summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-04-15 20:46:46 -0400
committerRuss Cox <rsc@golang.org>2014-04-15 20:46:46 -0400
commit5fee958207e7e22ca7676244afdcf8491ecf3aad (patch)
tree18ecb97b4edfa8ef090c2fec2ff0c3762f29a718 /include
parent4acf36e5adf9e76df65be826dd746ed3c02a1ffa (diff)
downloadgo-5fee958207e7e22ca7676244afdcf8491ecf3aad.tar.gz
build: remove tmp dir names from objects, support GOROOT_FINAL again
If we compile a generated file stored in a temporary directory - let's say /tmp/12345/work/x.c - then by default 6c stores the full path and then the pcln table in the final binary includes the full path. This makes repeated builds (using different temporary directories) produce different binaries, even if the inputs are the same. In the old 'go tool pack', the P flag specified a prefix to remove from all stored paths (if present), and cmd/go invoked 'go tool pack grcP $WORK' to remove references to the temporary work directory. We've changed the build to avoid pack as much as possible, under the theory that instead of making pack convert from .6 to .a, the tools should just write the .a directly and save a round of I/O. Instead of going back to invoking pack always, define a common flag -trimpath in the assemblers, C compilers, and Go compilers, implemented in liblink, and arrange for cmd/go to use the flag. Then the object files being written out have the shortened paths from the start. While we are here, reimplement pcln support for GOROOT_FINAL. A build in /tmp/go uses GOROOT=/tmp/go, but if GOROOT_FINAL=/usr/local/go is set, then a source file named /tmp/go/x.go is recorded instead as /usr/local/go/x.go. We use this so that we can prepare distributions to be installed in /usr/local/go without actually working in that directory. The conversion to liblink deleted all the old file name handling code, including the GOROOT_FINAL translation. Bring the GOROOT_FINAL translation back. Before this CL, using GOROOT_FINAL=/goroot make.bash: g% strings $(which go) | grep -c $TMPDIR 6 g% strings $(which go) | grep -c $GOROOT 793 g% After this CL: g% strings $(which go) | grep -c $TMPDIR 0 g% strings $(which go) | grep -c $GOROOT 0 g% (The references to $TMPDIR tend to be cgo-generated source files.) Adding the -trimpath flag to the assemblers required converting them to the new Go-semantics flag parser. The text in go1.3.html is copied and adjusted from go1.1.html, which is when we applied that conversion to the compilers and linkers. Fixes issue 6989. LGTM=iant R=r, iant CC=golang-codereviews https://codereview.appspot.com/88300045
Diffstat (limited to 'include')
-rw-r--r--include/link.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/link.h b/include/link.h
index 9a6fca2ab..200a503cc 100644
--- a/include/link.h
+++ b/include/link.h
@@ -360,6 +360,9 @@ struct Link
Biobuf* bso; // for -v flag
char* pathname;
int32 windows;
+ char* trimpath;
+ char* goroot;
+ char* goroot_final;
// hash table of all symbols
LSym* hash[LINKHASH];