|
46 | 46 | tooldir string
|
47 | 47 | oldgoos string
|
48 | 48 | oldgoarch string
|
| 49 | + oldgocache string |
49 | 50 | exe string
|
50 | 51 | defaultcc map[string]string
|
51 | 52 | defaultcxx map[string]string
|
@@ -234,11 +235,6 @@ func xinit() {
|
234 | 235 | os.Setenv("GOROOT", goroot)
|
235 | 236 | os.Setenv("GOROOT_FINAL", goroot_final)
|
236 | 237 |
|
237 |
| - // Use a build cache separate from the default user one. |
238 |
| - // Also one that will be wiped out during startup, so that |
239 |
| - // make.bash really does start from a clean slate. |
240 |
| - os.Setenv("GOCACHE", pathf("%s/pkg/obj/go-build", goroot)) |
241 |
| - |
242 | 238 | // Set GOBIN to GOROOT/bin. The meaning of GOBIN has drifted over time
|
243 | 239 | // (see https://go.dev/issue/3269, https://go.dev/cl/183058,
|
244 | 240 | // https://go.dev/issue/31576). Since we want binaries installed by 'dist' to
|
@@ -1211,7 +1207,6 @@ func cmdenv() {
|
1211 | 1207 | xprintf(format, "GO111MODULE", "")
|
1212 | 1208 | xprintf(format, "GOARCH", goarch)
|
1213 | 1209 | xprintf(format, "GOBIN", gorootBin)
|
1214 |
| - xprintf(format, "GOCACHE", os.Getenv("GOCACHE")) |
1215 | 1210 | xprintf(format, "GODEBUG", os.Getenv("GODEBUG"))
|
1216 | 1211 | xprintf(format, "GOENV", "off")
|
1217 | 1212 | xprintf(format, "GOFLAGS", "")
|
@@ -1340,6 +1335,12 @@ func cmdbootstrap() {
|
1340 | 1335 | // go tool may complain.
|
1341 | 1336 | os.Setenv("GOPATH", pathf("%s/pkg/obj/gopath", goroot))
|
1342 | 1337 |
|
| 1338 | + // Use a build cache separate from the default user one. |
| 1339 | + // Also one that will be wiped out during startup, so that |
| 1340 | + // make.bash really does start from a clean slate. |
| 1341 | + oldgocache = os.Getenv("GOCACHE") |
| 1342 | + os.Setenv("GOCACHE", pathf("%s/pkg/obj/go-build", goroot)) |
| 1343 | + |
1343 | 1344 | // Disable GOEXPERIMENT when building toolchain1 and
|
1344 | 1345 | // go_bootstrap. We don't need any experiments for the
|
1345 | 1346 | // bootstrap toolchain, and this lets us avoid duplicating the
|
@@ -1467,6 +1468,13 @@ func cmdbootstrap() {
|
1467 | 1468 | copyfile(pathf("%s/compile3", tooldir), pathf("%s/compile", tooldir), writeExec)
|
1468 | 1469 | }
|
1469 | 1470 |
|
| 1471 | + // Now that toolchain3 has been built from scratch, its compiler and linker |
| 1472 | + // should have accurate build IDs suitable for caching. |
| 1473 | + // Now prime the build cache with the rest of the standard library for |
| 1474 | + // testing, and so that the user can run 'go install std cmd' to quickly |
| 1475 | + // iterate on local changes without waiting for a full rebuild. |
| 1476 | + os.Setenv("GOCACHE", oldgocache) |
| 1477 | + |
1470 | 1478 | if goos == oldgoos && goarch == oldgoarch {
|
1471 | 1479 | // Common case - not setting up for cross-compilation.
|
1472 | 1480 | timelog("build", "toolchain")
|
|
0 commit comments