diff --git a/main.go b/main.go index cd75b1e..a30914b 100644 --- a/main.go +++ b/main.go @@ -268,7 +268,10 @@ type errJustExit int func (e errJustExit) Error() string { return fmt.Sprintf("exit: %d", e) } func goVersionOK() bool { - const minGoVersion = "go1.22" + const ( + minGoVersion = "go1.22" // the first major version we support + maxGoVersion = "go1.23" // the first major version we don't support + ) // rxVersion looks for a version like "go1.2" or "go1.2.3" in `go env GOVERSION`. rxVersion := regexp.MustCompile(`go\d+\.\d+(?:\.\d+)?`) @@ -285,6 +288,10 @@ func goVersionOK() bool { fmt.Fprintf(os.Stderr, "Go version %q is too old; please upgrade to %s or newer\n", toolchainVersionFull, minGoVersion) return false } + if version.Compare(sharedCache.GoVersion, maxGoVersion) >= 0 { + fmt.Fprintf(os.Stderr, "Go version %q is too new; Go linker patches aren't available for %s or later yet\n", toolchainVersionFull, maxGoVersion) + return false + } // Ensure that the version of Go that built the garble binary is equal or // newer than cache.GoVersionSemver. diff --git a/testdata/script/goversion.txtar b/testdata/script/goversion.txtar index 9ef85cc..fb07ae2 100644 --- a/testdata/script/goversion.txtar +++ b/testdata/script/goversion.txtar @@ -32,15 +32,15 @@ env TOOLCHAIN_GOVERSION='go1.14' ! exec garble build stderr 'Go version "go1\.14" is too old; please upgrade to go1\.22 or newer' -# We should accept a future stable version. +# We should reject a future stable version, as we don't have linker patches yet. # Note that we need to bump the version of Go that supposedly built it, too. env GARBLE_TEST_GOVERSION='go1.28.2' env TOOLCHAIN_GOVERSION='go1.28.2' ! exec garble build -stderr 'mocking the real build' +stderr 'Go version "go1\.28\.2" is too new; Go linker patches aren''t available for go1\.23 or later yet' # We should accept custom devel strings. -env TOOLCHAIN_GOVERSION='devel go1.23-somecustomversion' +env TOOLCHAIN_GOVERSION='devel go1.22-somecustomversion' ! exec garble build stderr 'mocking the real build'