Skip to content

Commit d75a867

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
cmd/dist: skip rebuilding packages during builder testing
Since packages in "std" no longer have install targets, checking them for staleness is somewhat meaningless: if they are not cached they will be rebuilt anyway, and without installed archives against which we can compare them the staleness check will not detect builder skew. It would still be meaningful to check "cmd" for staleness, but (especially on sharded VM-based builders) that is a fairly expensive operation relative to its benefit. If we are really interested in detecting builder skew and/or build reproducibility, we could instead add a "misc" test (similar to "misc/reboot", or perhaps even a part of that test) that verifies that bootstrapped binaries are reproducible. For #57734. Updates #47257. Updates #56896. Change-Id: I8683ee81aefe8fb59cce9484453df9729bdc587c Reviewed-on: https://go-review.googlesource.com/c/go/+/452775 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Austin Clements <austin@google.com>
1 parent dbfdc44 commit d75a867

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

src/cmd/dist/test.go

+10-32
Original file line numberDiff line numberDiff line change
@@ -154,41 +154,21 @@ func (t *tester) run() {
154154

155155
if !t.listMode {
156156
if builder := os.Getenv("GO_BUILDER_NAME"); builder == "" {
157-
// Complete rebuild bootstrap, even with -no-rebuild.
157+
// Ensure that installed commands are up to date, even with -no-rebuild,
158+
// so that tests that run commands end up testing what's actually on disk.
158159
// If everything is up-to-date, this is a no-op.
159-
// If everything is not up-to-date, the first checkNotStale
160-
// during the test process will kill the tests, so we might
161-
// as well install the world.
162-
// Now that for example "go install cmd/compile" does not
163-
// also install runtime (you need "go install -i cmd/compile"
164-
// for that), it's easy for previous workflows like
165-
// "rebuild the compiler and then run run.bash"
166-
// to break if we don't automatically refresh things here.
167-
// Rebuilding is a shortened bootstrap.
160+
// We first build the toolchain twice to allow it to converge,
161+
// as when we first bootstrap.
168162
// See cmdbootstrap for a description of the overall process.
163+
//
164+
// On the builders, we skip this step: we assume that 'dist test' is
165+
// already using the result of a clean build, and because of test sharding
166+
// and virtualization we usually start with a clean GOCACHE, so we would
167+
// end up rebuilding large parts of the standard library that aren't
168+
// otherwise relevant to the actual set of packages under test.
169169
goInstall(toolenv, gorootBinGo, toolchain...)
170170
goInstall(toolenv, gorootBinGo, toolchain...)
171171
goInstall(toolenv, gorootBinGo, "cmd")
172-
goInstall(nil, gorootBinGo, "std")
173-
} else {
174-
// The Go builder infrastructure should always begin running tests from a
175-
// clean, non-stale state, so there is no need to rebuild the world.
176-
// Instead, we can just check that it is not stale, which may be less
177-
// expensive (and is also more likely to catch bugs in the builder
178-
// implementation).
179-
// The cache used by dist when building is different from that used when
180-
// running dist test, so rebuild (but don't install) std and cmd to make
181-
// sure packages without install targets are cached so they are not stale.
182-
goCmd(toolenv, gorootBinGo, "build", "cmd") // make sure dependencies of targets are cached
183-
goCmd(nil, gorootBinGo, "build", "std")
184-
checkNotStale(nil, gorootBinGo, "std")
185-
if builder != "aix-ppc64" {
186-
// The aix-ppc64 builder for some reason does not have deterministic cgo
187-
// builds, so "cmd" is stale. Fortunately, most of the tests don't care.
188-
// TODO(#56896): remove this special case once the builder supports
189-
// determistic cgo builds.
190-
checkNotStale(toolenv, gorootBinGo, "cmd")
191-
}
192172
}
193173
}
194174

@@ -1361,7 +1341,6 @@ func (t *tester) registerCgoTests() {
13611341
// running in parallel with earlier tests, or if it has some other reason
13621342
// for needing the earlier tests to be done.
13631343
func (t *tester) runPending(nextTest *distTest) {
1364-
checkNotStale(nil, gorootBinGo, "std")
13651344
worklist := t.worklist
13661345
t.worklist = nil
13671346
for _, w := range worklist {
@@ -1419,7 +1398,6 @@ func (t *tester) runPending(nextTest *distTest) {
14191398
log.Printf("Failed: %v", w.err)
14201399
t.failed = true
14211400
}
1422-
checkNotStale(nil, gorootBinGo, "std")
14231401
}
14241402
if t.failed && !t.keepGoing {
14251403
fatalf("FAILED")

0 commit comments

Comments
 (0)