Commit Graph

6 Commits (59eee83beb8bd7433cb64149efcee4ee95333981)

Author SHA1 Message Date
Daniel Martí 59eee83beb
clarify why TestScript sets GONOSUMDB (#958)
And unset it in gotoolchain.txtar, as that one testscript
does fetch modules from the real proxy.golang.org.

Closes #950.
4 months ago
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.
6 months ago
Daniel Martí 8ee4c91196 make gotoolchain.txtar upgrade to the host's GOVERSION
On CI we test on go1.23.x and go1.24.x, so if we always upgrade
to the latest go1.24.x, that will cause garble to complain
when running on go1.23.x:

    garble was built with "go1.23.7" and can't be used with the newer "go1.24.1"

Moreover, the test hard-coded go1.24.1, which is currently the latest
go1.24.x but will not be for long, so this test was brittle.
6 months ago
Daniel Martí db3003b9fa use the correct toolchain "go" tool under GOTOOLCHAIN=auto
We call `go list` to collect information about all the packages
to obfuscate and build, which is crucial to be able to perform
obfuscation of names used across packages.

However, when GOTOOLCHAIN causes a toolchain upgrade,
we must ensure that we use the upgraded Go tool;
otherwise we are mixing information from different toolchain versions.

Fixes #934.
6 months ago
Daniel Martí 7f80dfb59d rebuild cmd/link with the correct toolchain under GOTOOLCHAIN=auto
When we build the patched cmd/link binary for use by garble,
we perform this build in a temporary directory so that the Go module
from the user does not get in the way.

When the user module made us upgrade the toolchain per GOTOOLCHAIN,
leaving that module's directory stops upgrading the toolchain,
so we patch a newer toolchain and build it with an older toolchain.
This is largely harmless, but it makes the newer toolchain think
it is actually an older toolchain, which leads to those pesky
"linker object header mismatch" version errors.

Updates #934.
6 months ago
Daniel Martí 6f7af3b785 add test reproducing gotoolchain upgrade errors
While here, make link.version more readable by adding a newline
and document the assumption it makes about GOVERSION.

For #934.
6 months ago