Commit 7ae6872f authored by Scott Lawrence's avatar Scott Lawrence Committed by Russ Cox

dist: treat CC as one unit

Fixes #3112.

R=golang-dev, 0xe2.0x9a.0x9b, ality, rsc, rsc
CC=golang-dev
https://golang.org/cl/5700044
parent 83b5f067
...@@ -539,7 +539,7 @@ install(char *dir) ...@@ -539,7 +539,7 @@ install(char *dir)
Buf b, b1, path; Buf b, b1, path;
Vec compile, files, link, go, missing, clean, lib, extra; Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t; Time ttarg, t;
int i, j, k, n, doclean; int i, j, k, n, doclean, targ;
if(vflag) { if(vflag) {
if(!streq(goos, gohostos) || !streq(goarch, gohostarch)) if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
...@@ -601,7 +601,7 @@ install(char *dir) ...@@ -601,7 +601,7 @@ install(char *dir)
exe = ".exe"; exe = ".exe";
// Start final link command line. // Start final link command line.
// Note: code below knows that link.p[2] is the target. // Note: code below knows that link.p[targ] is the target.
if(islib) { if(islib) {
// C library. // C library.
vadd(&link, "ar"); vadd(&link, "ar");
...@@ -609,6 +609,7 @@ install(char *dir) ...@@ -609,6 +609,7 @@ install(char *dir)
prefix = ""; prefix = "";
if(!hasprefix(name, "lib")) if(!hasprefix(name, "lib"))
prefix = "lib"; prefix = "lib";
targ = link.len;
vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohostos, gohostarch, prefix, name)); vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohostos, gohostarch, prefix, name));
} else if(ispkg) { } else if(ispkg) {
// Go library (package). // Go library (package).
...@@ -617,6 +618,7 @@ install(char *dir) ...@@ -617,6 +618,7 @@ install(char *dir)
p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4); p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
*xstrrchr(p, '/') = '\0'; *xstrrchr(p, '/') = '\0';
xmkdirall(p); xmkdirall(p);
targ = link.len;
vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4)); vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4));
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) { } else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
// Go command. // Go command.
...@@ -625,21 +627,20 @@ install(char *dir) ...@@ -625,21 +627,20 @@ install(char *dir)
elem = name; elem = name;
if(streq(elem, "go")) if(streq(elem, "go"))
elem = "go_bootstrap"; elem = "go_bootstrap";
targ = link.len;
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, elem, exe)); vadd(&link, bpathf(&b, "%s/%s%s", tooldir, elem, exe));
} else { } else {
// C command. // C command. Use gccargs.
// Use gccargs, but ensure that link.p[2] is output file, vcopy(&link, gccargs.p, gccargs.len);
// as noted above.
vadd(&link, gccargs.p[0]);
vadd(&link, "-o"); vadd(&link, "-o");
targ = link.len;
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe)); vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe));
vcopy(&link, gccargs.p+1, gccargs.len-1);
if(streq(gohostarch, "amd64")) if(streq(gohostarch, "amd64"))
vadd(&link, "-m64"); vadd(&link, "-m64");
else if(streq(gohostarch, "386")) else if(streq(gohostarch, "386"))
vadd(&link, "-m32"); vadd(&link, "-m32");
} }
ttarg = mtime(link.p[2]); ttarg = mtime(link.p[targ]);
// Gather files that are sources for this target. // Gather files that are sources for this target.
// Everything in that directory, and any target-specific // Everything in that directory, and any target-specific
...@@ -926,7 +927,7 @@ install(char *dir) ...@@ -926,7 +927,7 @@ install(char *dir)
} }
// Remove target before writing it. // Remove target before writing it.
xremove(link.p[2]); xremove(link.p[targ]);
runv(nil, nil, CheckExit, &link); runv(nil, nil, CheckExit, &link);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment