diff options
Diffstat (limited to 'src/cmd/dist/build.c')
-rw-r--r-- | src/cmd/dist/build.c | 146 |
1 files changed, 46 insertions, 100 deletions
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index 9c81dd8b2..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); @@ -719,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"); @@ -898,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), @@ -942,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) @@ -957,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")) @@ -1070,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) { @@ -1115,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++) @@ -1134,6 +1086,7 @@ out: bfree(&b); bfree(&b1); bfree(&path); + bfree(&archive); vfree(&compile); vfree(&files); vfree(&link); @@ -1321,11 +1274,9 @@ static char *buildorder[] = { "libbio", "liblink", - "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 @@ -1382,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", |