mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 15:47:04 +08:00
7114403786
Beyond the usual updating of version strings, re-running `go generate`, and updating the patches for the linker, we needed extra changes. First, the linker started being stricter about which packages are allowed to linkname runtime names by import path. Stop obfuscating import paths in runtimeAndLinknamed. Second, the compiler's intrinsics code adds an "add" function much like the existing "addF", so tweak the regular expression. Third, note that there is a new runtimeAndDeps windows-only package, which we find thanks to the recent improvement to cover many platforms. Fourth, the code around magic numbers in the runtime has changed, so rewrite the code which patches it via go/ast. Fixes #990.
116 lines
3.7 KiB
Plaintext
116 lines
3.7 KiB
Plaintext
# We use a simple Go program to report many Go versions.
|
|
# The program also errors on any command other than "go version",
|
|
# which saves us having to rebuild main.go many times.
|
|
go build -o .bin/go$exe ./fakego
|
|
env PATH=${WORK}/.bin${:}${PATH}
|
|
|
|
# An empty go version.
|
|
env TOOLCHAIN_GOVERSION=''
|
|
! exec garble build
|
|
stderr 'Go version is too old; please upgrade to go1\.26\.0 or newer'
|
|
|
|
# A clearly invalid go version.
|
|
env TOOLCHAIN_GOVERSION='bogus version'
|
|
! exec garble build
|
|
stderr 'Go version "bogus" appears to be invalid or too old; use go1\.26\.0 or newer'
|
|
|
|
# We should error on a devel version that's too old;
|
|
# note that they started with the string "devel",
|
|
# and very old ones didn't even have "goN.M" in them.
|
|
env TOOLCHAIN_GOVERSION='devel +afb5fca Sun Aug 07 00:00:00 2020 +0000'
|
|
! exec garble build
|
|
stderr 'Go version .* appears to be invalid or too old'
|
|
env TOOLCHAIN_GOVERSION='devel go1.15-afb5fca Sun Aug 07 00:00:00 2020 +0000'
|
|
! exec garble build
|
|
stderr 'Go version .* appears to be invalid or too old'
|
|
|
|
# A current devel version should be fine.
|
|
# Note that we don't look at devel version timestamps.
|
|
env GARBLE_TEST_GOVERSION='go1.26.0'
|
|
|
|
# We should error on a stable version that's too old.
|
|
env TOOLCHAIN_GOVERSION='go1.14'
|
|
! exec garble build
|
|
stderr 'Go version "go1\.14" is too old; please upgrade to go1\.26\.0 or newer'
|
|
|
|
# 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.38.2'
|
|
env TOOLCHAIN_GOVERSION='go1.38.2'
|
|
! exec garble build
|
|
stderr 'Go version "go1\.38\.2" is too new; Go linker patches aren''t available for go1\.27 or later yet'
|
|
|
|
# We should accept custom devel strings.
|
|
env TOOLCHAIN_GOVERSION='go1.26.0-somecustomversion'
|
|
! exec garble build
|
|
stderr 'mocking the real build'
|
|
|
|
# A stable version with a build-time GOEXPERIMENT.
|
|
# See: https://github.com/golang/go/issues/75953
|
|
env TOOLCHAIN_GOVERSION='go1.26.0 X:nodwarf5'
|
|
! exec garble build
|
|
stderr 'mocking the real build'
|
|
|
|
# The current toolchain may be older than the one that built garble.
|
|
env GARBLE_TEST_GOVERSION='go1.26.1'
|
|
env TOOLCHAIN_GOVERSION='go1.26.0'
|
|
! exec garble build
|
|
stderr 'mocking the real build'
|
|
|
|
# The current toolchain may be equal to the one that built garble.
|
|
env GARBLE_TEST_GOVERSION='go1.26.0'
|
|
env TOOLCHAIN_GOVERSION='go1.26.0'
|
|
! exec garble build
|
|
stderr 'mocking the real build'
|
|
|
|
# The current toolchain must not be newer than the one that built garble.
|
|
env GARBLE_TEST_GOVERSION='go1.18'
|
|
env TOOLCHAIN_GOVERSION='go1.26.0'
|
|
! exec garble build
|
|
stderr 'garble was built with "go1\.18" and can''t be used with the newer "go1\.26\.0"; rebuild '
|
|
|
|
# We'll error even if the difference is a minor (bugfix) level.
|
|
# In practice it probably wouldn't matter, but in theory it could still lead to tricky bugs.
|
|
env GARBLE_TEST_GOVERSION='go1.26.11'
|
|
env TOOLCHAIN_GOVERSION='go1.26.14'
|
|
! exec garble build
|
|
stderr 'garble was built with "go1\.26\.11" and can''t be used with the newer "go1\.26\.14"; rebuild '
|
|
|
|
# If garble builds itself and is then used, it won't know what version built it.
|
|
# As a fallback, we drop the comparison against the toolchain's version.
|
|
env GARBLE_TEST_GOVERSION='bogus version'
|
|
env TOOLCHAIN_GOVERSION='go1.26.0'
|
|
! exec garble build
|
|
stderr 'mocking the real build'
|
|
-- go.mod --
|
|
module test/main
|
|
|
|
go 1.23
|
|
-- main.go --
|
|
package main
|
|
|
|
func main() {}
|
|
|
|
-- fakego/main.go --
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) > 0 && os.Args[1] == "env" {
|
|
enc, _ := json.Marshal(struct {
|
|
GOVERSION string
|
|
}{
|
|
GOVERSION: os.Getenv("TOOLCHAIN_GOVERSION"),
|
|
})
|
|
fmt.Printf("%s\n", enc)
|
|
return
|
|
}
|
|
fmt.Fprintln(os.Stderr, "mocking the real build")
|
|
os.Exit(1)
|
|
}
|