mirror of
https://github.com/golang/go
synced 2024-11-22 04:44:39 -07:00
cmd/gc: if $GOROOT_FINAL is set, rewrite file names in object files
GOROOT_FINAL is a build parameter that means "eventually the Go tree will be installed here". Make the file name information match that eventual location. Fixes #3180. R=ken, ken CC=golang-dev https://golang.org/cl/5742043
This commit is contained in:
parent
c0a842e57f
commit
6e3a7930eb
3
src/cmd/dist/build.c
vendored
3
src/cmd/dist/build.c
vendored
@ -1351,6 +1351,9 @@ cmdbootstrap(int argc, char **argv)
|
||||
goversion = findgoversion();
|
||||
setup();
|
||||
|
||||
xsetenv("GOROOT", goroot);
|
||||
xsetenv("GOROOT_FINAL", goroot_final);
|
||||
|
||||
// For the main bootstrap, building for host os/arch.
|
||||
oldgoos = goos;
|
||||
oldgoarch = goarch;
|
||||
|
@ -126,10 +126,37 @@ outhist(Biobuf *b)
|
||||
{
|
||||
Hist *h;
|
||||
char *p, ds[] = {'c', ':', '/', 0};
|
||||
char *tofree;
|
||||
int n;
|
||||
static int first = 1;
|
||||
static char *goroot, *goroot_final;
|
||||
|
||||
if(first) {
|
||||
// Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL.
|
||||
first = 0;
|
||||
goroot = getenv("GOROOT");
|
||||
goroot_final = getenv("GOROOT_FINAL");
|
||||
if(goroot == nil)
|
||||
goroot = "";
|
||||
if(goroot_final == nil)
|
||||
goroot_final = goroot;
|
||||
if(strcmp(goroot, goroot_final) == 0) {
|
||||
goroot = nil;
|
||||
goroot_final = nil;
|
||||
}
|
||||
}
|
||||
|
||||
tofree = nil;
|
||||
for(h = hist; h != H; h = h->link) {
|
||||
p = h->name;
|
||||
if(p) {
|
||||
if(goroot != nil) {
|
||||
n = strlen(goroot);
|
||||
if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') {
|
||||
tofree = smprint("%s%s", goroot_final, p+n);
|
||||
p = tofree;
|
||||
}
|
||||
}
|
||||
if(windows) {
|
||||
// if windows variable is set, then, we know already,
|
||||
// pathname is started with windows drive specifier
|
||||
@ -161,9 +188,12 @@ outhist(Biobuf *b)
|
||||
outzfile(b, p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
zhist(b, h->line, h->offset);
|
||||
if(tofree) {
|
||||
free(tofree);
|
||||
tofree = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user