mirror of
https://github.com/burrowers/garble.git
synced 2025-09-26 20:01:16 +08:00
add support for Go 1.25 and drop support for 1.24
While strictly speaking it would be okay to leave Go 1.24 support in place for the time being, we are behind on a few tasks at the moment so it's best to keep the setup at master simpler for the next release. Go 1.25 already came out two weeks ago, and it seems to have been a fairly smooth release, so I don't suspect any end users will have trouble upgrading to it. Note that two changes were necessary for garble to work on Go 1.25.0. First, we stop deduplicating runtimeAndLinknamed with runtimeAndDeps. Otherwise, for GOOS=windows, internal/runtime/cgroup would be missing as it is a //go:linkname target from runtime on all platforms, but it is not transitively imported from runtime on GOOS=windows. Second, the testing/synctest package is now part of std, and it is a //go:linkname target from the testing package but not a transitive import from it. Teach appendListedPackages that, when loading all packages for a `go test` run, it should load the new testing/synctest package too. Fixes #968.
This commit is contained in:
14
.github/workflows/test.yml
vendored
14
.github/workflows/test.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.24.x]
|
||||
go-version: [1.25.x]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
@@ -53,17 +53,17 @@ jobs:
|
||||
# Static checks from this point forward. Only run on one Go version and on
|
||||
# linux, since it's the fastest platform, and the tools behave the same.
|
||||
- name: Test third-party project builds
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25.x'
|
||||
run: |
|
||||
go install
|
||||
./scripts/check-third-party.sh
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25.x'
|
||||
run: ./scripts/crlf-test.sh
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25.x'
|
||||
run: diff <(echo -n) <(gofmt -d .)
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25.x'
|
||||
run: go vet ./...
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.x'
|
||||
- if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25.x'
|
||||
uses: dominikh/staticcheck-action@v1
|
||||
with:
|
||||
version: "2025.1"
|
||||
@@ -81,6 +81,6 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.24.x
|
||||
go-version: 1.25.x
|
||||
cache: false
|
||||
- run: go test -short ./...
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
go install mvdan.cc/garble@latest
|
||||
|
||||
Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.24 or later.
|
||||
Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.25 or later.
|
||||
|
||||
garble build [build flags] [packages]
|
||||
|
||||
|
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module mvdan.cc/garble
|
||||
|
||||
go 1.24
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/bluekeyes/go-gitdiff v0.8.1
|
||||
|
441
go_std_tables.go
441
go_std_tables.go
@@ -1,68 +1,91 @@
|
||||
// Code generated by scripts/gen_go_std_tables.go; DO NOT EDIT.
|
||||
|
||||
// Generated from Go versions [go1.24.1].
|
||||
// Generated from Go versions [go1.25.0].
|
||||
|
||||
package main
|
||||
|
||||
// runtimeAndDeps contains the runtime package and all of its transitive dependencies
|
||||
// as reported by 'go list -deps'.
|
||||
var runtimeAndDeps = map[string]bool{
|
||||
"internal/abi": true, // go1.24
|
||||
"internal/asan": true, // go1.24
|
||||
"internal/bytealg": true, // go1.24
|
||||
"internal/byteorder": true, // go1.24
|
||||
"internal/chacha8rand": true, // go1.24
|
||||
"internal/coverage/rtcov": true, // go1.24
|
||||
"internal/cpu": true, // go1.24
|
||||
"internal/goarch": true, // go1.24
|
||||
"internal/godebugs": true, // go1.24
|
||||
"internal/goexperiment": true, // go1.24
|
||||
"internal/goos": true, // go1.24
|
||||
"internal/msan": true, // go1.24
|
||||
"internal/profilerecord": true, // go1.24
|
||||
"internal/race": true, // go1.24
|
||||
"internal/runtime/atomic": true, // go1.24
|
||||
"internal/runtime/exithook": true, // go1.24
|
||||
"internal/runtime/maps": true, // go1.24
|
||||
"internal/runtime/math": true, // go1.24
|
||||
"internal/runtime/sys": true, // go1.24
|
||||
"internal/runtime/syscall": true, // go1.24
|
||||
"internal/stringslite": true, // go1.24
|
||||
"runtime": true, // go1.24
|
||||
"unsafe": true, // go1.24
|
||||
"internal/abi": true, // go1.25
|
||||
"internal/asan": true, // go1.25
|
||||
"internal/bytealg": true, // go1.25
|
||||
"internal/byteorder": true, // go1.25
|
||||
"internal/chacha8rand": true, // go1.25
|
||||
"internal/coverage/rtcov": true, // go1.25
|
||||
"internal/cpu": true, // go1.25
|
||||
"internal/goarch": true, // go1.25
|
||||
"internal/godebugs": true, // go1.25
|
||||
"internal/goexperiment": true, // go1.25
|
||||
"internal/goos": true, // go1.25
|
||||
"internal/msan": true, // go1.25
|
||||
"internal/profilerecord": true, // go1.25
|
||||
"internal/race": true, // go1.25
|
||||
"internal/runtime/atomic": true, // go1.25
|
||||
"internal/runtime/cgroup": true, // go1.25
|
||||
"internal/runtime/exithook": true, // go1.25
|
||||
"internal/runtime/gc": true, // go1.25
|
||||
"internal/runtime/maps": true, // go1.25
|
||||
"internal/runtime/math": true, // go1.25
|
||||
"internal/runtime/strconv": true, // go1.25
|
||||
"internal/runtime/sys": true, // go1.25
|
||||
"internal/runtime/syscall": true, // go1.25
|
||||
"internal/stringslite": true, // go1.25
|
||||
"internal/trace/tracev2": true, // go1.25
|
||||
"runtime": true, // go1.25
|
||||
"unsafe": true, // go1.25
|
||||
}
|
||||
|
||||
var runtimeLinknamed = []string{
|
||||
"arena", // go1.24
|
||||
"crypto/internal/boring", // go1.24
|
||||
"crypto/internal/boring/bcache", // go1.24
|
||||
"crypto/internal/boring/fipstls", // go1.24
|
||||
"crypto/internal/fips140", // go1.24
|
||||
"crypto/internal/sysrand", // go1.24
|
||||
"crypto/rand", // go1.24
|
||||
"crypto/x509/internal/macos", // go1.24
|
||||
"internal/coverage/cfile", // go1.24
|
||||
"internal/godebug", // go1.24
|
||||
"internal/poll", // go1.24
|
||||
"internal/reflectlite", // go1.24
|
||||
"internal/sync", // go1.24
|
||||
"internal/synctest", // go1.24
|
||||
"internal/syscall/unix", // go1.24
|
||||
"internal/syscall/windows", // go1.24
|
||||
"maps", // go1.24
|
||||
"os", // go1.24
|
||||
"os/signal", // go1.24
|
||||
"plugin", // go1.24
|
||||
"reflect", // go1.24
|
||||
"runtime/debug", // go1.24
|
||||
"runtime/metrics", // go1.24
|
||||
"runtime/pprof", // go1.24
|
||||
"runtime/trace", // go1.24
|
||||
"sync", // go1.24
|
||||
"sync/atomic", // go1.24
|
||||
"syscall", // go1.24
|
||||
"syscall/js", // go1.24
|
||||
"time", // go1.24
|
||||
"unique", // go1.24
|
||||
"weak", // go1.24
|
||||
// runtimeAndLinknamed contains the runtime package and all the packages
|
||||
// which it points to via //go:linkname directives.
|
||||
// We need to track these as some are not imported as transitive dependencies,
|
||||
// and we need to load these to properly obfuscate the linkname target names.
|
||||
//
|
||||
// Note that runtimeAndLinknamed may contain duplicates with runtimeAndDeps.
|
||||
// This is on purpose; some packages are in runtimeAndDeps via 'go list -deps'
|
||||
// but not transitively imported on some platforms, even though they are used
|
||||
// from the runtime package via //go:linkname directives on those platforms.
|
||||
// To make sure we have coverage on all platforms, we allow duplicates.
|
||||
var runtimeAndLinknamed = []string{
|
||||
"arena", // go1.25
|
||||
"crypto/internal/boring", // go1.25
|
||||
"crypto/internal/boring/bcache", // go1.25
|
||||
"crypto/internal/fips140", // go1.25
|
||||
"crypto/internal/sysrand", // go1.25
|
||||
"crypto/rand", // go1.25
|
||||
"crypto/x509/internal/macos", // go1.25
|
||||
"internal/bytealg", // go1.25
|
||||
"internal/coverage/cfile", // go1.25
|
||||
"internal/cpu", // go1.25
|
||||
"internal/godebug", // go1.25
|
||||
"internal/poll", // go1.25
|
||||
"internal/race", // go1.25
|
||||
"internal/reflectlite", // go1.25
|
||||
"internal/runtime/atomic", // go1.25
|
||||
"internal/runtime/cgroup", // go1.25
|
||||
"internal/runtime/maps", // go1.25
|
||||
"internal/sync", // go1.25
|
||||
"internal/synctest", // go1.25
|
||||
"internal/syscall/unix", // go1.25
|
||||
"internal/syscall/windows", // go1.25
|
||||
"maps", // go1.25
|
||||
"os", // go1.25
|
||||
"os/signal", // go1.25
|
||||
"plugin", // go1.25
|
||||
"reflect", // go1.25
|
||||
"runtime", // go1.25
|
||||
"runtime/debug", // go1.25
|
||||
"runtime/metrics", // go1.25
|
||||
"runtime/pprof", // go1.25
|
||||
"runtime/trace", // go1.25
|
||||
"sync", // go1.25
|
||||
"sync/atomic", // go1.25
|
||||
"sync_test", // go1.25
|
||||
"syscall", // go1.25
|
||||
"syscall/js", // go1.25
|
||||
"time", // go1.25
|
||||
"unique", // go1.25
|
||||
"weak", // go1.25
|
||||
// The net package linknames to the runtime, not the other way around.
|
||||
// TODO: support this automatically via our script.
|
||||
"net",
|
||||
@@ -70,176 +93,176 @@ var runtimeLinknamed = []string{
|
||||
|
||||
var compilerIntrinsics = map[string]map[string]bool{
|
||||
"internal/runtime/atomic": {
|
||||
"And": true, // go1.24
|
||||
"And32": true, // go1.24
|
||||
"And64": true, // go1.24
|
||||
"And8": true, // go1.24
|
||||
"Anduintptr": true, // go1.24
|
||||
"Cas": true, // go1.24
|
||||
"Cas64": true, // go1.24
|
||||
"CasRel": true, // go1.24
|
||||
"Casint32": true, // go1.24
|
||||
"Casint64": true, // go1.24
|
||||
"Casp1": true, // go1.24
|
||||
"Casuintptr": true, // go1.24
|
||||
"Load": true, // go1.24
|
||||
"Load64": true, // go1.24
|
||||
"Load8": true, // go1.24
|
||||
"LoadAcq": true, // go1.24
|
||||
"LoadAcq64": true, // go1.24
|
||||
"LoadAcquintptr": true, // go1.24
|
||||
"Loadint32": true, // go1.24
|
||||
"Loadint64": true, // go1.24
|
||||
"Loadp": true, // go1.24
|
||||
"Loaduint": true, // go1.24
|
||||
"Loaduintptr": true, // go1.24
|
||||
"Or": true, // go1.24
|
||||
"Or32": true, // go1.24
|
||||
"Or64": true, // go1.24
|
||||
"Or8": true, // go1.24
|
||||
"Oruintptr": true, // go1.24
|
||||
"Store": true, // go1.24
|
||||
"Store64": true, // go1.24
|
||||
"Store8": true, // go1.24
|
||||
"StoreRel": true, // go1.24
|
||||
"StoreRel64": true, // go1.24
|
||||
"StoreReluintptr": true, // go1.24
|
||||
"Storeint32": true, // go1.24
|
||||
"Storeint64": true, // go1.24
|
||||
"StorepNoWB": true, // go1.24
|
||||
"Storeuintptr": true, // go1.24
|
||||
"Xadd": true, // go1.24
|
||||
"Xadd64": true, // go1.24
|
||||
"Xaddint32": true, // go1.24
|
||||
"Xaddint64": true, // go1.24
|
||||
"Xadduintptr": true, // go1.24
|
||||
"Xchg": true, // go1.24
|
||||
"Xchg64": true, // go1.24
|
||||
"Xchg8": true, // go1.24
|
||||
"Xchgint32": true, // go1.24
|
||||
"Xchgint64": true, // go1.24
|
||||
"Xchguintptr": true, // go1.24
|
||||
"And": true, // go1.25
|
||||
"And32": true, // go1.25
|
||||
"And64": true, // go1.25
|
||||
"And8": true, // go1.25
|
||||
"Anduintptr": true, // go1.25
|
||||
"Cas": true, // go1.25
|
||||
"Cas64": true, // go1.25
|
||||
"CasRel": true, // go1.25
|
||||
"Casint32": true, // go1.25
|
||||
"Casint64": true, // go1.25
|
||||
"Casp1": true, // go1.25
|
||||
"Casuintptr": true, // go1.25
|
||||
"Load": true, // go1.25
|
||||
"Load64": true, // go1.25
|
||||
"Load8": true, // go1.25
|
||||
"LoadAcq": true, // go1.25
|
||||
"LoadAcq64": true, // go1.25
|
||||
"LoadAcquintptr": true, // go1.25
|
||||
"Loadint32": true, // go1.25
|
||||
"Loadint64": true, // go1.25
|
||||
"Loadp": true, // go1.25
|
||||
"Loaduint": true, // go1.25
|
||||
"Loaduintptr": true, // go1.25
|
||||
"Or": true, // go1.25
|
||||
"Or32": true, // go1.25
|
||||
"Or64": true, // go1.25
|
||||
"Or8": true, // go1.25
|
||||
"Oruintptr": true, // go1.25
|
||||
"Store": true, // go1.25
|
||||
"Store64": true, // go1.25
|
||||
"Store8": true, // go1.25
|
||||
"StoreRel": true, // go1.25
|
||||
"StoreRel64": true, // go1.25
|
||||
"StoreReluintptr": true, // go1.25
|
||||
"Storeint32": true, // go1.25
|
||||
"Storeint64": true, // go1.25
|
||||
"StorepNoWB": true, // go1.25
|
||||
"Storeuintptr": true, // go1.25
|
||||
"Xadd": true, // go1.25
|
||||
"Xadd64": true, // go1.25
|
||||
"Xaddint32": true, // go1.25
|
||||
"Xaddint64": true, // go1.25
|
||||
"Xadduintptr": true, // go1.25
|
||||
"Xchg": true, // go1.25
|
||||
"Xchg64": true, // go1.25
|
||||
"Xchg8": true, // go1.25
|
||||
"Xchgint32": true, // go1.25
|
||||
"Xchgint64": true, // go1.25
|
||||
"Xchguintptr": true, // go1.25
|
||||
},
|
||||
"internal/runtime/maps": {
|
||||
"bitsetFirst": true, // go1.24
|
||||
"bitsetLowestSet": true, // go1.24
|
||||
"bitsetRemoveBelow": true, // go1.24
|
||||
"bitsetShiftOutLowest": true, // go1.24
|
||||
"ctrlGroupMatchEmpty": true, // go1.24
|
||||
"ctrlGroupMatchEmptyOrDeleted": true, // go1.24
|
||||
"ctrlGroupMatchFull": true, // go1.24
|
||||
"ctrlGroupMatchH2": true, // go1.24
|
||||
"bitsetFirst": true, // go1.25
|
||||
"bitsetLowestSet": true, // go1.25
|
||||
"bitsetRemoveBelow": true, // go1.25
|
||||
"bitsetShiftOutLowest": true, // go1.25
|
||||
"ctrlGroupMatchEmpty": true, // go1.25
|
||||
"ctrlGroupMatchEmptyOrDeleted": true, // go1.25
|
||||
"ctrlGroupMatchFull": true, // go1.25
|
||||
"ctrlGroupMatchH2": true, // go1.25
|
||||
},
|
||||
"internal/runtime/math": {
|
||||
"MulUintptr": true, // go1.24
|
||||
"MulUintptr": true, // go1.25
|
||||
},
|
||||
"internal/runtime/sys": {
|
||||
"Bswap32": true, // go1.24
|
||||
"Bswap64": true, // go1.24
|
||||
"Len64": true, // go1.24
|
||||
"Len8": true, // go1.24
|
||||
"OnesCount64": true, // go1.24
|
||||
"Prefetch": true, // go1.24
|
||||
"PrefetchStreamed": true, // go1.24
|
||||
"TrailingZeros32": true, // go1.24
|
||||
"TrailingZeros64": true, // go1.24
|
||||
"TrailingZeros8": true, // go1.24
|
||||
"Bswap32": true, // go1.25
|
||||
"Bswap64": true, // go1.25
|
||||
"Len64": true, // go1.25
|
||||
"Len8": true, // go1.25
|
||||
"OnesCount64": true, // go1.25
|
||||
"Prefetch": true, // go1.25
|
||||
"PrefetchStreamed": true, // go1.25
|
||||
"TrailingZeros32": true, // go1.25
|
||||
"TrailingZeros64": true, // go1.25
|
||||
"TrailingZeros8": true, // go1.25
|
||||
},
|
||||
"math": {
|
||||
"Abs": true, // go1.24
|
||||
"Ceil": true, // go1.24
|
||||
"Copysign": true, // go1.24
|
||||
"FMA": true, // go1.24
|
||||
"Floor": true, // go1.24
|
||||
"Round": true, // go1.24
|
||||
"RoundToEven": true, // go1.24
|
||||
"Trunc": true, // go1.24
|
||||
"sqrt": true, // go1.24
|
||||
"Abs": true, // go1.25
|
||||
"Ceil": true, // go1.25
|
||||
"Copysign": true, // go1.25
|
||||
"FMA": true, // go1.25
|
||||
"Floor": true, // go1.25
|
||||
"Round": true, // go1.25
|
||||
"RoundToEven": true, // go1.25
|
||||
"Trunc": true, // go1.25
|
||||
"sqrt": true, // go1.25
|
||||
},
|
||||
"math/big": {
|
||||
"mulWW": true, // go1.24
|
||||
"mulWW": true, // go1.25
|
||||
},
|
||||
"math/bits": {
|
||||
"Add": true, // go1.24
|
||||
"Add64": true, // go1.24
|
||||
"Div": true, // go1.24
|
||||
"Div64": true, // go1.24
|
||||
"Len": true, // go1.24
|
||||
"Len16": true, // go1.24
|
||||
"Len32": true, // go1.24
|
||||
"Len64": true, // go1.24
|
||||
"Len8": true, // go1.24
|
||||
"Mul": true, // go1.24
|
||||
"Mul64": true, // go1.24
|
||||
"OnesCount": true, // go1.24
|
||||
"OnesCount16": true, // go1.24
|
||||
"OnesCount32": true, // go1.24
|
||||
"OnesCount64": true, // go1.24
|
||||
"OnesCount8": true, // go1.24
|
||||
"Reverse": true, // go1.24
|
||||
"Reverse16": true, // go1.24
|
||||
"Reverse32": true, // go1.24
|
||||
"Reverse64": true, // go1.24
|
||||
"Reverse8": true, // go1.24
|
||||
"ReverseBytes16": true, // go1.24
|
||||
"ReverseBytes32": true, // go1.24
|
||||
"ReverseBytes64": true, // go1.24
|
||||
"RotateLeft": true, // go1.24
|
||||
"RotateLeft16": true, // go1.24
|
||||
"RotateLeft32": true, // go1.24
|
||||
"RotateLeft64": true, // go1.24
|
||||
"RotateLeft8": true, // go1.24
|
||||
"Sub": true, // go1.24
|
||||
"Sub64": true, // go1.24
|
||||
"TrailingZeros16": true, // go1.24
|
||||
"TrailingZeros32": true, // go1.24
|
||||
"TrailingZeros64": true, // go1.24
|
||||
"TrailingZeros8": true, // go1.24
|
||||
"Add": true, // go1.25
|
||||
"Add64": true, // go1.25
|
||||
"Div": true, // go1.25
|
||||
"Div64": true, // go1.25
|
||||
"Len": true, // go1.25
|
||||
"Len16": true, // go1.25
|
||||
"Len32": true, // go1.25
|
||||
"Len64": true, // go1.25
|
||||
"Len8": true, // go1.25
|
||||
"Mul": true, // go1.25
|
||||
"Mul64": true, // go1.25
|
||||
"OnesCount": true, // go1.25
|
||||
"OnesCount16": true, // go1.25
|
||||
"OnesCount32": true, // go1.25
|
||||
"OnesCount64": true, // go1.25
|
||||
"OnesCount8": true, // go1.25
|
||||
"Reverse": true, // go1.25
|
||||
"Reverse16": true, // go1.25
|
||||
"Reverse32": true, // go1.25
|
||||
"Reverse64": true, // go1.25
|
||||
"Reverse8": true, // go1.25
|
||||
"ReverseBytes16": true, // go1.25
|
||||
"ReverseBytes32": true, // go1.25
|
||||
"ReverseBytes64": true, // go1.25
|
||||
"RotateLeft": true, // go1.25
|
||||
"RotateLeft16": true, // go1.25
|
||||
"RotateLeft32": true, // go1.25
|
||||
"RotateLeft64": true, // go1.25
|
||||
"RotateLeft8": true, // go1.25
|
||||
"Sub": true, // go1.25
|
||||
"Sub64": true, // go1.25
|
||||
"TrailingZeros16": true, // go1.25
|
||||
"TrailingZeros32": true, // go1.25
|
||||
"TrailingZeros64": true, // go1.25
|
||||
"TrailingZeros8": true, // go1.25
|
||||
},
|
||||
"runtime": {
|
||||
"publicationBarrier": true, // go1.24
|
||||
"publicationBarrier": true, // go1.25
|
||||
},
|
||||
"sync": {
|
||||
"runtime_LoadAcquintptr": true, // go1.24
|
||||
"runtime_StoreReluintptr": true, // go1.24
|
||||
"runtime_LoadAcquintptr": true, // go1.25
|
||||
"runtime_StoreReluintptr": true, // go1.25
|
||||
},
|
||||
"sync/atomic": {
|
||||
"AddInt32": true, // go1.24
|
||||
"AddInt64": true, // go1.24
|
||||
"AddUint32": true, // go1.24
|
||||
"AddUint64": true, // go1.24
|
||||
"AddUintptr": true, // go1.24
|
||||
"AndInt32": true, // go1.24
|
||||
"AndInt64": true, // go1.24
|
||||
"AndUint32": true, // go1.24
|
||||
"AndUint64": true, // go1.24
|
||||
"AndUintptr": true, // go1.24
|
||||
"CompareAndSwapInt32": true, // go1.24
|
||||
"CompareAndSwapInt64": true, // go1.24
|
||||
"CompareAndSwapUint32": true, // go1.24
|
||||
"CompareAndSwapUint64": true, // go1.24
|
||||
"CompareAndSwapUintptr": true, // go1.24
|
||||
"LoadInt32": true, // go1.24
|
||||
"LoadInt64": true, // go1.24
|
||||
"LoadPointer": true, // go1.24
|
||||
"LoadUint32": true, // go1.24
|
||||
"LoadUint64": true, // go1.24
|
||||
"LoadUintptr": true, // go1.24
|
||||
"OrInt32": true, // go1.24
|
||||
"OrInt64": true, // go1.24
|
||||
"OrUint32": true, // go1.24
|
||||
"OrUint64": true, // go1.24
|
||||
"OrUintptr": true, // go1.24
|
||||
"StoreInt32": true, // go1.24
|
||||
"StoreInt64": true, // go1.24
|
||||
"StoreUint32": true, // go1.24
|
||||
"StoreUint64": true, // go1.24
|
||||
"StoreUintptr": true, // go1.24
|
||||
"SwapInt32": true, // go1.24
|
||||
"SwapInt64": true, // go1.24
|
||||
"SwapUint32": true, // go1.24
|
||||
"SwapUint64": true, // go1.24
|
||||
"SwapUintptr": true, // go1.24
|
||||
"AddInt32": true, // go1.25
|
||||
"AddInt64": true, // go1.25
|
||||
"AddUint32": true, // go1.25
|
||||
"AddUint64": true, // go1.25
|
||||
"AddUintptr": true, // go1.25
|
||||
"AndInt32": true, // go1.25
|
||||
"AndInt64": true, // go1.25
|
||||
"AndUint32": true, // go1.25
|
||||
"AndUint64": true, // go1.25
|
||||
"AndUintptr": true, // go1.25
|
||||
"CompareAndSwapInt32": true, // go1.25
|
||||
"CompareAndSwapInt64": true, // go1.25
|
||||
"CompareAndSwapUint32": true, // go1.25
|
||||
"CompareAndSwapUint64": true, // go1.25
|
||||
"CompareAndSwapUintptr": true, // go1.25
|
||||
"LoadInt32": true, // go1.25
|
||||
"LoadInt64": true, // go1.25
|
||||
"LoadPointer": true, // go1.25
|
||||
"LoadUint32": true, // go1.25
|
||||
"LoadUint64": true, // go1.25
|
||||
"LoadUintptr": true, // go1.25
|
||||
"OrInt32": true, // go1.25
|
||||
"OrInt64": true, // go1.25
|
||||
"OrUint32": true, // go1.25
|
||||
"OrUint64": true, // go1.25
|
||||
"OrUintptr": true, // go1.25
|
||||
"StoreInt32": true, // go1.25
|
||||
"StoreInt64": true, // go1.25
|
||||
"StoreUint32": true, // go1.25
|
||||
"StoreUint64": true, // go1.25
|
||||
"StoreUintptr": true, // go1.25
|
||||
"SwapInt32": true, // go1.25
|
||||
"SwapInt64": true, // go1.25
|
||||
"SwapUint32": true, // go1.25
|
||||
"SwapUint64": true, // go1.25
|
||||
"SwapUintptr": true, // go1.25
|
||||
},
|
||||
}
|
||||
|
||||
|
4
main.go
4
main.go
@@ -290,8 +290,8 @@ func (e errJustExit) Error() string { return fmt.Sprintf("exit: %d", e) }
|
||||
|
||||
func goVersionOK() bool {
|
||||
const (
|
||||
minGoVersion = "go1.24" // the minimum Go version we support; could be a bugfix release if needed
|
||||
unsupportedGo = "go1.25" // the first major version we don't support
|
||||
minGoVersion = "go1.25.0" // the minimum Go version we support; could be a bugfix release if needed
|
||||
unsupportedGo = "go1.26" // the first major version we don't support
|
||||
)
|
||||
|
||||
// rxVersion looks for a version like "go1.2" or "go1.2.3" in `go env GOVERSION`.
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var goVersions = []string{"go1.24.1"}
|
||||
var goVersions = []string{"go1.25.0"}
|
||||
|
||||
var tmplTables = template.Must(template.New("").Parse(`
|
||||
// Code generated by scripts/gen_go_std_tables.go; DO NOT EDIT.
|
||||
@@ -30,14 +30,26 @@ var tmplTables = template.Must(template.New("").Parse(`
|
||||
|
||||
package main
|
||||
|
||||
// runtimeAndDeps contains the runtime package and all of its transitive dependencies
|
||||
// as reported by 'go list -deps'.
|
||||
var runtimeAndDeps = map[string]bool{
|
||||
{{- range $path := .RuntimeAndDeps }}
|
||||
"{{ $path.String }}": true, // {{ $path.GoVersionLang }}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
var runtimeLinknamed = []string{
|
||||
{{- range $path := .RuntimeLinknamed }}
|
||||
// runtimeAndLinknamed contains the runtime package and all the packages
|
||||
// which it points to via //go:linkname directives.
|
||||
// We need to track these as some are not imported as transitive dependencies,
|
||||
// and we need to load these to properly obfuscate the linkname target names.
|
||||
//
|
||||
// Note that runtimeAndLinknamed may contain duplicates with runtimeAndDeps.
|
||||
// This is on purpose; some packages are in runtimeAndDeps via 'go list -deps'
|
||||
// but not transitively imported on some platforms, even though they are used
|
||||
// from the runtime package via //go:linkname directives on those platforms.
|
||||
// To make sure we have coverage on all platforms, we allow duplicates.
|
||||
var runtimeAndLinknamed = []string{
|
||||
{{- range $path := .RuntimeAndLinknamed }}
|
||||
"{{ $path.String }}", // {{ $path.GoVersionLang }}
|
||||
{{- end }}
|
||||
// The net package linknames to the runtime, not the other way around.
|
||||
@@ -63,7 +75,7 @@ var reflectSkipPkg = map[string]bool{
|
||||
type tmplData struct {
|
||||
GoVersions []string
|
||||
RuntimeAndDeps []versionedString
|
||||
RuntimeLinknamed []versionedString
|
||||
RuntimeAndLinknamed []versionedString
|
||||
CompilerIntrinsics []tmplIntrinsic
|
||||
}
|
||||
|
||||
@@ -151,7 +163,7 @@ func main() {
|
||||
// All packages that the runtime linknames to, except runtime and its dependencies.
|
||||
// This resulting list is what we need to "go list" when obfuscating the runtime,
|
||||
// as they are the packages that we may be missing.
|
||||
var runtimeLinknamed []versionedString
|
||||
var runtimeAndLinknamed []versionedString
|
||||
for _, goroot := range goroots {
|
||||
runtimeGoFiles, err := filepath.Glob(filepath.Join(goroot.String, "src", "runtime", "*.go"))
|
||||
if err != nil {
|
||||
@@ -168,23 +180,15 @@ func main() {
|
||||
case "main", "runtime/metrics_test":
|
||||
continue
|
||||
}
|
||||
runtimeLinknamed = append(runtimeLinknamed, versionedString{
|
||||
runtimeAndLinknamed = append(runtimeAndLinknamed, versionedString{
|
||||
String: path,
|
||||
GoVersionLang: goroot.GoVersionLang,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
slices.SortFunc(runtimeLinknamed, versionedString.Compare)
|
||||
runtimeLinknamed = slices.CompactFunc(runtimeLinknamed, versionedString.Equal)
|
||||
runtimeLinknamed = slices.DeleteFunc(runtimeLinknamed, func(path versionedString) bool {
|
||||
for _, prev := range runtimeAndDeps {
|
||||
if prev.String == path.String {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
slices.SortFunc(runtimeAndLinknamed, versionedString.Compare)
|
||||
runtimeAndLinknamed = slices.CompactFunc(runtimeAndLinknamed, versionedString.Equal)
|
||||
|
||||
compilerIntrinsicsIndexByPath := make(map[string]int)
|
||||
var compilerIntrinsics []tmplIntrinsic
|
||||
@@ -224,7 +228,7 @@ func main() {
|
||||
if err := tmplTables.Execute(&buf, tmplData{
|
||||
GoVersions: goVersions,
|
||||
RuntimeAndDeps: runtimeAndDeps,
|
||||
RuntimeLinknamed: runtimeLinknamed,
|
||||
RuntimeAndLinknamed: runtimeAndLinknamed,
|
||||
CompilerIntrinsics: compilerIntrinsics,
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
|
31
shared.go
31
shared.go
@@ -274,12 +274,23 @@ func appendListedPackages(packages []string, mainBuild bool) error {
|
||||
// Similar flags to what go/packages uses.
|
||||
"-json", "-export", "-compiled", "-e",
|
||||
}
|
||||
if len(packages) == 0 {
|
||||
// As we may append to the packages slice below,
|
||||
// ensure that zero packages still means "the current directory".
|
||||
packages = append(packages, ".")
|
||||
}
|
||||
if mainBuild {
|
||||
// When loading the top-level packages we are building,
|
||||
// we want to transitively load all their dependencies as well.
|
||||
// That is not the case when loading standard library packages,
|
||||
// as runtimeLinknamed already contains transitive dependencies.
|
||||
// as runtimeAndLinknamed already contains transitive dependencies.
|
||||
args = append(args, "-deps")
|
||||
if slices.Contains(sharedCache.ForwardBuildFlags, "-test") {
|
||||
// The testing package uses a //go:linkname directive pointing to testing/synctest,
|
||||
// but it doesn't import the package, presumably to avoid an import cycle.
|
||||
// For the linkname to obfuscate correctly, we need to list both when using `go test`.
|
||||
packages = append(packages, "testing/synctest")
|
||||
}
|
||||
}
|
||||
args = append(args, garbleBuildFlags...)
|
||||
args = append(args, sharedCache.ForwardBuildFlags...)
|
||||
@@ -327,7 +338,7 @@ func appendListedPackages(packages []string, mainBuild bool) error {
|
||||
|
||||
if perr := pkg.Error; perr != nil {
|
||||
if !mainBuild && strings.Contains(perr.Err, "build constraints exclude all Go files") {
|
||||
// Some packages in runtimeLinknamed need a build tag to be importable,
|
||||
// Some packages in runtimeAndLinknamed need a build tag to be importable,
|
||||
// like crypto/internal/boring/fipstls with boringcrypto,
|
||||
// so any pkg.Error should be ignored when the build tag isn't set.
|
||||
} else if !mainBuild && strings.Contains(perr.Err, "is not in std") {
|
||||
@@ -408,7 +419,7 @@ func appendListedPackages(packages []string, mainBuild bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var listedRuntimeLinknamed = false
|
||||
var listedRuntimeAndLinknamed = false
|
||||
|
||||
var ErrNotFound = errors.New("not found")
|
||||
|
||||
@@ -433,20 +444,20 @@ func listPackage(from *listedPackage, path string) (*listedPackage, error) {
|
||||
// This is due to how runtime linkname-implements std packages,
|
||||
// such as sync/atomic or reflect, without importing them in any way.
|
||||
// A few other cases don't involve runtime, like time/tzdata linknaming to time,
|
||||
// but luckily those few cases are covered by runtimeLinknamed as well.
|
||||
// but luckily those few cases are covered by runtimeAndLinknamed as well.
|
||||
//
|
||||
// If ListedPackages lacks such a package we fill it via runtimeLinknamed.
|
||||
// TODO: can we instead add runtimeLinknamed to the top-level "go list" args?
|
||||
// If ListedPackages lacks such a package we fill it via runtimeAndLinknamed.
|
||||
// TODO: can we instead add runtimeAndLinknamed to the top-level "go list" args?
|
||||
if from.Standard {
|
||||
if ok {
|
||||
return pkg, nil
|
||||
}
|
||||
if listedRuntimeLinknamed {
|
||||
if listedRuntimeAndLinknamed {
|
||||
return nil, fmt.Errorf("package %q still missing after go list call", path)
|
||||
}
|
||||
startTime := time.Now()
|
||||
missing := make([]string, 0, len(runtimeLinknamed))
|
||||
for _, linknamed := range runtimeLinknamed {
|
||||
missing := make([]string, 0, len(runtimeAndLinknamed))
|
||||
for _, linknamed := range runtimeAndLinknamed {
|
||||
switch {
|
||||
case sharedCache.ListedPackages[linknamed] != nil:
|
||||
// We already have it; skip.
|
||||
@@ -466,7 +477,7 @@ func listPackage(from *listedPackage, path string) (*listedPackage, error) {
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("std listed another std package that we can't find: %s", path)
|
||||
}
|
||||
listedRuntimeLinknamed = true
|
||||
listedRuntimeAndLinknamed = true
|
||||
log.Printf("listed %d missing runtime-linknamed packages in %s", len(missing), debugSince(startTime))
|
||||
return pkg, nil
|
||||
}
|
||||
|
34
testdata/script/goversion.txtar
vendored
34
testdata/script/goversion.txtar
vendored
@@ -7,22 +7,22 @@ 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\.24 or newer'
|
||||
stderr 'Go version is too old; please upgrade to go1\.25\.0 or newer'
|
||||
|
||||
# We should error on a devel version that's too old.
|
||||
# Note that they lacked the "goN.M-" prefix.
|
||||
env TOOLCHAIN_GOVERSION='devel +afb5fca Sun Aug 07 00:00:00 2020 +0000'
|
||||
! exec garble build
|
||||
stderr 'Go version is too old; please upgrade to go1\.24 or newer'
|
||||
stderr 'Go version is too old; please upgrade to go1\.25\.0 or newer'
|
||||
|
||||
# Another form of old version; with an old "goN.M-" prefix.
|
||||
env TOOLCHAIN_GOVERSION='devel go1.15-afb5fca Sun Aug 07 00:00:00 2020 +0000'
|
||||
! exec garble build
|
||||
stderr 'Go version "devel go1\.15-.*2020.*" is too old; please upgrade to go1\.24 or newer'
|
||||
stderr 'Go version "devel go1\.15-.*2020.*" is too old; please upgrade to go1\.25\.0 or newer'
|
||||
|
||||
# A current devel version should be fine.
|
||||
# Note that we don't look at devel version timestamps.
|
||||
env GARBLE_TEST_GOVERSION='go1.24.5'
|
||||
env GARBLE_TEST_GOVERSION='go1.25.0'
|
||||
# TODO: temporarily disabled while we do not support tip.
|
||||
# env TOOLCHAIN_GOVERSION='devel go1.24-ad97d204f0 Sun Sep 12 16:46:58 2023 +0000'
|
||||
# ! exec garble build
|
||||
@@ -31,49 +31,49 @@ env GARBLE_TEST_GOVERSION='go1.24.5'
|
||||
# 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\.24 or newer'
|
||||
stderr 'Go version "go1\.14" is too old; please upgrade to go1\.25\.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.28.2'
|
||||
env TOOLCHAIN_GOVERSION='go1.28.2'
|
||||
! exec garble build
|
||||
stderr 'Go version "go1\.28\.2" is too new; Go linker patches aren''t available for go1\.25 or later yet'
|
||||
stderr 'Go version "go1\.28\.2" is too new; Go linker patches aren''t available for go1\.26 or later yet'
|
||||
|
||||
# We should accept custom devel strings.
|
||||
env TOOLCHAIN_GOVERSION='devel go1.24.5-somecustomversion'
|
||||
env TOOLCHAIN_GOVERSION='devel go1.25.0-somecustomversion'
|
||||
! 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.24.22'
|
||||
env TOOLCHAIN_GOVERSION='go1.24.21'
|
||||
env GARBLE_TEST_GOVERSION='go1.25.1'
|
||||
env TOOLCHAIN_GOVERSION='go1.25.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.24.25'
|
||||
env TOOLCHAIN_GOVERSION='go1.24.25'
|
||||
env GARBLE_TEST_GOVERSION='go1.25.0'
|
||||
env TOOLCHAIN_GOVERSION='go1.25.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.24.25'
|
||||
env TOOLCHAIN_GOVERSION='go1.25.0'
|
||||
! exec garble build
|
||||
stderr 'garble was built with "go1\.18" and can''t be used with the newer "go1\.24\.25"; rebuild '
|
||||
stderr 'garble was built with "go1\.18" and can''t be used with the newer "go1\.25\.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.24.11'
|
||||
env TOOLCHAIN_GOVERSION='go1.24.14'
|
||||
env GARBLE_TEST_GOVERSION='go1.25.11'
|
||||
env TOOLCHAIN_GOVERSION='go1.25.14'
|
||||
! exec garble build
|
||||
stderr 'garble was built with "go1\.24\.11" and can''t be used with the newer "go1\.24\.14"; rebuild '
|
||||
stderr 'garble was built with "go1\.25\.11" and can''t be used with the newer "go1\.25\.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.24.25'
|
||||
env TOOLCHAIN_GOVERSION='go1.25.0'
|
||||
! exec garble build
|
||||
stderr 'mocking the real build'
|
||||
-- go.mod --
|
||||
|
4
testdata/script/modinfo.txtar
vendored
4
testdata/script/modinfo.txtar
vendored
@@ -20,12 +20,12 @@ go build -tags veryuniquebuildtag
|
||||
|
||||
go version -m main$exe
|
||||
stdout 'path\s*test/main'
|
||||
[go1.24] stdout 'mod\s*test/main\s*v0\.0\.0-202\d'
|
||||
stdout 'mod\s*test/main\s*v0\.0\.0-202\d'
|
||||
stdout 'build\s*-tags=veryuniquebuildtag'
|
||||
stdout 'build\s*vcs.revision='${HEAD_COMMIT_SHA}
|
||||
|
||||
binsubstr main$exe 'veryuniquebuildtag' ${HEAD_COMMIT_SHA}
|
||||
[go1.24] binsubstr main$exe 'v0.0.0-202'
|
||||
binsubstr main$exe 'v0.0.0-202'
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
|
Reference in New Issue
Block a user