1
0
mirror of https://github.com/golang/go synced 2024-11-22 21:50:03 -07:00

cmd/dist: use separate args for separate compiler flags

This makes dist safe for CL 7035043 (but keeps working now too).

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7029047
This commit is contained in:
Russ Cox 2013-01-02 17:52:54 -05:00
parent 5e8ca201d1
commit 5e46d540c8
2 changed files with 35 additions and 18 deletions

31
src/cmd/dist/build.c vendored
View File

@ -892,20 +892,27 @@ install(char *dir)
// lib9/goos.c gets the default constants hard-coded.
if(streq(name, "goos.c")) {
vadd(&compile, bprintf(&b, "-DGOOS=\"%s\"", goos));
vadd(&compile, bprintf(&b, "-DGOARCH=\"%s\"", goarch));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOOS=\"%s\"", goos));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOARCH=\"%s\"", goarch));
bprintf(&b1, "%s", goroot_final);
bsubst(&b1, "\\", "\\\\"); // turn into C string
vadd(&compile, bprintf(&b, "-DGOROOT=\"%s\"", bstr(&b1)));
vadd(&compile, bprintf(&b, "-DGOVERSION=\"%s\"", goversion));
vadd(&compile, bprintf(&b, "-DGOARM=\"%s\"", goarm));
vadd(&compile, bprintf(&b, "-DGO386=\"%s\"", go386));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOROOT=\"%s\"", bstr(&b1)));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOVERSION=\"%s\"", goversion));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOARM=\"%s\"", goarm));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GO386=\"%s\"", go386));
}
// gc/lex.c records the GOEXPERIMENT setting used during the build.
if(streq(name, "lex.c")) {
xgetenv(&b, "GOEXPERIMENT");
vadd(&compile, bprintf(&b1, "-DGOEXPERIMENT=\"%s\"", bstr(&b)));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b1, "GOEXPERIMENT=\"%s\"", bstr(&b)));
}
} else {
// Supporting files for a Go package.
@ -913,12 +920,16 @@ install(char *dir)
vadd(&compile, bpathf(&b, "%s/%sa", tooldir, gochar));
else {
vadd(&compile, bpathf(&b, "%s/%sc", tooldir, gochar));
vadd(&compile, "-FVw");
vadd(&compile, "-F");
vadd(&compile, "-V");
vadd(&compile, "-w");
}
vadd(&compile, "-I");
vadd(&compile, workdir);
vadd(&compile, bprintf(&b, "-DGOOS_%s", goos));
vadd(&compile, bprintf(&b, "-DGOARCH_%s", goarch));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOOS_%s", goos));
vadd(&compile, "-D");
vadd(&compile, bprintf(&b, "GOARCH_%s", goarch));
}
bpathf(&b, "%s/%s", workdir, lastelem(files.p[i]));

View File

@ -199,13 +199,16 @@ mkzasm(char *dir, char *file)
fatal("unknown $GOOS/$GOARCH in mkzasm");
ok:
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -a proc.c
// Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -a proc.c
// to get acid [sic] output.
vreset(&argv);
vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
vadd(&argv, bprintf(&b, "-I%s", workdir));
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, "-a");
vadd(&argv, "proc.c");
runv(&in, dir, CheckExit, &argv);
@ -299,12 +302,15 @@ mkzruntimedefs(char *dir, char *file)
);
// Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -q
// Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -q
// on each of the runtimedefs C files.
vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
vadd(&argv, bprintf(&b, "-I%s", workdir));
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, "-q");
vadd(&argv, "");
p = argv.p[argv.len-1];