summaryrefslogtreecommitdiff
path: root/src/cmd/gc/obj.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-03-05 16:13:33 -0500
committerRuss Cox <rsc@golang.org>2012-03-05 16:13:33 -0500
commit4fafaea617c9093703f37878f9fa3f0078c1f3bc (patch)
treeccf0524141d6b0d28696a216bbc63ea92d60a3be /src/cmd/gc/obj.c
parent530527990a50414ac9638f6b7cefc8d54916c03c (diff)
downloadgo-4fafaea617c9093703f37878f9fa3f0078c1f3bc.tar.gz
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 issue 3180. R=ken, ken CC=golang-dev http://codereview.appspot.com/5742043
Diffstat (limited to 'src/cmd/gc/obj.c')
-rw-r--r--src/cmd/gc/obj.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/cmd/gc/obj.c b/src/cmd/gc/obj.c
index aae566dbb..e45b4e0d4 100644
--- a/src/cmd/gc/obj.c
+++ b/src/cmd/gc/obj.c
@@ -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;
+ }
}
}