Skip to content

Commit 7ae6872

Browse files
bytboxrsc
authored andcommitted
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
1 parent 83b5f06 commit 7ae6872

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/cmd/dist/build.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ install(char *dir)
539539
Buf b, b1, path;
540540
Vec compile, files, link, go, missing, clean, lib, extra;
541541
Time ttarg, t;
542-
int i, j, k, n, doclean;
542+
int i, j, k, n, doclean, targ;
543543

544544
if(vflag) {
545545
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
@@ -601,14 +601,15 @@ install(char *dir)
601601
exe = ".exe";
602602

603603
// Start final link command line.
604-
// Note: code below knows that link.p[2] is the target.
604+
// Note: code below knows that link.p[targ] is the target.
605605
if(islib) {
606606
// C library.
607607
vadd(&link, "ar");
608608
vadd(&link, "rsc");
609609
prefix = "";
610610
if(!hasprefix(name, "lib"))
611611
prefix = "lib";
612+
targ = link.len;
612613
vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohostos, gohostarch, prefix, name));
613614
} else if(ispkg) {
614615
// Go library (package).
@@ -617,6 +618,7 @@ install(char *dir)
617618
p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
618619
*xstrrchr(p, '/') = '\0';
619620
xmkdirall(p);
621+
targ = link.len;
620622
vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4));
621623
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
622624
// Go command.
@@ -625,21 +627,20 @@ install(char *dir)
625627
elem = name;
626628
if(streq(elem, "go"))
627629
elem = "go_bootstrap";
630+
targ = link.len;
628631
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, elem, exe));
629632
} else {
630-
// C command.
631-
// Use gccargs, but ensure that link.p[2] is output file,
632-
// as noted above.
633-
vadd(&link, gccargs.p[0]);
633+
// C command. Use gccargs.
634+
vcopy(&link, gccargs.p, gccargs.len);
634635
vadd(&link, "-o");
636+
targ = link.len;
635637
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe));
636-
vcopy(&link, gccargs.p+1, gccargs.len-1);
637638
if(streq(gohostarch, "amd64"))
638639
vadd(&link, "-m64");
639640
else if(streq(gohostarch, "386"))
640641
vadd(&link, "-m32");
641642
}
642-
ttarg = mtime(link.p[2]);
643+
ttarg = mtime(link.p[targ]);
643644

644645
// Gather files that are sources for this target.
645646
// Everything in that directory, and any target-specific
@@ -926,7 +927,7 @@ install(char *dir)
926927
}
927928

928929
// Remove target before writing it.
929-
xremove(link.p[2]);
930+
xremove(link.p[targ]);
930931

931932
runv(nil, nil, CheckExit, &link);
932933

0 commit comments

Comments
 (0)