fail early if we know we lack Go linker patches

Right now, we only have linker patches for Go 1.22.x.
We only ever maintain those for one or two major Go versions at a time.

If a user tries to use the Go toolchain from 1.21, we already fail
with "Go version too old" messages early on, but we don't for 1.23,
causing a relatively confusing error later on when we link a binary:

    cannot get modified linker: cannot retrieve linker patches: open patches/go1.23: file does not exist

Instead, fail early and with a good error message.
This commit is contained in:
Daniel Martí
2024-02-18 09:51:43 +00:00
committed by pagran
parent d138afaf32
commit 9a2ef369b2
2 changed files with 11 additions and 4 deletions
+3 -3
View File
@@ -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'