From 10643b744d91544fd61d5131b52c89e1c3caabeb Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 3 Feb 2023 09:59:16 -0500 Subject: [PATCH] cmd/dist: do not include runtime/internal/sys in cmd staleness checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since CL 454836, cmd/dist has built the packages in 'cmd' with different settings than those in 'std': namely, for' cmd' we disable the use of cgo, and (since CL 463740) if GO_BUILDER_NAME is non-empty or the VERSION file indicates a release version we also set GOFLAGS=-trimpath. However, since at least CL 73212 the staleness checks performed by cmd/dist for the “toolchain” targets (a subset of 'cmd') have included the package "runtime/internal/sys" (which is in 'std', not 'cmd'). At that time, cmd/go did not have a separate build cache, so it would not have been possible to check staleness for a 'cmd' build differently from 'std'. However, now that is possible, and most of the time "runtime/internal/sys" lives *only* in the build cache (and so is essentially never stale after building anything that imports it). But there is one more wrinkle: if GODEBUG=installgoroot=all is set, the packages in 'std' are still installed to GOROOT/pkg, and can once again become stale. Since the install with the 'std' configuration does not match the configuration used to build 'cmd', the staleness check fails for "runtime/internal/sys" under the 'cmd' configuration. Since we intentionally build the toolchain with a different "runtime/internal/sys" stored only in the build cache, there is no longer a point in checking that package for staleness: if it is stale, then the toolchain itself will be reported as stale anyway. So we can simply remove the package from that staleness check, and unbreak bootstrapping with GODEBUG=installgoroot=all. I tested this manually using the sequence: export GODEBUG=installgoroot=all export GO_BUILDER_NAME=linux-amd64-bcmills ./make.bash It fails the staleness check before this change, and successfully builds after. For #24904. Change-Id: I376e93e35129694a093c6675e20905a097a8b64b Reviewed-on: https://go-review.googlesource.com/c/go/+/465155 Reviewed-by: Russ Cox Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills --- src/cmd/dist/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index d388058d9e..444d293433 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -1513,14 +1513,14 @@ func cmdbootstrap() { } goInstall(nil, goBootstrap, "std") goInstall(toolenv(), goBootstrap, "cmd") - checkNotStale(toolenv(), goBootstrap, append(toolchain, "runtime/internal/sys")...) + checkNotStale(toolenv(), goBootstrap, toolchain...) checkNotStale(nil, goBootstrap, "std") checkNotStale(toolenv(), goBootstrap, "cmd") checkNotStale(nil, gorootBinGo, "std") checkNotStale(toolenv(), gorootBinGo, "cmd") if debug { run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full") - checkNotStale(toolenv(), goBootstrap, append(toolchain, "runtime/internal/sys")...) + checkNotStale(toolenv(), goBootstrap, toolchain...) copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec) } -- 2.48.1