shithub: mc

Download patch

ref: a9c6f053de3a54b55fa10ad07c5a94c76e854f58
parent: 732ad41dc312266d89f33ce472b5fe23d099df19
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jun 21 22:49:52 EDT 2015

Get closer to a working Plan 9 build on new 6m.

--- a/6/asm.h
+++ b/6/asm.h
@@ -76,8 +76,11 @@
     char isglobl;
     union {
         uint64_t ival;
-        char *ref;
         struct {
+            char *str;
+            char isextern;
+        } ref;
+        struct {
             size_t len;
             char *buf;
         } bytes;
@@ -236,6 +239,7 @@
 void gengas(Node *file, char *out);
 void genp9(Node *file, char *out);
 Blob *tydescblob(Type *t);
+size_t blobsz(Blob *b);
 
 /* location generation */
 extern size_t maxregid;
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -542,7 +542,7 @@
             encodemin(fd, b->ival);
             break;
         case Btref:
-            fprintf(fd, "\t.quad %s\n", b->ref);
+            fprintf(fd, "\t.quad %s\n", b->ref.str);
             break;
         case Btbytes:
             writebytes(fd, b->bytes.buf, b->bytes.len);
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -500,7 +500,7 @@
 
 static size_t encodemin(FILE *fd, uint64_t val, size_t off, char *lbl)
 {
-    size_t i, shift;
+    size_t i, shift, n;
     uint8_t b;
 
     if (val < 128) {
@@ -512,6 +512,7 @@
         if (val < 1ULL << (7*i))
             break;
 
+    n = 0;
     shift = 8 - i;
     b = ~0 << (shift + 1);
     b |= val & ((1 << (8 - shift)) - 1);
@@ -518,7 +519,8 @@
     fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off, b);
     val >>=  shift;
     while (val != 0) {
-        fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off, (uint)val & 0xff);
+        n++;
+        fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off+n, (uint)val & 0xff);
         val >>= 8;
     }
     return i;
@@ -533,34 +535,37 @@
         return 0;
     switch (b->type) {
         case Bti8:
-            fprintf(fd, "\tDATA %s+%zd(SB)/1,$%zd\n", lbl, off, b->ival);
+            fprintf(fd, "DATA %s+%zd(SB)/1,$%zd\n", lbl, off+n, b->ival);
             n += 1;
             break;
         case Bti16:
-            fprintf(fd, "\tDATA %s+%zd(SB)/2,$%zd\n", lbl, off, b->ival);
+            fprintf(fd, "DATA %s+%zd(SB)/2,$%zd\n", lbl, off+n, b->ival);
             n += 2;
             break;
         case Bti32:
-            fprintf(fd, "\tDATA %s+%zd(SB)/4,$%zd\n", lbl, off, b->ival);
+            fprintf(fd, "DATA %s+%zd(SB)/4,$%zd\n", lbl, off+n, b->ival);
             n += 4;
             break;
         case Bti64:
-            fprintf(fd, "\tDATA %s+%zd(SB)/8,%zd\n", lbl, off, b->ival);
+            fprintf(fd, "DATA %s+%zd(SB)/8,%zd\n", lbl, off+n, b->ival);
             n += 8;
             break;
         case Btimin:
-            n += encodemin(fd, b->ival, off, lbl);
+            n += encodemin(fd, b->ival, off+n, lbl);
             break;
         case Btref:
-            fprintf(fd, "\tDATA %s+%zd/8,$%s\n", lbl, off, b->ref);
+            if (b->ref.isextern)
+                fprintf(fd, "DATA %s+%zd(SB)/8,$%s<>+0(SB)\n", lbl, off+n, b->ref.str);
+            else
+                fprintf(fd, "DATA %s+%zd(SB)/8,$%s+0(SB)\n", lbl, off+n, b->ref.str);
             n += 8;
             break;
         case Btbytes:
-            n += writebytes(fd, lbl, off, b->bytes.buf, b->bytes.len);
+            n += writebytes(fd, lbl, off+n, b->bytes.buf, b->bytes.len);
             break;
         case Btseq:
             for (i = 0; i < b->seq.nsub; i++)
-                n += gentyblob(fd, b->seq.sub[i], off, lbl);
+                n += gentyblob(fd, b->seq.sub[i], off+n, lbl);
             break;
     }
     return n;
@@ -574,11 +579,14 @@
     if (ty->type == Tyvar)
         return;
     b = tydescblob(ty);
-    if (b->lbl) {
-        if (b->isglobl)
-            snprintf(lbl, sizeof lbl, "DATA %s%s\n", Symprefix, lbl);
-        else
-            snprintf(lbl, sizeof lbl, "DATA %s%s<>+SB\n", Symprefix, lbl);
+    if (!b)
+        return;
+    if (b->isglobl) {
+        fprintf(fd, "GLOBL %s%s+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+        snprintf(lbl, sizeof lbl, "%s%s", Symprefix, b->lbl);
+    } else {
+        fprintf(fd, "GLOBL %s%s<>+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+        snprintf(lbl, sizeof lbl, "%s%s<>", Symprefix, b->lbl);
     }
     gentyblob(fd, b, 0, lbl);
 }
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -51,17 +51,18 @@
     return b;
 }
 
-static Blob *mkblobref(char *lbl)
+static Blob *mkblobref(char *lbl, int isextern)
 {
     Blob *b;
 
     b = zalloc(sizeof(Blob));
     b->type = Btref;
-    b->ref = strdup(lbl);
+    b->ref.str = strdup(lbl);
+    b->ref.isextern = isextern;
     return b;
 }
 
-static size_t blobsz(Blob *b)
+size_t blobsz(Blob *b)
 {
     size_t n;
     size_t i;
@@ -91,6 +92,7 @@
         default:
             die("unknown blob type");
     }
+    return 0;
 }
 
 void namevec(Blob ***sub, size_t *nsub, Node *n)
@@ -218,7 +220,7 @@
         case Tyname:
             i = snprintf(buf, sizeof buf, "%s", Symprefix);
             tydescid(buf + i, sizeof buf - i, ty);
-            lappend(&sub, &nsub, mkblobref(buf));
+            lappend(&sub, &nsub, mkblobref(buf, ty->isimport));
             break;
     }
     b = mkblobseq(sub, nsub);
--- a/doc/mkfile
+++ b/doc/mkfile
@@ -1,7 +1,6 @@
 MANS=\
 	mc.1 \
 	muse.1 \
-	myrbuild.1 \
 
 all:V: $MANS
 
--- a/mk/bootstrap/bootstrap+Plan9-amd64.sh
+++ b/mk/bootstrap/bootstrap+Plan9-amd64.sh
@@ -24,10 +24,10 @@
 echo 	../6/6.out	-I . `$pwd/sysselect.sh errno`;	../6/6.out	-I . `$pwd/sysselect.sh errno`
 echo 	../6/6.out	-I . cstrconv.myr ;	../6/6.out	-I . cstrconv.myr 
 echo 	../6/6.out	-I . `$pwd/sysselect.sh syswrap-ss`;	../6/6.out	-I . `$pwd/sysselect.sh syswrap-ss`
+echo 	../6/6.out	-I . introspect.myr ;	../6/6.out	-I . introspect.myr 
 echo 	../6/6.out	-I . varargs.myr ;	../6/6.out	-I . varargs.myr 
 echo 	../6/6.out	-I . chartype.myr ;	../6/6.out	-I . chartype.myr 
 echo 	../6/6.out	-I . cmp.myr ;	../6/6.out	-I . cmp.myr 
-echo 	../6/6.out	-I . hasprefix.myr ;	../6/6.out	-I . hasprefix.myr 
 echo 	../6/6.out	-I . slcp.myr ;	../6/6.out	-I . slcp.myr 
 echo 	../6/6.out	-I . sldup.myr ;	../6/6.out	-I . sldup.myr 
 echo 	../6/6.out	-I . slpush.myr ;	../6/6.out	-I . slpush.myr 
@@ -70,8 +70,8 @@
 echo 	../6/6.out	-I . swap.myr ;	../6/6.out	-I . swap.myr 
 echo 	../6/6.out	-I . bitset.myr ;	../6/6.out	-I . bitset.myr 
 echo 	../6/6.out	-I . `$pwd/sysselect.sh dial`;	../6/6.out	-I . `$pwd/sysselect.sh dial`
-echo 	../muse/6.out	-o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use ;	../muse/6.out	-o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use 
-echo 	ar	vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 ;	ar	vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 
+echo 	../muse/6.out	-o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use ;	../muse/6.out	-o std putint.use fmt.use try.use sort.use blat.use pathjoin.use strjoin.use mk.use errno.use hassuffix.use execvp.use swap.use types.use ipparse.use syswrap-ss.use strfind.use utf.use cstrconv.use search.use die.use units.use wait.use sljoin.use slpush.use result.use htab.use now.use strstrip.use bitset.use getcwd.use rand.use env.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use syswrap.use resolve.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use dial.use fltbits.use cmp.use sldup.use chartype.use fltfmt.use bigint.use extremum.use hashfuncs.use option.use slcp.use slfill.use introspect.use
+echo 	ar	vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 ;	ar	vu libstd.a putint.6 fmt.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 mk.6 errno.6 hassuffix.6 execvp.6 swap.6 types.6 ipparse.6 syswrap-ss.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 wait.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 bitset.6 getcwd.6 rand.6 env.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 syswrap.6 resolve.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 dial.6 fltbits.6 cmp.6 sldup.6 chartype.6 fltfmt.6 bigint.6 extremum.6 hashfuncs.6 option.6 slcp.6 slfill.6 introspect.6
 echo 	cd $pwd;	cd $pwd
 echo 	cd $pwd/libbio;	cd $pwd/libbio
 echo 	../6/6.out	-I ../libstd bio.myr ;	../6/6.out	-I ../libstd bio.myr