]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: add liblink build information
authorRuss Cox <rsc@golang.org>
Mon, 9 Dec 2013 03:48:11 +0000 (22:48 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 9 Dec 2013 03:48:11 +0000 (22:48 -0500)
In addition to adding the library, change the way the anames array is created.
Previously, it was written to src/cmd/6l/enam.c (and similarly for 5l and 8l)
and each of the other tools (6g, 6c, 6a) compiled the 6l/enam.c file in addition
to their own sources.

Now that there is a library shared by all these programs, move the anames
array into that library. To eliminate name conflicts, name the array after
the architecture letter: anames5, anames6, anames8.

First step to linker cleanup (golang.org/s/go13linker).

This CL does not build by itself. It depends on the CLs introducing
liblink and changing commands to use it.

R=iant
CC=golang-dev
https://golang.org/cl/35740044

.hgignore
src/cmd/dist/a.h
src/cmd/dist/build.c
src/cmd/dist/buildgc.c

index afe76cf22099d0f58cccba220eced82c056bd9be..2f11d9c2333f97bb231eba149864ae9ff84b36b6 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -33,7 +33,7 @@ misc/goplay/goplay
 misc/osx/*.pkg
 misc/osx/*.dmg
 src/cmd/?a/y.output
-src/cmd/?l/enam.c
+src/liblink/anames?.c
 src/cmd/cc/y.output
 src/cmd/cgo/zdefaultcc.go
 src/cmd/dist/dist.dSYM
index 9de93180f188a0f077c2484be2d556100dec2820..3052e515b3164faa3472625e4b89c0bbeb0284ef 100644 (file)
@@ -93,7 +93,7 @@ void  cmdversion(int, char**);
 
 // buildgc.c
 void   gcopnames(char*, char*);
-void   mkenam(char*, char*);
+void   mkanames(char*, char*);
 
 // buildruntime.c
 void   mkzasm(char*, char*);
index 51503e2800b7ba4fd3fa70cc335b6f3c38ea1542..69e2aafad9bac44fbb653c3f23d7bb9e7a402a61 100644 (file)
@@ -493,6 +493,18 @@ static struct {
                "$GOROOT/include/ureg_arm.h",
                "$GOROOT/include/ureg_x86.h",
        }},
+       {"liblink", {
+               "$GOROOT/include/u.h",
+               "$GOROOT/include/utf.h",
+               "$GOROOT/include/fmt.h",
+               "$GOROOT/include/libc.h",
+               "$GOROOT/include/bio.h",
+               "$GOROOT/include/ar.h",
+               "$GOROOT/include/link.h",
+               "anames5.c",
+               "anames6.c",
+               "anames8.c",
+       }},
        {"cmd/cc", {
                "-pgen.c",
                "-pswt.c",
@@ -508,19 +520,16 @@ static struct {
        {"cmd/5c", {
                "../cc/pgen.c",
                "../cc/pswt.c",
-               "../5l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
        }},
        {"cmd/6c", {
                "../cc/pgen.c",
                "../cc/pswt.c",
-               "../6l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
        }},
        {"cmd/8c", {
                "../cc/pgen.c",
                "../cc/pswt.c",
-               "../8l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a",
        }},
        {"cmd/5g", {
@@ -529,7 +538,6 @@ static struct {
                "../gc/plive.c",
                "../gc/popt.c",
                "../gc/popt.h",
-               "../5l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
        }},
        {"cmd/6g", {
@@ -538,7 +546,6 @@ static struct {
                "../gc/plive.c",
                "../gc/popt.c",
                "../gc/popt.h",
-               "../6l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
        }},
        {"cmd/8g", {
@@ -547,25 +554,22 @@ static struct {
                "../gc/plive.c",
                "../gc/popt.c",
                "../gc/popt.h",
-               "../8l/enam.c",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a",
        }},
        {"cmd/5l", {
                "../ld/*",
-               "enam.c",
        }},
        {"cmd/6l", {
                "../ld/*",
-               "enam.c",
        }},
        {"cmd/8l", {
                "../ld/*",
-               "enam.c",
        }},
        {"cmd/go", {
                "zdefaultcc.go",
        }},
        {"cmd/", {
+               "$GOROOT/pkg/obj/$GOOS_$GOARCH/liblink.a",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libmach.a",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/libbio.a",
                "$GOROOT/pkg/obj/$GOOS_$GOARCH/lib9.a",
@@ -596,7 +600,9 @@ static struct {
        void (*gen)(char*, char*);
 } gentab[] = {
        {"opnames.h", gcopnames},
-       {"enam.c", mkenam},
+       {"anames5.c", mkanames},
+       {"anames6.c", mkanames},
+       {"anames8.c", mkanames},
        {"zasm_", mkzasm},
        {"zdefaultcc.go", mkzdefaultcc},
        {"zsys_", mkzsys},
@@ -605,6 +611,9 @@ static struct {
        {"zruntime_defs_", mkzruntimedefs},
        {"zversion.go", mkzversion},
        {"zaexperiment.h", mkzexperiment},
+
+       // not generated anymore, but delete the file if we see it
+       {"enam.c", nil},
 };
 
 // install installs the library, package, or binary associated with dir,
@@ -869,6 +878,8 @@ install(char *dir)
                p = files.p[i];
                elem = lastelem(p);
                for(j=0; j<nelem(gentab); j++) {
+                       if(gentab[j].gen == nil)
+                               continue;
                        if(hasprefix(elem, gentab[j].nameprefix)) {
                                if(vflag > 1)
                                        errprintf("generate %s\n", p);
@@ -1247,6 +1258,7 @@ static char *buildorder[] = {
        "lib9",
        "libbio",
        "libmach",
+       "liblink",
 
        "misc/pprof",
 
@@ -1338,6 +1350,7 @@ static char *cleantab[] = {
        "lib9",
        "libbio",
        "libmach",
+       "liblink",
        "pkg/bufio",
        "pkg/bytes",
        "pkg/container/heap",
index 03a797f2cff3257df0794955a5daa5f71a57e8ae..1f0625daa005cb0c5b5117e53b4e2b8e3e7c8332 100644 (file)
@@ -63,10 +63,10 @@ gcopnames(char *dir, char *file)
        vfree(&fields);
 }
 
-// mkenam reads [568].out.h and writes enam.c
+// mkanames reads [568].out.h and writes anames[568].c
 // The format is much the same as the Go opcodes above.
 void
-mkenam(char *dir, char *file)
+mkanames(char *dir, char *file)
 {
        int i, ch;
        Buf in, b, out;
@@ -78,11 +78,11 @@ mkenam(char *dir, char *file)
        binit(&out);
        vinit(&lines);
 
-       ch = dir[xstrlen(dir)-2];
-       bprintf(&b, "%s/../%cl/%c.out.h", dir, ch, ch);
+       ch = file[xstrlen(file)-3];
+       bprintf(&b, "%s/../cmd/%cl/%c.out.h", dir, ch, ch);
        readfile(&in, bstr(&b));
        splitlines(&lines, bstr(&in));
-       bwritestr(&out, "char*  anames[] = {\n");
+       bprintf(&out, "char*    anames%c[] = {\n", ch);
        for(i=0; i<lines.len; i++) {
                if(hasprefix(lines.p[i], "\tA")) {
                        p = xstrstr(lines.p[i], ",");