diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4da1101..2b58de3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: test: strategy: matrix: - go-version: [1.20.x, 1.21.x] + go-version: [1.21.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/go.mod b/go.mod index 155d1fd..daff0bf 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module mvdan.cc/garble -go 1.20 +go 1.21 require ( github.com/bluekeyes/go-gitdiff v0.7.1 diff --git a/go.sum b/go.sum index 40d9d2e..97aab8c 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,7 @@ golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUU golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= diff --git a/main.go b/main.go index 16c7c33..0d6d4be 100644 --- a/main.go +++ b/main.go @@ -267,7 +267,7 @@ func (e errJustExit) Error() string { return fmt.Sprintf("exit: %d", e) } func goVersionOK() bool { const ( - minGoVersionSemver = "v1.20.0" + minGoVersionSemver = "v1.21.0" suggestedGoVersion = "1.21" ) @@ -1329,7 +1329,7 @@ func (tf *transformer) processImportCfg(flags []string, requiredPkgs []string) ( // See exporttest/*.go in testdata/scripts/test.txt. // For now, spot the pattern and avoid the unnecessary error; // the dependency is unused, so the packagefile line is redundant. - // This still triggers as of go1.20. + // This still triggers as of go1.21. if strings.HasSuffix(tf.curPkg.ImportPath, ".test]") && strings.HasPrefix(tf.curPkg.ImportPath, impPath) { continue } @@ -2195,7 +2195,7 @@ func alterTrimpath(flags []string) []string { return flagSetValue(flags, "-trimpath", sharedTempDir+"=>;"+trimpath) } -// forwardBuildFlags is obtained from 'go help build' as of Go 1.20. +// forwardBuildFlags is obtained from 'go help build' as of Go 1.21. var forwardBuildFlags = map[string]bool{ // These shouldn't be used in nested cmd/go calls. "-a": false, @@ -2235,7 +2235,7 @@ var forwardBuildFlags = map[string]bool{ "-workfile": true, } -// booleanFlags is obtained from 'go help build' and 'go help testflag' as of Go 1.20. +// booleanFlags is obtained from 'go help build' and 'go help testflag' as of Go 1.21. var booleanFlags = map[string]bool{ // Shared build flags. "-a": true, diff --git a/runtime_patch.go b/runtime_patch.go index f47bf90..df240f7 100644 --- a/runtime_patch.go +++ b/runtime_patch.go @@ -9,8 +9,6 @@ import ( "strconv" "strings" - "golang.org/x/mod/semver" - ah "mvdan.cc/garble/internal/asthelper" ) @@ -238,11 +236,7 @@ func stripRuntime(basename string, file *ast.File) { "printAncestorTracebackFuncInfo", "goroutineheader", "tracebackothers", "tracebackHexdump", "printCgoTraceback": funcDecl.Body.List = nil case "printOneCgoTraceback": - if semver.Compare(sharedCache.GoVersionSemver, "v1.21") >= 0 { - funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ast.NewIdent("false"))) - } else { - funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ah.IntLit(0))) - } + funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ast.NewIdent("false"))) default: if strings.HasPrefix(funcDecl.Name.Name, "print") { funcDecl.Body.List = nil diff --git a/shared.go b/shared.go index 2ebc2df..b4f5172 100644 --- a/shared.go +++ b/shared.go @@ -53,8 +53,8 @@ type sharedCacheType struct { // GoVersionSemver is a semver-compatible version of the Go toolchain // currently being used, as reported by "go env GOVERSION". // Note that the version of Go that built the garble binary might be newer. - // Also note that a devel version like "go1.21-231f290e51" is - // currently represented as "v1.21". + // Also note that a devel version like "go1.22-231f290e51" is + // currently represented as "v1.22". GoVersionSemver string // Filled directly from "go env". @@ -266,8 +266,6 @@ func appendListedPackages(packages []string, mainBuild bool) error { // Some packages in runtimeLinknamed 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 pkg.ImportPath == "maps" && semver.Compare(sharedCache.GoVersionSemver, "v1.21") < 0 { - // added in Go 1.21, so Go 1.20 runs into a "not found" error. } else if pkg.ImportPath == "math/rand/v2" && semver.Compare(sharedCache.GoVersionSemver, "v1.22") < 0 { // added in Go 1.22, so Go 1.21 runs into a "not found" error. } else { diff --git a/testdata/script/asm.txtar b/testdata/script/asm.txtar index f088370..59e8a77 100644 --- a/testdata/script/asm.txtar +++ b/testdata/script/asm.txtar @@ -33,7 +33,7 @@ binsubstr main$exe 'addJmp' 'AddImpl' -- go.mod -- module test/with.many.dots/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/atomic.txtar b/testdata/script/atomic.txtar index 8e14e19..ffc2d65 100644 --- a/testdata/script/atomic.txtar +++ b/testdata/script/atomic.txtar @@ -18,7 +18,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/basic.txtar b/testdata/script/basic.txtar index b36dfb2..caf0c2a 100644 --- a/testdata/script/basic.txtar +++ b/testdata/script/basic.txtar @@ -59,7 +59,7 @@ binsubstr main$exe 'garble_main.go' 'globalVar' 'globalFunc' $gofullversion -- go.mod -- module test/mainfoo -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/cache.txtar b/testdata/script/cache.txtar index 317fbb0..2879472 100644 --- a/testdata/script/cache.txtar +++ b/testdata/script/cache.txtar @@ -28,7 +28,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/cgo.txtar b/testdata/script/cgo.txtar index ff2b207..c02fa95 100644 --- a/testdata/script/cgo.txtar +++ b/testdata/script/cgo.txtar @@ -29,7 +29,7 @@ binsubstr main$exe 'privateAdd' -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/crossbuild.txtar b/testdata/script/crossbuild.txtar index aa08ca5..75f47b9 100644 --- a/testdata/script/crossbuild.txtar +++ b/testdata/script/crossbuild.txtar @@ -21,7 +21,7 @@ stderr 'intrinsic substitution for Len64.*BitLen64' -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/ctrlflow.txtar b/testdata/script/ctrlflow.txtar index 3add8fa..085b12d 100644 --- a/testdata/script/ctrlflow.txtar +++ b/testdata/script/ctrlflow.txtar @@ -30,7 +30,7 @@ grep 'func\(int\) int' $WORK/debug/test/main/GARBLE_controlflow.go -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/debugdir.txtar b/testdata/script/debugdir.txtar index 8a5271b..48825f4 100644 --- a/testdata/script/debugdir.txtar +++ b/testdata/script/debugdir.txtar @@ -18,7 +18,7 @@ stderr 'test/main' # we force rebuilds with -debugdir -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/embed.txtar b/testdata/script/embed.txtar index 0b7ef3e..bf2c097 100644 --- a/testdata/script/embed.txtar +++ b/testdata/script/embed.txtar @@ -11,7 +11,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/goenv.txtar b/testdata/script/goenv.txtar index 50bf17a..3e44b86 100644 --- a/testdata/script/goenv.txtar +++ b/testdata/script/goenv.txtar @@ -46,7 +46,7 @@ exec $NAME/garble$exe build -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/gogarble.txtar b/testdata/script/gogarble.txtar index f5110ac..3d9dab3 100644 --- a/testdata/script/gogarble.txtar +++ b/testdata/script/gogarble.txtar @@ -54,7 +54,7 @@ bincmp out_rebuild out -- go.mod -- module test/main -go 1.20 +go 1.21 -- standalone/main.go -- package main diff --git a/testdata/script/goversion.txtar b/testdata/script/goversion.txtar index c34a265..0a457e1 100644 --- a/testdata/script/goversion.txtar +++ b/testdata/script/goversion.txtar @@ -40,45 +40,45 @@ env TOOLCHAIN_GOVERSION='go1.28.2' stderr 'mocking the real build' # We should accept custom devel strings. -env TOOLCHAIN_GOVERSION='devel go1.20-somecustomversion' +env TOOLCHAIN_GOVERSION='devel go1.22-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.21' -env TOOLCHAIN_GOVERSION='go1.20.3' +env GARBLE_TEST_GOVERSION='go1.22' +env TOOLCHAIN_GOVERSION='go1.21.3' ! exec garble build stderr 'mocking the real build' # The current toolchain may be equal to the one that built garble. -env GARBLE_TEST_GOVERSION='devel go1.20-6673d5d701 Sun Mar 20 16:05:03 2023 +0000' -env TOOLCHAIN_GOVERSION='devel go1.20-6673d5d701 Sun Mar 20 16:05:03 2023 +0000' +env GARBLE_TEST_GOVERSION='devel go1.21-6673d5d701 Sun Mar 20 16:05:03 2023 +0000' +env TOOLCHAIN_GOVERSION='devel go1.21-6673d5d701 Sun Mar 20 16:05:03 2023 +0000' ! 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.20.1' +env TOOLCHAIN_GOVERSION='go1.21.1' ! exec garble build -stderr 'garble was built with "go1\.18" and is being used with "go1\.20\.1"; rebuild ' +stderr 'garble was built with "go1\.18" and is being used with "go1\.21\.1"; 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.20.11' -env TOOLCHAIN_GOVERSION='go1.20.14' +env GARBLE_TEST_GOVERSION='go1.21.11' +env TOOLCHAIN_GOVERSION='go1.21.14' ! exec garble build -stderr 'garble was built with "go1\.20\.11" and is being used with "go1\.20\.14"; rebuild ' +stderr 'garble was built with "go1\.21\.11" and is being used with "go1\.21\.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.20.3' +env TOOLCHAIN_GOVERSION='go1.21.3' ! exec garble build stderr 'mocking the real build' -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/help.txtar b/testdata/script/help.txtar index 56cfc5a..5d627ae 100644 --- a/testdata/script/help.txtar +++ b/testdata/script/help.txtar @@ -78,8 +78,7 @@ stderr 'must precede command, like: garble -seed=random build \./pkg' stderr 'did you run.*instead of "garble \[command\]"' ! exec garble build badpackage -[!go1.21] stderr 'package badpackage is not in GOROOT' -[go1.21] stderr 'package badpackage is not in std' +stderr 'package badpackage is not in std' ! stdout . ! exec garble build ./badpackage @@ -118,6 +117,6 @@ stderr 'usage: garble version' -- go.mod -- module dummy -go 1.20 +go 1.21 -- dummy.go -- package dummy diff --git a/testdata/script/implement.txtar b/testdata/script/implement.txtar index c62c8a9..13fc909 100644 --- a/testdata/script/implement.txtar +++ b/testdata/script/implement.txtar @@ -13,7 +13,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/imports.txtar b/testdata/script/imports.txtar index 6992545..73cff4b 100644 --- a/testdata/script/imports.txtar +++ b/testdata/script/imports.txtar @@ -42,7 +42,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.20 +go 1.21 require ( gopkg.in/garbletest.v2 v2.999.0 diff --git a/testdata/script/init.txtar b/testdata/script/init.txtar index ac1f51c..f1a0d5b 100644 --- a/testdata/script/init.txtar +++ b/testdata/script/init.txtar @@ -12,7 +12,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/ldflags.txtar b/testdata/script/ldflags.txtar index d40b6d5..a6f2e28 100644 --- a/testdata/script/ldflags.txtar +++ b/testdata/script/ldflags.txtar @@ -28,7 +28,7 @@ binsubstr main$exe 'unexportedVersion' 'ExportedUnset' 'v1.22.33' 'garble_replac -- go.mod -- module domain.test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/linker.txtar b/testdata/script/linker.txtar index ebda394..3afa716 100644 --- a/testdata/script/linker.txtar +++ b/testdata/script/linker.txtar @@ -34,7 +34,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/linkname.txtar b/testdata/script/linkname.txtar index a2ee29a..bc0fa48 100644 --- a/testdata/script/linkname.txtar +++ b/testdata/script/linkname.txtar @@ -14,7 +14,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 replace big.chungus/meme => ./big.chungus/meme @@ -149,7 +149,7 @@ func ByteIndex(s string, c byte) int -- big.chungus/meme/go.mod -- module test/main -go 1.20 +go 1.21 -- big.chungus/meme/dante.go -- package meme diff --git a/testdata/script/list_error.txtar b/testdata/script/list_error.txtar index 43f730e..9fa3bad 100644 --- a/testdata/script/list_error.txtar +++ b/testdata/script/list_error.txtar @@ -1,19 +1,14 @@ ! exec garble build ./... -[!go1.21] cmpenv stderr stderr-go1.20.golden -[go1.21] cmpenv stderr stderr-go1.21.golden +cmpenv stderr stderr.golden --- stderr-go1.20.golden -- -# test/main/broken -broken${/}broken.go:5:16: cannot use 123 (untyped int constant) as string value in variable declaration -imports_missing${/}imports.go:5:8: package test/main/missing is not in GOROOT (${GOROOT}${/}src${/}test${/}main${/}missing) --- stderr-go1.21.golden -- +-- stderr.golden -- # test/main/broken broken${/}broken.go:5:16: cannot use 123 (untyped int constant) as string value in variable declaration imports_missing${/}imports.go:5:8: package test/main/missing is not in std (${GOROOT}${/}src${/}test${/}main${/}missing) -- go.mod -- module test/main -go 1.20 +go 1.21 -- broken/broken.go -- package broken diff --git a/testdata/script/literals.txtar b/testdata/script/literals.txtar index c23a06e..e84becd 100644 --- a/testdata/script/literals.txtar +++ b/testdata/script/literals.txtar @@ -59,7 +59,7 @@ exec garble -literals build std -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/modinfo.txtar b/testdata/script/modinfo.txtar index c34d663..32a6d32 100644 --- a/testdata/script/modinfo.txtar +++ b/testdata/script/modinfo.txtar @@ -26,7 +26,7 @@ stdout 'build\s*vcs.revision='${HEAD_COMMIT_SHA} -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/plugin.txtar b/testdata/script/plugin.txtar index 0b29c40..c33f541 100644 --- a/testdata/script/plugin.txtar +++ b/testdata/script/plugin.txtar @@ -26,7 +26,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- plugin/main.go -- package main diff --git a/testdata/script/position.txtar b/testdata/script/position.txtar index e02ca72..52919ea 100644 --- a/testdata/script/position.txtar +++ b/testdata/script/position.txtar @@ -16,7 +16,7 @@ stdout 'varPositions is sorted' -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/reflect.txtar b/testdata/script/reflect.txtar index aa932e4..354f7c0 100644 --- a/testdata/script/reflect.txtar +++ b/testdata/script/reflect.txtar @@ -14,7 +14,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/reverse.txtar b/testdata/script/reverse.txtar index 27e588c..3d22413 100644 --- a/testdata/script/reverse.txtar +++ b/testdata/script/reverse.txtar @@ -53,7 +53,7 @@ cmp stdout main-literals.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- long_main.go -- package main diff --git a/testdata/script/run.txtar b/testdata/script/run.txtar index 74b8fe0..0b9adac 100644 --- a/testdata/script/run.txtar +++ b/testdata/script/run.txtar @@ -14,7 +14,7 @@ stdout 'garble_main\.go 9$' -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/seed-cache.txtar b/testdata/script/seed-cache.txtar index 6164244..ac93458 100644 --- a/testdata/script/seed-cache.txtar +++ b/testdata/script/seed-cache.txtar @@ -32,7 +32,7 @@ cd .. -- mod1/go.mod -- module test/main/mod1 -go 1.20 +go 1.21 require gopkg.in/garbletest.v2 v2.999.0 @@ -52,7 +52,7 @@ func main() { garbletest.Test() } -- mod2/go.mod -- module test/main/mod2 -go 1.20 +go 1.21 require gopkg.in/garbletest.v2 v2.999.0 diff --git a/testdata/script/seed.txtar b/testdata/script/seed.txtar index f461e20..cd4179b 100644 --- a/testdata/script/seed.txtar +++ b/testdata/script/seed.txtar @@ -97,7 +97,7 @@ cmp stderr importedpkg.stderr -- go.mod -- module test/main -go 1.20 +go 1.21 -- main.go -- package main diff --git a/testdata/script/syntax.txtar b/testdata/script/syntax.txtar index cfdaf8e..94743f6 100644 --- a/testdata/script/syntax.txtar +++ b/testdata/script/syntax.txtar @@ -16,7 +16,7 @@ binsubstr main$exe 'globalVar' # 'globalType' matches on some, but not all, plat -- extra/go.mod -- module private.source/extra -go 1.20 +go 1.21 -- extra/extra.go -- package extra @@ -26,7 +26,7 @@ func Func() string { -- go.mod -- module test/main -go 1.20 +go 1.21 // We include an extra module to obfuscate, included in the same original source // code via a replace directive. diff --git a/testdata/script/test.txtar b/testdata/script/test.txtar index f6edbfe..ad312b1 100644 --- a/testdata/script/test.txtar +++ b/testdata/script/test.txtar @@ -52,7 +52,7 @@ stdout 'package bar_test, func name: test/bar\.OriginalFuncName' -- go.mod -- module test/bar -go 1.20 +go 1.21 -- bar.go -- package bar diff --git a/testdata/script/tiny.txtar b/testdata/script/tiny.txtar index 015eb35..108c3f4 100644 --- a/testdata/script/tiny.txtar +++ b/testdata/script/tiny.txtar @@ -27,7 +27,7 @@ stderr 'funcStructExported false funcStructUnexported false' -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main diff --git a/testdata/script/typeparams.txtar b/testdata/script/typeparams.txtar index d7728d4..bbb6d3f 100644 --- a/testdata/script/typeparams.txtar +++ b/testdata/script/typeparams.txtar @@ -3,7 +3,7 @@ exec garble build -- go.mod -- module test/main -go 1.20 +go 1.21 -- garble_main.go -- package main