Skip to content

Commit b09e2de

Browse files
committed
cmd/dist: force non-devel version for cross-build buildlets
If the compiler has a non-devel version it will report that version to the go command for use as the "compiler ID" instead of using the content ID of the binary. This in turn allows the go command to see the compiled-for-amd64 arm compiler and the compiled-for-arm arm compiler as having the same ID, so that packages cross-compiled from amd64 look up-to-date when copied to the arm system during the linux-arm buildlets and trybots. Change-Id: I76cbf129303941f8e31bdb100e263478159ddaa5 Reviewed-on: https://go-review.googlesource.com/74360 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent b97688d commit b09e2de

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/cmd/dist/build.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,26 @@ func findgoversion() string {
288288
// its content if available, which is empty at this point.
289289
// Only use the VERSION file if it is non-empty.
290290
if b != "" {
291+
// Some builders cross-compile the toolchain on linux-amd64
292+
// and then copy the toolchain to the target builder (say, linux-arm)
293+
// for use there. But on non-release (devel) branches, the compiler
294+
// used on linux-amd64 will be an amd64 binary, and the compiler
295+
// shipped to linux-arm will be an arm binary, so they will have different
296+
// content IDs (they are binaries for different architectures) and so the
297+
// packages compiled by the running-on-amd64 compiler will appear
298+
// stale relative to the running-on-arm compiler. Avoid this by setting
299+
// the version string to something that doesn't begin with devel.
300+
// Then the version string will be used in place of the content ID,
301+
// and the packages will look up-to-date.
302+
// TODO(rsc): Really the builders could be writing out a better VERSION file instead,
303+
// but it is easier to change cmd/dist than to try to make changes to
304+
// the builder while Brad is away.
305+
if strings.HasPrefix(b, "devel") {
306+
if hostType := os.Getenv("META_BUILDLET_HOST_TYPE"); strings.Contains(hostType, "-cross") {
307+
fmt.Fprintf(os.Stderr, "warning: changing VERSION from %q to %q\n", b, "builder "+hostType)
308+
b = "builder " + hostType
309+
}
310+
}
291311
return b
292312
}
293313
}

0 commit comments

Comments
 (0)