From b66a294813bb70fdc52d0e55e32048be3f3a176a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 1 Nov 2017 19:22:56 -0400 Subject: [PATCH] cmd/dist: set GOCACHE during make.bash/run.bash Use a build cache separate from the default user cache, one that will be wiped out during startup, so that make.bash continues to start from a clean slate. Change-Id: I38733991015c66efb89fc170c71701b1dd9de28d Reviewed-on: https://go-review.googlesource.com/75291 Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot Reviewed-by: David Crawshaw --- src/cmd/dist/build.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index f0679be54c..04168d691c 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -226,6 +226,11 @@ func xinit() { os.Setenv("GOROOT", goroot) os.Setenv("GOROOT_FINAL", goroot_final) + // Use a build cache separate from the default user one. + // Also one that will be wiped out during startup, so that + // make.bash really does start from a clean slate. + os.Setenv("GOCACHE", pathf("%s/pkg/obj/go-build", goroot)) + // Make the environment more predictable. os.Setenv("LANG", "C") os.Setenv("LANGUAGE", "en_US.UTF8") @@ -428,14 +433,10 @@ func setup() { } // Create object directory. - // We keep it in pkg/ so that all the generated binaries - // are in one tree. If pkg/obj/libgc.a exists, it is a dreg from - // before we used subdirectories of obj. Delete all of obj - // to clean up. - if p := pathf("%s/pkg/obj/libgc.a", goroot); isfile(p) { - xremoveall(pathf("%s/pkg/obj", goroot)) - } - p = pathf("%s/pkg/obj/%s_%s", goroot, gohostos, gohostarch) + // We used to use it for C objects. + // Now we use it for the build cache, to separate dist's cache + // from any other cache the user might have. + p = pathf("%s/pkg/obj/go-build", goroot) if rebuildall { xremoveall(p) } -- 2.48.1