summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-08-21 18:54:53 -0700
committerOri Bernstein <ori@eigenstate.org>2015-08-21 19:08:40 -0700
commit14aeadb41737f1765b6f3489f3b8da330aeccf39 (patch)
tree58eeceec013d79b26e024f47a065896e5a44a21d
parent0bd2678722f5f70a063190d54d12e62420f02b05 (diff)
downloadmc-14aeadb41737f1765b6f3489f3b8da330aeccf39.tar.gz
Get closer to the C ABI
-rw-r--r--6/asm.h6
-rw-r--r--6/insns.def12
-rw-r--r--6/isel.c123
-rw-r--r--6/ra.c3
-rw-r--r--6/simp.c28
-rw-r--r--libstd/syscall+freebsd-x64.s32
-rw-r--r--libstd/syscall+linux-x64.s35
-rw-r--r--libstd/syscall+osx-x64.s115
-rw-r--r--libstd/util+posixy-x64.s3
-rw-r--r--libstd/varargs.myr4
-rw-r--r--mbld/deps.myr14
-rw-r--r--muse/Makefile1
-rw-r--r--muse/muse.c2
-rw-r--r--parse/parse.h2
-rwxr-xr-xtest/runtest.sh2
15 files changed, 182 insertions, 200 deletions
diff --git a/6/asm.h b/6/asm.h
index 0797eba..2a4946a 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -130,10 +130,14 @@ struct Insn {
struct Func {
char *name; /* function name */
int isexport; /* is this exported from the asm? */
- size_t stksz; /* stack size */
Type *type; /* type of function */
+
+ Node **args; /* argument list */
+ size_t nargs; /* number of args, including hidden ones */
Htab *stkoff; /* Loc* -> int stackoff map */
+ size_t stksz; /* stack size */
Node *ret; /* return value */
+
Cfg *cfg; /* flow graph */
};
diff --git a/6/insns.def b/6/insns.def
index 1ff515a..8682263 100644
--- a/6/insns.def
+++ b/6/insns.def
@@ -304,7 +304,11 @@ Insn(Ixorp,
Insn(Icall,
"\tcall %v\n",
"\tCALL %V\n",
- Use(.l={1}),
+ Use(.l={1}, .r={
+ Rrdi, Rrsi, Rrdx, Rrcx, Rr8, Rr9,
+ Rxmm0d, Rxmm1d, Rxmm2d, Rxmm3d,
+ Rxmm4d, Rxmm5d, Rxmm6d, Rxmm7d,
+ }),
Def(.r={Rrax, Rrbx, Rrcx, Rrdx, Rrsi,
Rrdi, Rr8,Rr9,Rr10,Rr11,
Rxmm0d, Rxmm1d, Rxmm2d, Rxmm3d,
@@ -315,7 +319,11 @@ Insn(Icall,
Insn(Icallind,
"\tcall *%v\n",
"\tCALL *%V\n",
- Use(.l={1}),
+ Use(.l={1}, .r={
+ Rrdi, Rrsi, Rrdx, Rrcx, Rr8, Rr9,
+ Rxmm0d, Rxmm1d, Rxmm2d, Rxmm3d,
+ Rxmm4d, Rxmm5d, Rxmm6d, Rxmm7d,
+ }),
Def(.r={Rrax, Rrbx, Rrcx, Rrdx, Rrsi,
Rrdi, Rr8,Rr9,Rr10,Rr11,
Rxmm0d, Rxmm1d, Rxmm2d, Rxmm3d,
diff --git a/6/isel.c b/6/isel.c
index 3a1a7f2..9cf81b6 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -19,6 +19,14 @@
/* forward decls */
Loc *selexpr(Isel *s, Node *n);
+#define Nfloatregargs 8
+#define Nintregargs 6
+regid floatargregs[] = {
+ Rxmm0d, Rxmm1d, Rxmm2d, Rxmm3d,
+ Rxmm4d, Rxmm5d, Rxmm6d, Rxmm7d,
+};
+regid intargregs[] = {Rrdi, Rrsi, Rrdx, Rrcx, Rr8, Rr9};
+
/* used to decide which operator is appropriate
* for implementing various conditional operators */
struct {
@@ -50,21 +58,19 @@ struct {
[Ofle] = {Icomis, Ijbe, Isetbe},
};
-static Mode mode(Node *n)
+static Mode tymode(Type *t)
{
- Type *t;
-
- t = tybase(exprtype(n));
/* FIXME: What should the mode for, say, structs be when we have no
* intention of loading /through/ the pointer? For now, we'll just say it's
* the pointer mode, since we expect to address through the pointer */
+ t = tybase(t);
switch (t->type) {
case Tyflt32: return ModeF; break;
case Tyflt64: return ModeD; break;
default:
if (stacktype(t))
return ModeQ;
- switch (size(n)) {
+ switch (tysize(t)) {
case 1: return ModeB; break;
case 2: return ModeW; break;
case 4: return ModeL; break;
@@ -75,6 +81,16 @@ static Mode mode(Node *n)
return ModeQ;
}
+static Mode mode(Node *n)
+{
+ if (n->type == Nexpr)
+ return tymode(exprtype(n));
+ else if (n->type == Ndecl)
+ return tymode(n->decl.type);
+ else
+ die("invalid node type");
+}
+
static Loc *loc(Isel *s, Node *n)
{
ssize_t stkoff;
@@ -90,9 +106,11 @@ static Loc *loc(Isel *s, Node *n)
stkoff = ptoi(htget(s->stkoff, n));
l = locmem(-stkoff, locphysreg(Rrbp), NULL, mode(n));
} else {
- if (!hthas(s->reglocs, n))
- htput(s->reglocs, n, locreg(mode(n)));
- return htget(s->reglocs, n);
+ l = htget(s->reglocs, n);
+ if (!l) {
+ l = locreg(mode(n));
+ htput(s->reglocs, n, l);
+ }
}
break;
case Olit:
@@ -471,14 +489,31 @@ static void call(Isel *s, Node *n)
g(s, op, f, NULL);
}
+static size_t countargs(Type *t)
+{
+ size_t nargs;
+
+ t = tybase(t);
+ nargs = t->nsub - 1;
+ if (stacktype(t->sub[0]))
+ nargs++;
+ /* valists are replaced with hidden type parameter,
+ * which we want on the stack for ease of ABI */
+ if (tybase(t->sub[t->nsub - 1])->type == Tyvalist)
+ nargs--;
+ return nargs;
+}
+
static Loc *gencall(Isel *s, Node *n)
{
Loc *src, *dst, *arg; /* values we reduced */
+ size_t argsz, argoff, nargs;
+ size_t nfloats, nints;
Loc *retloc, *rsp, *ret; /* hard-coded registers */
Loc *stkbump; /* calculated stack offset */
- int argsz, argoff;
size_t i, a;
- Type *t;
+ int vararg;
+ Type *t, *fn;
rsp = locphysreg(Rrsp);
t = exprtype(n);
@@ -492,6 +527,10 @@ static Loc *gencall(Isel *s, Node *n)
retloc = coreg(Rrax, mode(n));
ret = locreg(mode(n));
}
+ fn = tybase(exprtype(n->expr.args[0]));
+ /* calculate the number of args we expect to see, adjust
+ * for a hidden return argument. */
+ nargs = countargs(fn);
argsz = 0;
/* Have to calculate the amount to bump the stack
* pointer by in one pass first, otherwise if we push
@@ -510,20 +549,36 @@ static Loc *gencall(Isel *s, Node *n)
/* Now, we can evaluate the arguments */
argoff = 0;
+ nfloats = 0;
+ nints = 0;
+ vararg = 0;
for (i = 1; i < n->expr.nargs; i++) {
arg = selexpr(s, n->expr.args[i]);
argoff = align(argoff, min(size(n->expr.args[i]), Ptrsz));
+ if (i > nargs)
+ vararg = 1;
if (stacknode(n->expr.args[i])) {
src = locreg(ModeQ);
g(s, Ilea, arg, src, NULL);
a = alignto(1, n->expr.args[i]->expr.type);
blit(s, rsp, src, argoff, 0, size(n->expr.args[i]), a);
+ argoff += size(n->expr.args[i]);
+ } else if (!vararg && isfloatmode(arg->mode) && nfloats < Nfloatregargs) {
+ dst = coreg(floatargregs[nfloats], arg->mode);
+ arg = inri(s, arg);
+ g(s, Imovs, arg, dst, NULL);
+ nfloats++;
+ } else if (!vararg && isintmode(arg->mode) && nints < Nintregargs) {
+ dst = coreg(intargregs[nints], arg->mode);
+ arg = inri(s, arg);
+ g(s, Imov, arg, dst, NULL);
+ nints++;
} else {
dst = locmem(argoff, rsp, NULL, arg->mode);
arg = inri(s, arg);
stor(s, arg, dst);
+ argoff += size(n->expr.args[i]);
}
- argoff += size(n->expr.args[i]);
}
call(s, n->expr.args[0]);
if (argsz)
@@ -842,7 +897,47 @@ Reg savedregs[] = {
Rnone
};
-static void prologue(Isel *s, size_t sz)
+void addarglocs(Isel *s, Func *fn)
+{
+ size_t i, nints, nfloats, nargs;
+ size_t argoff;
+ int vararg;
+ Node *arg;
+ Loc *a, *l;
+
+ argoff = 0;
+ nfloats = 0;
+ nints = 0;
+ vararg = 0;
+ nargs = countargs(fn->type);
+ for (i = 0; i < fn->nargs; i++) {
+ arg = fn->args[i];
+ argoff = align(argoff, min(size(arg), Ptrsz));
+ if (i >= nargs)
+ vararg = 1;
+ if (stacknode(arg)) {
+ htput(s->stkoff, arg, itop(-(argoff + 2*Ptrsz)));
+ argoff += size(arg);
+ } else if (!vararg && isfloatmode(mode(arg)) && nfloats < Nfloatregargs) {
+ a = coreg(floatargregs[nfloats], mode(arg));
+ l = locreg(mode(arg));
+ g(s, Imovs, a, l, NULL);
+ htput(s->reglocs, arg, l);
+ nfloats++;
+ } else if (!vararg && isintmode(mode(arg)) && nints < Nintregargs) {
+ a = coreg(intargregs[nints], mode(arg));
+ l = locreg(mode(arg));
+ g(s, Imov, a, l, NULL);
+ htput(s->reglocs, arg, l);
+ nints++;
+ } else {
+ htput(s->stkoff, arg, itop(-(argoff + 2*Ptrsz)));
+ argoff += size(arg);
+ }
+ }
+}
+
+static void prologue(Isel *s, Func *fn, size_t sz)
{
Loc *rsp;
Loc *rbp;
@@ -867,6 +962,7 @@ static void prologue(Isel *s, size_t sz)
g(s, Imov, phys, s->calleesave[i], NULL);
}
}
+ addarglocs(s, fn);
s->nsaved = i;
s->stksz = stksz; /* need to update if we spill */
}
@@ -927,7 +1023,7 @@ void selfunc(Isel *is, Func *fn, Htab *globls, Htab *strtab)
lappend(&is->bb, &is->nbb, mkasmbb(fn->cfg->bb[i]));
is->curbb = is->bb[0];
- prologue(is, fn->stksz);
+ prologue(is, fn, fn->stksz);
for (j = 0; j < fn->cfg->nbb - 1; j++) {
is->curbb = is->bb[j];
if (!is->bb[j])
@@ -945,4 +1041,5 @@ void selfunc(Isel *is, Func *fn, Htab *globls, Htab *strtab)
is->curbb = is->bb[is->nbb - 1];
epilogue(is);
regalloc(is);
+ is->stksz->lit = align(is->stksz->lit, 16);
}
diff --git a/6/ra.c b/6/ra.c
index 8e67f43..cb2057a 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -919,6 +919,8 @@ static int spillmetric(Isel *s, regid r)
{
if (s->nuses[r] == 0)
return -1;
+ if (bshas(s->neverspill, r))
+ return -10000;
return s->degree[r] * 100 / s->nuses[r];
}
@@ -953,7 +955,6 @@ static void selspill(Isel *s)
if (!m) {
for (i = 0; i < s->nwlspill; i++) {
if (bshas(s->neverspill, s->wlspill[i]->reg.id)) {
- printf("Not spilling %zd\n", s->wlspill[i]->reg.id);
continue;
}
m = s->wlspill[i];
diff --git a/6/simp.c b/6/simp.c
index 17ce36f..81b0a53 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -47,10 +47,13 @@ struct Simp {
/* location handling */
Node **blobs;
size_t nblobs;
- size_t stksz;
- size_t argsz;
Htab *globls;
- Htab *stkoff;
+
+ Htab *_stkoff;
+ size_t stksz;
+
+ Node **args;
+ size_t nargs;
};
static Node *simp(Simp *s, Node *n);
@@ -166,7 +169,7 @@ static Node *mul(Node *a, Node *b)
static int addressable(Simp *s, Node *a)
{
if (a->type == Ndecl || (a->type == Nexpr && exprop(a) == Ovar))
- return hthas(s->stkoff, a) || hthas(s->globls, a);
+ return hthas(s->_stkoff, a) || hthas(s->globls, a);
else
return stacknode(a);
}
@@ -209,7 +212,7 @@ static void forcelocal(Simp *s, Node *n)
dump(n, stdout);
printf("declared at %zd, size = %zd\n", s->stksz, size(n));
}
- htput(s->stkoff, n, itop(s->stksz));
+ htput(s->_stkoff, n, itop(s->stksz));
}
static void declarelocal(Simp *s, Node *n)
@@ -1565,13 +1568,7 @@ static Node *rval(Simp *s, Node *n, Node *dst)
static void declarearg(Simp *s, Node *n)
{
assert(n->type == Ndecl || (n->type == Nexpr && exprop(n) == Ovar));
- s->argsz = align(s->argsz, min(size(n), Ptrsz));
- htput(s->stkoff, n, itop(-(s->argsz + 2*Ptrsz)));
- if (debugopt['i']) {
- dump(n, stdout);
- printf("declared at %zd\n", -(s->argsz + 2*Ptrsz));
- }
- s->argsz += size(n);
+ lappend(&s->args, &s->nargs, n);
}
static int islbl(Node *n)
@@ -1724,10 +1721,13 @@ static Func *simpfn(Simp *s, char *name, Node *dcl)
fn = zalloc(sizeof(Func));
fn->name = strdup(name);
+ fn->type = dcl->decl.type;
fn->isexport = isexport(dcl);
fn->stksz = align(s->stksz, 8);
- fn->stkoff = s->stkoff;
+ fn->stkoff = s->_stkoff;
fn->ret = s->ret;
+ fn->args = s->args;
+ fn->nargs = s->nargs;
fn->cfg = cfg;
return fn;
}
@@ -1800,7 +1800,7 @@ void simpglobl(Node *dcl, Htab *globls, Func ***fn, size_t *nfn, Node ***blob, s
if (ismain(dcl))
dcl->decl.vis = Vishidden;
- s.stkoff = mkht(varhash, vareq);
+ s._stkoff = mkht(varhash, vareq);
s.globls = globls;
s.blobs = *blob;
s.nblobs = *nblob;
diff --git a/libstd/syscall+freebsd-x64.s b/libstd/syscall+freebsd-x64.s
index 680971e..8002099 100644
--- a/libstd/syscall+freebsd-x64.s
+++ b/libstd/syscall+freebsd-x64.s
@@ -1,14 +1,5 @@
.globl sys$syscall
sys$syscall:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
/*
hack: We load 6 args regardless of
how many we actually have. This may
@@ -16,24 +7,15 @@ sys$syscall:
doesn't use them, it's going to be
harmless.
*/
- movq 80 (%rsp),%rax
- movq 88 (%rsp),%rdi
- movq 96 (%rsp),%rsi
- movq 104(%rsp),%rdx
- movq 112(%rsp),%r10
- movq 120(%rsp),%r8
- movq 128(%rsp),%r9
+ movq %rdi,%rax
+ movq %rsi,%rdi
+ movq %rdx,%rsi
+ movq %rcx,%rdx
+ movq %r8,%r10
+ movq %r9,%r8
+ movq 8(%rsp),%r9
syscall
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
diff --git a/libstd/syscall+linux-x64.s b/libstd/syscall+linux-x64.s
index 0393497..f7c020d 100644
--- a/libstd/syscall+linux-x64.s
+++ b/libstd/syscall+linux-x64.s
@@ -1,15 +1,5 @@
.globl sys$syscall
sys$syscall:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
-
/*
hack: We load 6 args regardless of
how many we actually have. This may
@@ -17,25 +7,16 @@ sys$syscall:
doesn't use them, it's going to be
harmless.
*/
- movq 80 (%rsp),%rax
- /* 88: hidden type arg */
- movq 96 (%rsp),%rdi
- movq 104(%rsp),%rsi
- movq 112(%rsp),%rdx
- movq 120(%rsp),%r10
- movq 128(%rsp),%r8
- movq 136(%rsp),%r9
+ movq %rdi,%rax
+ /* 8(%rsp): hidden type arg */
+ movq 16(%rsp),%rdi
+ movq 24(%rsp),%rsi
+ movq 32(%rsp),%rdx
+ movq 40(%rsp),%r10
+ movq 48(%rsp),%r8
+ movq 56(%rsp),%r9
syscall
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
diff --git a/libstd/syscall+osx-x64.s b/libstd/syscall+osx-x64.s
index 18968e6..8fc1d4c 100644
--- a/libstd/syscall+osx-x64.s
+++ b/libstd/syscall+osx-x64.s
@@ -1,14 +1,6 @@
.globl _sys$syscall
_sys$syscall:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
+
/*
hack: We load 6 args regardless of
how many we actually have. This may
@@ -16,29 +8,20 @@ _sys$syscall:
doesn't use them, it's going to be
harmless.
*/
- movq 80 (%rsp),%rax
- /* 88: hidden type arg */
- movq 96 (%rsp),%rdi
- movq 104(%rsp),%rsi
- movq 112(%rsp),%rdx
- movq 120(%rsp),%r10
- movq 128(%rsp),%r8
- movq 136(%rsp),%r9
+ movq %rdi,%rax
+ /* 8(%rsp): hidden type arg */
+ movq 16(%rsp),%rdi
+ movq 24(%rsp),%rsi
+ movq 32(%rsp),%rdx
+ movq 40(%rsp),%r10
+ movq 48(%rsp),%r8
+ movq 56(%rsp),%r9
syscall
jae .success
negq %rax
.success:
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
/*
@@ -51,16 +34,6 @@ _sys$syscall:
*/
.globl _sys$__osx_fork
_sys$__osx_fork:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
-
movq $0x2000002,%rax
syscall
@@ -72,16 +45,6 @@ _sys$__osx_fork:
jz .isparent
xorq %rax,%rax
.isparent:
-
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
/*
@@ -91,16 +54,6 @@ _sys$__osx_fork:
*/
.globl _sys$__osx_pipe
_sys$__osx_pipe:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
-
movq $0x200002a,%rax
syscall
@@ -112,30 +65,10 @@ _sys$__osx_pipe:
movl %eax,(%rdi)
movl %edx,4(%rdi)
xorq %rax,%rax
-
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
.globl _sys$__osx_lseek
_sys$__osx_lseek:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
-
movq $0x20000C7,%rax
syscall
@@ -146,31 +79,11 @@ _sys$__osx_lseek:
movq 80(%rsp),%rdi
shlq $32,%rdx
orq %rdx,%rax
-
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
.globl _sys$__osx_gettimeofday
_sys$__osx_gettimeofday:
- pushq %rbp
- pushq %rdi
- pushq %rsi
- pushq %rdx
- pushq %r10
- pushq %r8
- pushq %r9
- pushq %rcx
- pushq %r11
-
movq $0x2000074,%rax
syscall
@@ -182,15 +95,5 @@ _sys$__osx_gettimeofday:
movq %rax, (%rdi)
movl %edx,8(%rdi)
xorq %rax,%rax
-
- popq %r11
- popq %rcx
- popq %r9
- popq %r8
- popq %r10
- popq %rdx
- popq %rsi
- popq %rdi
- popq %rbp
ret
diff --git a/libstd/util+posixy-x64.s b/libstd/util+posixy-x64.s
index b6a9b85..d44ab79 100644
--- a/libstd/util+posixy-x64.s
+++ b/libstd/util+posixy-x64.s
@@ -56,10 +56,9 @@ sys$alloca:
pushq %rbx
movq 8(%rbp),%r15 /* ret addr */
- movq 16(%rbp),%rbx /* len */
/* get stack space */
- subq %rbx,%rsp /* get stack space */
+ subq %rdi,%rsp /* get stack space */
movq %rsp,%rax /* top of stack (return value) */
subq $31,%rsp /* "unpop" the args for return */
andq $(~15),%rsp /* align */
diff --git a/libstd/varargs.myr b/libstd/varargs.myr
index e0948a6..c2ed1b2 100644
--- a/libstd/varargs.myr
+++ b/libstd/varargs.myr
@@ -77,6 +77,9 @@ const vabytes = {ap
-> sl
}
+const inspectarg = {x
+}
+
generic vanext = {ap -> @a
var v : @a
var ti
@@ -87,6 +90,7 @@ generic vanext = {ap -> @a
/* apply the alignment to the arg pointer */
align = ti.align castto(intptr)
+ inspectarg(align)
p = ap.args castto(intptr)
p = (p + align - 1) & ~(align - 1)
ap.args = p castto(byte#)
diff --git a/mbld/deps.myr b/mbld/deps.myr
index f8fd661..ca01175 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -14,6 +14,7 @@ pkg bld =
var usepat : regex.regex#
;;
+const Abiversion = 5
var usepat : regex.regex#
type dep = union
@@ -234,12 +235,13 @@ const scrapelibs = {dg, lib, incs
| `std.None: std.fatal("library {}: could not read usefile\n", lib)
;;
match bio.getbe32(f)
- | `std.Some 4: /* nothing: version matches. */
- | `std.Some 3: std.fput(1, "library {}: warning: old usefile version\n", lib)
- | `std.Some 2: std.fput(1, "library {}: warning: old usefile version\n", lib)
- | `std.Some 1: std.fput(1, "library {}: warning: old usefile version\n", lib)
- | `std.Some 0: std.fput(1, "library {}: warning: old usefile version\n", lib)
- | `std.Some _: std.fatal("library {}: usefile version unknown\n", lib)
+ | `std.Some Abiversion: /* nothing: version matches. */
+ | `std.Some v:
+ if v < Abiversion
+ std.fput(1, "library {}: warning: old abi version\n", lib)
+ else
+ std.fatal("library {}: usefile version unknown\n", lib)
+ ;;
| `std.None: std.fatal("library {}: corrutpt or invalid usefile\n", lib)
;;
std.slfree(rdstr(f))
diff --git a/muse/Makefile b/muse/Makefile
index 7cc6da5..1ec6377 100644
--- a/muse/Makefile
+++ b/muse/Makefile
@@ -5,3 +5,4 @@ OBJ=muse.o
DEPS=../parse/libparse.a
include ../mk/c.mk
+include ../config.mk
diff --git a/muse/muse.c b/muse/muse.c
index 96d1f43..0923d83 100644
--- a/muse/muse.c
+++ b/muse/muse.c
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
lappend(&incpaths, &nincpaths, Instroot "/lib/myr");
if (!outfile) {
- fprintf(stderr, "Output file needed when merging usefiles.");
+ fprintf(stderr, "output file needed when merging usefiles.\n");
exit(1);
}
diff --git a/parse/parse.h b/parse/parse.h
index 4743c0b..129ecab 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -4,7 +4,7 @@
# define FATAL
#endif
-#define Abiversion 4
+#define Abiversion 5
typedef uint8_t byte;
typedef unsigned int uint;
diff --git a/test/runtest.sh b/test/runtest.sh
index 332e0d2..18f2cdc 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -10,7 +10,7 @@ NPASSES=0
function build {
rm -f $1 $1.o $1.s $1.use
- ../mbld/mbld -b $1 -C../6/6m -M../muse/muse -I../libstd -r../rt/_myrrt.o $1.myr
+ mbld -b $1 -C../6/6m -M../muse/muse -I../libstd -r../rt/_myrrt.o $1.myr
}
function pass {