summaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-11-14 12:10:52 -0500
committerRuss Cox <rsc@golang.org>2014-11-14 12:10:52 -0500
commit6b31cfd20257f4d7226d5c4e95c67ed9b48ab58c (patch)
treefd7941be82dd45f113d8f0668e2c9b6a6ec3c77f /src/cmd/dist
parent9cabb766eb4acbe2c11ad0084659710919f40c0d (diff)
parent0fdd42d52b29f44cf6cffa4c881ee8b40f9b3090 (diff)
downloadgo-6b31cfd20257f4d7226d5c4e95c67ed9b48ab58c.tar.gz
[dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes. These are the files that had merge conflicts and have been edited by hand: malloc.go mem_linux.go mgc.go os1_linux.go proc1.go panic1.go runtime1.go LGTM=austin R=austin CC=golang-codereviews https://codereview.appspot.com/174180043
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/build.c155
-rw-r--r--src/cmd/dist/buildruntime.c306
2 files changed, 46 insertions, 415 deletions
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index 8fd2e998a..e4f307bee 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -526,10 +526,6 @@ static struct {
"anames8.c",
"anames9.c",
}},
- {"cmd/cc", {
- "-pgen.c",
- "-pswt.c",
- }},
{"cmd/gc", {
"-cplx.c",
"-pgen.c",
@@ -538,26 +534,6 @@ static struct {
"-y1.tab.c", // makefile dreg
"opnames.h",
}},
- {"cmd/5c", {
- "../cc/pgen.c",
- "../cc/pswt.c",
- "$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libcc.a",
- }},
- {"cmd/6c", {
- "../cc/pgen.c",
- "../cc/pswt.c",
- "$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libcc.a",
- }},
- {"cmd/8c", {
- "../cc/pgen.c",
- "../cc/pswt.c",
- "$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libcc.a",
- }},
- {"cmd/9c", {
- "../cc/pgen.c",
- "../cc/pswt.c",
- "$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libcc.a",
- }},
{"cmd/5g", {
"../gc/cplx.c",
"../gc/pgen.c",
@@ -611,12 +587,10 @@ static struct {
"$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/lib9.a",
}},
{"runtime", {
- "zaexperiment.h", // must sort above zasm
- "zasm_$GOOS_$GOARCH.h",
+ "zaexperiment.h",
"zsys_$GOOS_$GOARCH.s",
"zgoarch_$GOARCH.go",
"zgoos_$GOOS.go",
- "zruntime_defs_$GOOS_$GOARCH.go",
"zversion.go",
}},
};
@@ -639,12 +613,10 @@ static struct {
{"anames6.c", mkanames},
{"anames8.c", mkanames},
{"anames9.c", mkanames},
- {"zasm_", mkzasm},
{"zdefaultcc.go", mkzdefaultcc},
{"zsys_", mkzsys},
{"zgoarch_", mkzgoarch},
{"zgoos_", mkzgoos},
- {"zruntime_defs_", mkzruntimedefs},
{"zversion.go", mkzversion},
{"zaexperiment.h", mkzexperiment},
@@ -659,7 +631,7 @@ install(char *dir)
{
char *name, *p, *elem, *prefix, *exe;
bool islib, ispkg, isgo, stale, ispackcmd;
- Buf b, b1, path, final_path, final_name;
+ Buf b, b1, path, final_path, final_name, archive;
Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t;
int i, j, k, n, doclean, targ;
@@ -676,6 +648,7 @@ install(char *dir)
binit(&path);
binit(&final_path);
binit(&final_name);
+ binit(&archive);
vinit(&compile);
vinit(&files);
vinit(&link);
@@ -691,13 +664,6 @@ install(char *dir)
bpathf(&final_path, "%s/src/%s", goroot_final, dir);
name = lastelem(dir);
- // For misc/prof, copy into the tool directory and we're done.
- if(hasprefix(dir, "misc/")) {
- copyfile(bpathf(&b, "%s/%s", tooldir, name),
- bpathf(&b1, "%s/misc/%s", goroot, name), 1);
- goto out;
- }
-
// set up gcc command line on first run.
if(gccargs.len == 0) {
bprintf(&b, "%s %s", defaultcc, defaultcflags);
@@ -726,7 +692,7 @@ install(char *dir)
splitfields(&ldargs, bstr(&b));
}
- islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
+ islib = hasprefix(dir, "lib") || streq(dir, "cmd/gc");
ispkg = !islib && !hasprefix(dir, "cmd/");
isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo");
@@ -905,17 +871,6 @@ install(char *dir)
// For package runtime, copy some files into the work space.
if(streq(dir, "runtime")) {
- copyfile(bpathf(&b, "%s/arch_GOARCH.h", workdir),
- bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0);
- copyfile(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
- bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch), 0);
- p = bpathf(&b1, "%s/signal_%s_%s.h", bstr(&path), goos, goarch);
- if(isfile(p))
- copyfile(bpathf(&b, "%s/signal_GOOS_GOARCH.h", workdir), p, 0);
- copyfile(bpathf(&b, "%s/os_GOOS.h", workdir),
- bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0);
- copyfile(bpathf(&b, "%s/signals_GOOS.h", workdir),
- bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0);
copyfile(bpathf(&b, "%s/pkg/%s_%s/textflag.h", goroot, goos, goarch),
bpathf(&b1, "%s/src/cmd/ld/textflag.h", goroot), 0);
copyfile(bpathf(&b, "%s/pkg/%s_%s/funcdata.h", goroot, goos, goarch),
@@ -949,14 +904,6 @@ install(char *dir)
built:;
}
- // One more copy for package runtime.
- // The last batch was required for the generators.
- // This one is generated.
- if(streq(dir, "runtime")) {
- copyfile(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
- bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch), 0);
- }
-
if((!streq(goos, gohostos) || !streq(goarch, gohostarch)) && isgo) {
// We've generated the right files; the go command can do the build.
if(vflag > 1)
@@ -964,6 +911,42 @@ install(char *dir)
goto nobuild;
}
+ if(isgo) {
+ // The next loop will compile individual non-Go files.
+ // Hand the Go files to the compiler en masse.
+ // For package runtime, this writes go_asm.h, which
+ // the assembly files will need.
+ vreset(&compile);
+ vadd(&compile, bpathf(&b, "%s/%sg", tooldir, gochar));
+
+ bpathf(&b, "%s/_go_.a", workdir);
+ vadd(&compile, "-pack");
+ vadd(&compile, "-o");
+ vadd(&compile, bstr(&b));
+ vadd(&clean, bstr(&b));
+ if(!ispackcmd)
+ vadd(&link, bstr(&b));
+ else
+ bwriteb(&archive, &b);
+
+ vadd(&compile, "-p");
+ if(hasprefix(dir, "cmd/"))
+ vadd(&compile, "main");
+ else
+ vadd(&compile, dir);
+
+ if(streq(dir, "runtime")) {
+ vadd(&compile, "-+");
+ vadd(&compile, "-asmhdr");
+ bpathf(&b1, "%s/go_asm.h", workdir);
+ vadd(&compile, bstr(&b1));
+ }
+
+ vcopy(&compile, go.p, go.len);
+
+ runv(nil, bstr(&path), CheckExit, &compile);
+ }
+
// Compile the files.
for(i=0; i<files.len; i++) {
if(!hassuffix(files.p[i], ".c") && !hassuffix(files.p[i], ".s"))
@@ -1077,38 +1060,10 @@ install(char *dir)
}
bgwait();
- if(isgo) {
- // The last loop was compiling individual files.
- // Hand the Go files to the compiler en masse.
- vreset(&compile);
- vadd(&compile, bpathf(&b, "%s/%sg", tooldir, gochar));
-
- bpathf(&b, "%s/_go_.a", workdir);
- vadd(&compile, "-pack");
- vadd(&compile, "-o");
- vadd(&compile, bstr(&b));
- vadd(&clean, bstr(&b));
- if(!ispackcmd)
- vadd(&link, bstr(&b));
-
- vadd(&compile, "-p");
- if(hasprefix(dir, "pkg/"))
- vadd(&compile, dir+4);
- else
- vadd(&compile, "main");
-
- if(streq(dir, "runtime"))
- vadd(&compile, "-+");
-
- vcopy(&compile, go.p, go.len);
-
- runv(nil, bstr(&path), CheckExit, &compile);
-
- if(ispackcmd) {
- xremove(link.p[targ]);
- dopack(link.p[targ], bstr(&b), &link.p[targ+1], link.len - (targ+1));
- goto nobuild;
- }
+ if(isgo && ispackcmd) {
+ xremove(link.p[targ]);
+ dopack(link.p[targ], bstr(&archive), &link.p[targ+1], link.len - (targ+1));
+ goto nobuild;
}
if(!islib && !isgo) {
@@ -1122,17 +1077,7 @@ install(char *dir)
xremove(link.p[targ]);
runv(nil, nil, CheckExit, &link);
-
nobuild:
- // In package runtime, we install runtime.h and cgocall.h too,
- // for use by cgo compilation.
- if(streq(dir, "runtime")) {
- copyfile(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/runtime/cgocall.h", goroot), 0);
- copyfile(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/runtime/runtime.h", goroot), 0);
- }
-
out:
for(i=0; i<clean.len; i++)
@@ -1141,6 +1086,7 @@ out:
bfree(&b);
bfree(&b1);
bfree(&path);
+ bfree(&archive);
vfree(&compile);
vfree(&files);
vfree(&link);
@@ -1328,13 +1274,9 @@ static char *buildorder[] = {
"libbio",
"liblink",
- "misc/pprof",
-
- "cmd/cc", // must be before c
"cmd/gc", // must be before g
- "cmd/%sl", // must be before a, c, g
+ "cmd/%sl", // must be before a, g
"cmd/%sa",
- "cmd/%sc",
"cmd/%sg",
// The dependency order here was copied from a buildscript
@@ -1391,22 +1333,17 @@ static char *buildorder[] = {
static char *cleantab[] = {
// Commands and C libraries.
"cmd/5a",
- "cmd/5c",
"cmd/5g",
"cmd/5l",
"cmd/6a",
- "cmd/6c",
"cmd/6g",
"cmd/6l",
"cmd/8a",
- "cmd/8c",
"cmd/8g",
"cmd/8l",
"cmd/9a",
- "cmd/9c",
"cmd/9g",
"cmd/9l",
- "cmd/cc",
"cmd/gc",
"cmd/go",
"lib9",
diff --git a/src/cmd/dist/buildruntime.c b/src/cmd/dist/buildruntime.c
index d22e09955..e561937fb 100644
--- a/src/cmd/dist/buildruntime.c
+++ b/src/cmd/dist/buildruntime.c
@@ -127,174 +127,8 @@ mkzgoos(char *dir, char *file)
bfree(&out);
}
-static struct {
- char *goarch;
- char *goos;
- char *hdr;
-} zasmhdr[] = {
- {"386", "",
- "#define get_tls(r) MOVL TLS, r\n"
- "#define g(r) 0(r)(TLS*1)\n"
- },
- {"amd64p32", "",
- "#define get_tls(r) MOVL TLS, r\n"
- "#define g(r) 0(r)(TLS*1)\n"
- },
- {"amd64", "",
- "#define get_tls(r) MOVQ TLS, r\n"
- "#define g(r) 0(r)(TLS*1)\n"
- },
-
- {"arm", "",
- "#define LR R14\n"
- },
-
- {"power64", "",
- "#define g R30\n"
- },
- {"power64le", "",
- "#define g R30\n"
- },
-};
-
#define MAXWINCB 2000 /* maximum number of windows callbacks allowed */
-// mkzasm writes zasm_$GOOS_$GOARCH.h,
-// which contains struct offsets for use by
-// assembly files. It also writes a copy to the work space
-// under the name zasm_GOOS_GOARCH.h (no expansion).
-//
-void
-mkzasm(char *dir, char *file)
-{
- int i, n;
- char *aggr, *p;
- Buf in, b, b1, out, exp;
- Vec argv, lines, fields;
-
- binit(&in);
- binit(&b);
- binit(&b1);
- binit(&out);
- binit(&exp);
- vinit(&argv);
- vinit(&lines);
- vinit(&fields);
-
- bwritestr(&out, "// auto generated by go tool dist\n\n");
- if(streq(goos, "linux")) {
- bwritestr(&out, "// +build !android\n\n");
- }
-
- for(i=0; i<nelem(zasmhdr); i++) {
- if(hasprefix(goarch, zasmhdr[i].goarch) && hasprefix(goos, zasmhdr[i].goos)) {
- bwritestr(&out, zasmhdr[i].hdr);
- goto ok;
- }
- }
- fatal("unknown $GOOS/$GOARCH in mkzasm");
-ok:
-
- copyfile(bpathf(&b, "%s/pkg/%s_%s/textflag.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/cmd/ld/textflag.h", goroot), 0);
-
- // Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -a -n -o workdir/proc.acid proc.c
- // to get acid [sic] output. Run once without the -a -o workdir/proc.acid in order to
- // report compilation failures (the -o redirects all messages, unfortunately).
- vreset(&argv);
- vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
- vadd(&argv, "-D");
- vadd(&argv, bprintf(&b, "GOOS_%s", goos));
- vadd(&argv, "-D");
- vadd(&argv, bprintf(&b, "GOARCH_%s", goarch));
- vadd(&argv, "-I");
- vadd(&argv, bprintf(&b, "%s", workdir));
- vadd(&argv, "-I");
- vadd(&argv, bprintf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
- vadd(&argv, "-n");
- vadd(&argv, "-a");
- vadd(&argv, "-o");
- vadd(&argv, bpathf(&b, "%s/proc.acid", workdir));
- vadd(&argv, "proc.c");
- runv(nil, dir, CheckExit, &argv);
- readfile(&in, bpathf(&b, "%s/proc.acid", workdir));
-
- // Convert input like
- // aggr G
- // {
- // Gobuf 24 sched;
- // 'Y' 48 stack0;
- // }
- // StackMin = 128;
- // into output like
- // #define g_sched 24
- // #define g_stack0 48
- // #define const_StackMin 128
- aggr = nil;
- splitlines(&lines, bstr(&in));
- for(i=0; i<lines.len; i++) {
- splitfields(&fields, lines.p[i]);
- if(fields.len == 2 && streq(fields.p[0], "aggr")) {
- if(streq(fields.p[1], "G"))
- aggr = "g";
- else if(streq(fields.p[1], "M"))
- aggr = "m";
- else if(streq(fields.p[1], "P"))
- aggr = "p";
- else if(streq(fields.p[1], "Gobuf"))
- aggr = "gobuf";
- else if(streq(fields.p[1], "LibCall"))
- aggr = "libcall";
- else if(streq(fields.p[1], "WinCallbackContext"))
- aggr = "cbctxt";
- else if(streq(fields.p[1], "SEH"))
- aggr = "seh";
- else if(streq(fields.p[1], "Alg"))
- aggr = "alg";
- else if(streq(fields.p[1], "Panic"))
- aggr = "panic";
- else if(streq(fields.p[1], "Stack"))
- aggr = "stack";
- }
- if(hasprefix(lines.p[i], "}"))
- aggr = nil;
- if(aggr && hasprefix(lines.p[i], "\t") && fields.len >= 2) {
- n = fields.len;
- p = fields.p[n-1];
- if(p[xstrlen(p)-1] == ';')
- p[xstrlen(p)-1] = '\0';
- bwritestr(&out, bprintf(&b, "#define %s_%s %s\n", aggr, fields.p[n-1], fields.p[n-2]));
- }
- if(fields.len == 3 && streq(fields.p[1], "=")) { // generated from enumerated constants
- p = fields.p[2];
- if(p[xstrlen(p)-1] == ';')
- p[xstrlen(p)-1] = '\0';
- bwritestr(&out, bprintf(&b, "#define const_%s %s\n", fields.p[0], p));
- }
- }
-
- // Some #defines that are used for .c files.
- if(streq(goos, "windows")) {
- bwritestr(&out, bprintf(&b, "#define cb_max %d\n", MAXWINCB));
- }
-
- xgetenv(&exp, "GOEXPERIMENT");
- bwritestr(&out, bprintf(&b, "#define GOEXPERIMENT \"%s\"\n", bstr(&exp)));
-
- // Write both to file and to workdir/zasm_GOOS_GOARCH.h.
- writefile(&out, file, 0);
- writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), 0);
-
- bfree(&in);
- bfree(&b);
- bfree(&b1);
- bfree(&out);
- bfree(&exp);
- vfree(&argv);
- vfree(&lines);
- vfree(&fields);
-}
-
// mkzsys writes zsys_$GOOS_$GOARCH.s,
// which contains arch or os specific asm code.
//
@@ -333,143 +167,3 @@ mkzsys(char *dir, char *file)
bfree(&out);
}
-
-static char *runtimedefs[] = {
- "defs.c",
- "malloc.c",
- "mcache.c",
- "mgc0.c",
- "proc.c",
- "parfor.c",
- "stack.c",
-};
-
-// mkzruntimedefs writes zruntime_defs_$GOOS_$GOARCH.h,
-// which contains Go struct definitions equivalent to the C ones.
-// Mostly we just write the output of 6c -q to the file.
-// However, we run it on multiple files, so we have to delete
-// the duplicated definitions, and we don't care about the funcs,
-// so we delete those too.
-//
-void
-mkzruntimedefs(char *dir, char *file)
-{
- int i, skip;
- char *p;
- Buf in, b, b1, out;
- Vec argv, lines, fields, seen;
-
- binit(&in);
- binit(&b);
- binit(&b1);
- binit(&out);
- vinit(&argv);
- vinit(&lines);
- vinit(&fields);
- vinit(&seen);
-
- bwritestr(&out, "// auto generated by go tool dist\n"
- "\n");
-
- if(streq(goos, "linux")) {
- bwritestr(&out, "// +build !android\n\n");
- }
-
- bwritestr(&out,
- "package runtime\n"
- "import \"unsafe\"\n"
- "var _ unsafe.Pointer\n"
- "\n"
- );
-
- // Do not emit definitions for these.
- vadd(&seen, "true");
- vadd(&seen, "false");
- vadd(&seen, "raceenabled");
- vadd(&seen, "allgs");
-
- // Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -q -n -o workdir/runtimedefs
- // on each of the runtimedefs C files.
- vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
- vadd(&argv, "-D");
- vadd(&argv, bprintf(&b, "GOOS_%s", goos));
- vadd(&argv, "-D");
- vadd(&argv, bprintf(&b, "GOARCH_%s", goarch));
- vadd(&argv, "-I");
- vadd(&argv, bprintf(&b, "%s", workdir));
- vadd(&argv, "-I");
- vadd(&argv, bprintf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
- vadd(&argv, "-q");
- vadd(&argv, "-n");
- vadd(&argv, "-o");
- vadd(&argv, bpathf(&b, "%s/runtimedefs", workdir));
- vadd(&argv, "");
- p = argv.p[argv.len-1];
- for(i=0; i<nelem(runtimedefs); i++) {
- argv.p[argv.len-1] = runtimedefs[i];
- runv(nil, dir, CheckExit, &argv);
- readfile(&b, bpathf(&b1, "%s/runtimedefs", workdir));
- bwriteb(&in, &b);
- }
- argv.p[argv.len-1] = p;
-
- // Process the aggregate output.
- skip = 0;
- splitlines(&lines, bstr(&in));
- for(i=0; i<lines.len; i++) {
- p = lines.p[i];
- // Drop comment and func lines.
- if(hasprefix(p, "//") || hasprefix(p, "func"))
- continue;
-
- // Note beginning of type or var decl, which can be multiline.
- // Remove duplicates. The linear check of seen here makes the
- // whole processing quadratic in aggregate, but there are only
- // about 100 declarations, so this is okay (and simple).
- if(hasprefix(p, "type ") || hasprefix(p, "var ") || hasprefix(p, "const ")) {
- splitfields(&fields, p);
- if(fields.len < 2)
- continue;
- if(find(fields.p[1], seen.p, seen.len) >= 0) {
- if(streq(fields.p[fields.len-1], "{"))
- skip = 1; // skip until }
- continue;
- }
- vadd(&seen, fields.p[1]);
- }
-
- // Const lines are printed in original case (usually upper). Add a leading _ as needed.
- if(hasprefix(p, "const ")) {
- if('A' <= p[6] && p[6] <= 'Z')
- bwritestr(&out, "const _");
- else
- bwritestr(&out, "const ");
- bwritestr(&out, p+6);
- continue;
- }
-
- if(skip) {
- if(hasprefix(p, "}"))
- skip = 0;
- continue;
- }
-
- bwritestr(&out, p);
- }
-
- // Some windows specific const.
- if(streq(goos, "windows")) {
- bwritestr(&out, bprintf(&b, "const cb_max = %d\n", MAXWINCB));
- }
-
- writefile(&out, file, 0);
-
- bfree(&in);
- bfree(&b);
- bfree(&b1);
- bfree(&out);
- vfree(&argv);
- vfree(&lines);
- vfree(&fields);
- vfree(&seen);
-}