tooldir string
oldgoos string
oldgoarch string
+ oldgocache string
exe string
defaultcc map[string]string
defaultcxx map[string]string
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))
-
// Set GOBIN to GOROOT/bin. The meaning of GOBIN has drifted over time
// (see https://go.dev/issue/3269, https://go.dev/cl/183058,
// https://go.dev/issue/31576). Since we want binaries installed by 'dist' to
xprintf(format, "GO111MODULE", "")
xprintf(format, "GOARCH", goarch)
xprintf(format, "GOBIN", gorootBin)
- xprintf(format, "GOCACHE", os.Getenv("GOCACHE"))
xprintf(format, "GODEBUG", os.Getenv("GODEBUG"))
xprintf(format, "GOENV", "off")
xprintf(format, "GOFLAGS", "")
// go tool may complain.
os.Setenv("GOPATH", pathf("%s/pkg/obj/gopath", goroot))
+ // 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.
+ oldgocache = os.Getenv("GOCACHE")
+ os.Setenv("GOCACHE", pathf("%s/pkg/obj/go-build", goroot))
+
// Disable GOEXPERIMENT when building toolchain1 and
// go_bootstrap. We don't need any experiments for the
// bootstrap toolchain, and this lets us avoid duplicating the
copyfile(pathf("%s/compile3", tooldir), pathf("%s/compile", tooldir), writeExec)
}
+ // Now that toolchain3 has been built from scratch, its compiler and linker
+ // should have accurate build IDs suitable for caching.
+ // Now prime the build cache with the rest of the standard library for
+ // testing, and so that the user can run 'go install std cmd' to quickly
+ // iterate on local changes without waiting for a full rebuild.
+ os.Setenv("GOCACHE", oldgocache)
+
if goos == oldgoos && goarch == oldgoarch {
// Common case - not setting up for cross-compilation.
timelog("build", "toolchain")
pkg: "fmt",
}).command(t)
unsetEnv(cmd, "GOROOT")
- unsetEnv(cmd, "GOCACHE") // TODO(bcmills): ...why‽
err := cmd.Run()
if rerr := os.Rename(moved, goroot); rerr != nil {
}
}
- gocache := os.Getenv("GOCACHE")
- if gocache == "" {
- panic("GOCACHE not set")
- }
- gocacheSubdir, _ := filepath.Rel(dir, gocache)
-
filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if suffix := strings.TrimPrefix(path, dir+string(filepath.Separator)); suffix != "" {
- if suffix == gocacheSubdir {
- // Leave GOCACHE writable: we may need to write test binaries into it.
- return filepath.SkipDir
- }
if suffix == ".git" {
// Leave Git metadata in whatever state it was in. It may contain a lot
// of files, and it is highly unlikely that a test will try to modify