summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/typeinfo.c3
-rw-r--r--mbld/build.myr9
-rw-r--r--mbld/deps.myr12
-rw-r--r--mbld/types.myr2
-rw-r--r--muse/muse.c11
-rw-r--r--parse/parse.h3
-rw-r--r--parse/use.c25
7 files changed, 53 insertions, 12 deletions
diff --git a/6/typeinfo.c b/6/typeinfo.c
index 94eccfa..0f420cf 100644
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -234,8 +234,7 @@ size_t tysize(Type *t)
die("size of empty type => bailing.");
switch (t->type) {
case Tyvoid:
- die("void has no size");
- return 1;
+ return 0;
case Tybool: case Tyint8:
case Tybyte: case Tyuint8:
return 1;
diff --git a/mbld/build.myr b/mbld/build.myr
index afbfba5..055f8b7 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -268,7 +268,7 @@ const compile = {dg, src, incs
;;
}
-const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extralibs
+const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extlibs
var cmd
cmd = [][:]
@@ -300,7 +300,7 @@ const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extralibs
cmd = addlibs(cmd, dg.libs, incs)
/* add extra libs */
- for l in dg.extralibs
+ for l in dg.extlibs
cmd = std.slpush(cmd, std.fmt("-l{}", l))
;;
@@ -344,10 +344,13 @@ const mergeuse = {dg, lib, files, incs
for f in files
if std.hassuffix(f, ".myr")
cmd = std.slpush(cmd, srcswapsuffix(f, ".use"))
- elif !std.hassuffix(f, ".s")
+ elif !std.hassuffix(f, ".s") && !std.hassuffix(f, ".glue.c")
std.fatal("unknown file type for {}\n", f)
;;
;;
+ for l in dg.extlibs
+ cmd = std.slpush(cmd, std.fmt("-l{}", l))
+ ;;
run(cmd)
strlistfree(cmd)
}
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 7a00574..66aeb6a 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -55,7 +55,7 @@ const myrdeps = {b, mt, doclean, addsrc
.seen = std.mkht(std.strhash, std.streq),
.done = std.mkht(std.strhash, std.streq),
.cflags = std.mkht(std.strhash, std.streq),
- .extralibs = [][:],
+ .extlibs = [][:],
.dynamic = false,
])
/* direct dependencies of binary */
@@ -87,7 +87,7 @@ const myrdeps = {b, mt, doclean, addsrc
elif std.hassuffix(srcs[i], ".glue.c")
(cflags, libs) = scrapecflags(b, dg, srcs[i])
std.htput(dg.cflags, srcs[i], cflags)
- dg.extralibs = std.sljoin(dg.extralibs, libs)
+ dg.extlibs = std.sljoin(dg.extlibs, libs)
dg.dynamic = true
;;
;;
@@ -232,7 +232,6 @@ const getcflags = {ln, cflags, libs
match regex.exec(cflagpat, ln)
| `std.None:
| `std.Some m:
- std.put("Got cflags {}\n", m)
flags = std.strtok(m[1])
for fl in flags
cflags = std.slpush(cflags, std.sldup(fl))
@@ -243,7 +242,6 @@ const getcflags = {ln, cflags, libs
match regex.exec(clibpat, ln)
| `std.None:
| `std.Some m:
- std.put("Got libs {}\n", m)
flags = std.strtok(m[1])
for fl in flags
libs = std.slpush(libs, std.sldup(fl))
@@ -315,7 +313,6 @@ const scrapelibs = {dg, lib, incs
->
;;
- deps = [][:]
f = openlib(lib, incs)
match bio.getc(f)
| `std.Some 'U': /* nothing */
@@ -333,12 +330,17 @@ const scrapelibs = {dg, lib, incs
| `std.None: std.fatal("library {}: corrupt or invalid usefile\n", lib)
;;
std.slfree(rdstr(f))
+
done = false
+ deps = [][:]
while !done
match bio.getc(f)
| `std.Some 'L':
d = rdstr(f)
deps = std.slpush(deps, d)
+ | `std.Some 'X':
+ d = rdstr(f)
+ dg.extlibs = std.slpush(dg.extlibs, d)
| `std.Some _: done = true
| `std.None: done = true
;;
diff --git a/mbld/types.myr b/mbld/types.myr
index aeb6121..b6edca9 100644
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -72,7 +72,7 @@ pkg bld =
done : std.htab(byte[:], bool)#
/* used for linking C */
- extralibs : byte[:][:]
+ extlibs : byte[:][:]
cflags : std.htab(byte[:], byte[:][:])#
dynamic : bool
;;
diff --git a/muse/muse.c b/muse/muse.c
index 96dd5e1..c00ade6 100644
--- a/muse/muse.c
+++ b/muse/muse.c
@@ -21,6 +21,8 @@ int show;
char debugopt[128];
char **incpaths;
size_t nincpaths;
+char **extralibs;
+size_t nextralibs;
static void usage(char *prog)
{
@@ -52,7 +54,7 @@ int main(int argc, char **argv)
size_t i;
FILE *f;
- optinit(&ctx, "d:hmo:I:", argv, argc);
+ optinit(&ctx, "d:hmo:I:l:", argv, argc);
while (!optdone(&ctx)) {
switch (optnext(&ctx)) {
case 'h':
@@ -69,6 +71,9 @@ int main(int argc, char **argv)
case 'I':
lappend(&incpaths, &nincpaths, ctx.optarg);
break;
+ case 'l':
+ lappend(&extralibs, &nextralibs, ctx.optarg);
+ break;
case 's':
show = 1;
break;
@@ -85,6 +90,7 @@ int main(int argc, char **argv)
exit(1);
}
+ /* read and parse the file */
file = mkfile("internal");
file->file.globls = mkstab(0);
updatens(file->file.globls, outfile);
@@ -93,6 +99,9 @@ int main(int argc, char **argv)
mergeuse(ctx.args[i]);
infer(file);
tagexports(file, 1);
+ addextlibs(file, extralibs, nextralibs);
+
+ /* generate the usefile */
f = fopen(outfile, "w");
if (debugopt['s'] || show)
dumpstab(file->file.globls, stdout);
diff --git a/parse/parse.h b/parse/parse.h
index e7c849c..1d8086e 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -218,6 +218,8 @@ struct Node {
size_t nuses;
char **libdeps; /* library dependencies */
size_t nlibdeps;
+ char **extlibs; /* non-myrddin libraries */
+ size_t nextlibs;
Node **stmts; /* all top level statements */
size_t nstmts;
Node **init; /* a list of all __init__ function names of our deps. NB, this is a Nname, not an Ndecl */
@@ -595,6 +597,7 @@ int loaduse(char *path, FILE *f, Stab *into, Vis vis);
void readuse(Node *use, Stab *into, Vis vis);
void writeuse(FILE *fd, Node *file);
void tagexports(Node *file, int hidelocal);
+void addextlibs(Node *file, char **libs, size_t nlibs);
/* typechecking/inference */
void infer(Node *file);
diff --git a/parse/use.c b/parse/use.c
index 9bd80d3..a5cbe46 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -41,6 +41,18 @@ static intptr_t *traitfixid; /* list of traits we need to replace */
static size_t ntraitfixid; /* size of replacement list */
+void addextlibs(Node *file, char **libs, size_t nlibs)
+{
+ size_t i, j;
+
+ for (i = 0; i < nlibs; i++) {
+ for (j = 0; j < file->file.nextlibs; j++)
+ if (!strcmp(file->file.extlibs[j], libs[i]))
+ continue;
+ lappend(&file->file.extlibs, &file->file.nextlibs, libs[i]);
+ }
+}
+
/* Outputs a symbol table to file in a way that can be
* read back usefully. Only writes declarations, types
* and sub-namespaces. Captured variables are ommitted. */
@@ -862,6 +874,15 @@ int loaduse(char *path, FILE *f, Stab *st, Vis vis)
lappend(&file->file.libdeps, &file->file.nlibdeps, lib);
foundlib:
break;
+ case 'X':
+ lib = rdstr(f);
+ for (i = 0; i < file->file.nextlibs; i++)
+ if (!strcmp(file->file.extlibs[i], lib))
+ /* break out of both loop and switch */
+ goto foundextlib;
+ lappend(&file->file.extlibs, &file->file.nextlibs, lib);
+foundextlib:
+ break;
case 'F':
lappend(&file->file.files, &file->file.nfiles, rdstr(f));
break;
@@ -995,6 +1016,10 @@ void writeuse(FILE *f, Node *file)
wrbyte(f, 'L');
wrstr(f, file->file.libdeps[i]);
}
+ for (i = 0; i < file->file.nextlibs; i++) {
+ wrbyte(f, 'X');
+ wrstr(f, file->file.extlibs[i]);
+ }
/* source file name */
wrbyte(f, 'F');