Files
Daniel Martí 9cf2a6a77f properly patch the linker when GOROOT is a symlink
Some Go version managers like github.com/voidint/g use GOROOT symlinks,
which silently broke the way we patch the linker via go build -overlay.

Reproduced the original crash via the following testscript:

    env GARBLE_CACHE=${WORK}/garble-cache
    symlink goroot -> /usr/lib/go
    env GOROOT=${WORK}/goroot
    exec garble run main.go

    -- main.go --
    package main

    import "fmt"

    func main() {
        fmt.Println("hello world")
    }

We don't commit this testscript given how it's an expensive test
and for a relatively rare edge case whose fix is now well documented.
Moreover, as GOTOOLCHAIN is now available, I expect version managers
for Go to fade away with time.

While here, remove a debugging 'exec cat' from a testscript.

Fixes #915.
2025-04-26 16:42:15 +02:00

45 lines
1.3 KiB
Plaintext

# We want the upgraded toolchain to match the garble binary
# which we will exec below, as otherwise garble will complain.
# Tell GOTOOLCHAIN to upgrade to the same version thanks to `go mod init`
# setting up a `go` directive with its Go version.
cd mod
go mod init test
cd ..
go env GOVERSION
setenvfile GOVERSION_UPGRADE stdout
# To test that garble works with transparent upgrades via GOTOOLCHAIN,
# use a relatively old version, but still new enough to support GOTOOLCHAIN.
env GOVERSION_BASE=go1.23.0
setup-go ${GOVERSION_BASE}
# We want to use the real GOPROXY so that we can download the newer
# toolchain, and we use the host's GOMODCACHE so we can reuse it.
env GOPROXY=proxy.golang.org
env GOMODCACHE=${HOST_GOMODCACHE}
# Verify that we are using an older version of Go.
exec go version
stdout 'go version '${GOVERSION_BASE@R}
# The builds inside the module use the upgraded toolchain.
cd mod
exec go run .
stderr 'hello from '${GOVERSION_UPGRADE@R}
# Note that garble hides runtime.Version by design, but we know that it requires
# the Go toolchain version to match the exact same version that built garble,
# and that version is most likely newer than GOVERSION_BASE.
exec garble run .
stderr 'hello from unknown'
-- mod/main.go --
package main
import "runtime"
func main() {
println("hello from", runtime.Version())
}