@@ -539,7 +539,7 @@ install(char *dir)
539
539
Buf b , b1 , path ;
540
540
Vec compile , files , link , go , missing , clean , lib , extra ;
541
541
Time ttarg , t ;
542
- int i , j , k , n , doclean ;
542
+ int i , j , k , n , doclean , targ ;
543
543
544
544
if (vflag ) {
545
545
if (!streq (goos , gohostos ) || !streq (goarch , gohostarch ))
@@ -601,14 +601,15 @@ install(char *dir)
601
601
exe = ".exe" ;
602
602
603
603
// 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.
605
605
if (islib ) {
606
606
// C library.
607
607
vadd (& link , "ar" );
608
608
vadd (& link , "rsc" );
609
609
prefix = "" ;
610
610
if (!hasprefix (name , "lib" ))
611
611
prefix = "lib" ;
612
+ targ = link .len ;
612
613
vadd (& link , bpathf (& b , "%s/pkg/obj/%s_%s/%s%s.a" , goroot , gohostos , gohostarch , prefix , name ));
613
614
} else if (ispkg ) {
614
615
// Go library (package).
@@ -617,6 +618,7 @@ install(char *dir)
617
618
p = bprintf (& b , "%s/pkg/%s_%s/%s" , goroot , goos , goarch , dir + 4 );
618
619
* xstrrchr (p , '/' ) = '\0' ;
619
620
xmkdirall (p );
621
+ targ = link .len ;
620
622
vadd (& link , bpathf (& b , "%s/pkg/%s_%s/%s.a" , goroot , goos , goarch , dir + 4 ));
621
623
} else if (streq (dir , "cmd/go" ) || streq (dir , "cmd/cgo" )) {
622
624
// Go command.
@@ -625,21 +627,20 @@ install(char *dir)
625
627
elem = name ;
626
628
if (streq (elem , "go" ))
627
629
elem = "go_bootstrap" ;
630
+ targ = link .len ;
628
631
vadd (& link , bpathf (& b , "%s/%s%s" , tooldir , elem , exe ));
629
632
} 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 );
634
635
vadd (& link , "-o" );
636
+ targ = link .len ;
635
637
vadd (& link , bpathf (& b , "%s/%s%s" , tooldir , name , exe ));
636
- vcopy (& link , gccargs .p + 1 , gccargs .len - 1 );
637
638
if (streq (gohostarch , "amd64" ))
638
639
vadd (& link , "-m64" );
639
640
else if (streq (gohostarch , "386" ))
640
641
vadd (& link , "-m32" );
641
642
}
642
- ttarg = mtime (link .p [2 ]);
643
+ ttarg = mtime (link .p [targ ]);
643
644
644
645
// Gather files that are sources for this target.
645
646
// Everything in that directory, and any target-specific
@@ -926,7 +927,7 @@ install(char *dir)
926
927
}
927
928
928
929
// Remove target before writing it.
929
- xremove (link .p [2 ]);
930
+ xremove (link .p [targ ]);
930
931
931
932
runv (nil , nil , CheckExit , & link );
932
933
0 commit comments