drop support for Go 1.20

Go 1.21.0 was released in August 2023, so our upcoming release
will no longer support the Go 1.20 release series.

The first Go 1.22 release candidate is also due in December 2023,
less than a month from now, so dropping 1.20 will simplify 1.22 work.
pull/805/head
Daniel Martí 6 months ago committed by pagran
parent abcdc1fcbf
commit 126618a0d5

@ -25,7 +25,7 @@ jobs:
test: test:
strategy: strategy:
matrix: matrix:
go-version: [1.20.x, 1.21.x] go-version: [1.21.x]
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

@ -1,6 +1,6 @@
module mvdan.cc/garble module mvdan.cc/garble
go 1.20 go 1.21
require ( require (
github.com/bluekeyes/go-gitdiff v0.7.1 github.com/bluekeyes/go-gitdiff v0.7.1

@ -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 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 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 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 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=

@ -267,7 +267,7 @@ func (e errJustExit) Error() string { return fmt.Sprintf("exit: %d", e) }
func goVersionOK() bool { func goVersionOK() bool {
const ( const (
minGoVersionSemver = "v1.20.0" minGoVersionSemver = "v1.21.0"
suggestedGoVersion = "1.21" suggestedGoVersion = "1.21"
) )
@ -1329,7 +1329,7 @@ func (tf *transformer) processImportCfg(flags []string, requiredPkgs []string) (
// See exporttest/*.go in testdata/scripts/test.txt. // See exporttest/*.go in testdata/scripts/test.txt.
// For now, spot the pattern and avoid the unnecessary error; // For now, spot the pattern and avoid the unnecessary error;
// the dependency is unused, so the packagefile line is redundant. // 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) { if strings.HasSuffix(tf.curPkg.ImportPath, ".test]") && strings.HasPrefix(tf.curPkg.ImportPath, impPath) {
continue continue
} }
@ -2195,7 +2195,7 @@ func alterTrimpath(flags []string) []string {
return flagSetValue(flags, "-trimpath", sharedTempDir+"=>;"+trimpath) 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{ var forwardBuildFlags = map[string]bool{
// These shouldn't be used in nested cmd/go calls. // These shouldn't be used in nested cmd/go calls.
"-a": false, "-a": false,
@ -2235,7 +2235,7 @@ var forwardBuildFlags = map[string]bool{
"-workfile": true, "-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{ var booleanFlags = map[string]bool{
// Shared build flags. // Shared build flags.
"-a": true, "-a": true,

@ -9,8 +9,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"golang.org/x/mod/semver"
ah "mvdan.cc/garble/internal/asthelper" ah "mvdan.cc/garble/internal/asthelper"
) )
@ -238,11 +236,7 @@ func stripRuntime(basename string, file *ast.File) {
"printAncestorTracebackFuncInfo", "goroutineheader", "tracebackothers", "tracebackHexdump", "printCgoTraceback": "printAncestorTracebackFuncInfo", "goroutineheader", "tracebackothers", "tracebackHexdump", "printCgoTraceback":
funcDecl.Body.List = nil funcDecl.Body.List = nil
case "printOneCgoTraceback": case "printOneCgoTraceback":
if semver.Compare(sharedCache.GoVersionSemver, "v1.21") >= 0 { funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ast.NewIdent("false")))
funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ast.NewIdent("false")))
} else {
funcDecl.Body = ah.BlockStmt(ah.ReturnStmt(ah.IntLit(0)))
}
default: default:
if strings.HasPrefix(funcDecl.Name.Name, "print") { if strings.HasPrefix(funcDecl.Name.Name, "print") {
funcDecl.Body.List = nil funcDecl.Body.List = nil

@ -53,8 +53,8 @@ type sharedCacheType struct {
// GoVersionSemver is a semver-compatible version of the Go toolchain // GoVersionSemver is a semver-compatible version of the Go toolchain
// currently being used, as reported by "go env GOVERSION". // currently being used, as reported by "go env GOVERSION".
// Note that the version of Go that built the garble binary might be newer. // 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 // Also note that a devel version like "go1.22-231f290e51" is
// currently represented as "v1.21". // currently represented as "v1.22".
GoVersionSemver string GoVersionSemver string
// Filled directly from "go env". // 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, // Some packages in runtimeLinknamed need a build tag to be importable,
// like crypto/internal/boring/fipstls with boringcrypto, // like crypto/internal/boring/fipstls with boringcrypto,
// so any pkg.Error should be ignored when the build tag isn't set. // 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 { } 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. // added in Go 1.22, so Go 1.21 runs into a "not found" error.
} else { } else {

@ -33,7 +33,7 @@ binsubstr main$exe 'addJmp' 'AddImpl'
-- go.mod -- -- go.mod --
module test/with.many.dots/main module test/with.many.dots/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -18,7 +18,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -59,7 +59,7 @@ binsubstr main$exe 'garble_main.go' 'globalVar' 'globalFunc' $gofullversion
-- go.mod -- -- go.mod --
module test/mainfoo module test/mainfoo
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -28,7 +28,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -29,7 +29,7 @@ binsubstr main$exe 'privateAdd'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -21,7 +21,7 @@ stderr 'intrinsic substitution for Len64.*BitLen64'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -30,7 +30,7 @@ grep 'func\(int\) int' $WORK/debug/test/main/GARBLE_controlflow.go
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -18,7 +18,7 @@ stderr 'test/main' # we force rebuilds with -debugdir
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -11,7 +11,7 @@ cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -46,7 +46,7 @@ exec $NAME/garble$exe build
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -54,7 +54,7 @@ bincmp out_rebuild out
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- standalone/main.go -- -- standalone/main.go --
package main package main

@ -40,45 +40,45 @@ env TOOLCHAIN_GOVERSION='go1.28.2'
stderr 'mocking the real build' stderr 'mocking the real build'
# We should accept custom devel strings. # We should accept custom devel strings.
env TOOLCHAIN_GOVERSION='devel go1.20-somecustomversion' env TOOLCHAIN_GOVERSION='devel go1.22-somecustomversion'
! exec garble build ! exec garble build
stderr 'mocking the real build' stderr 'mocking the real build'
# The current toolchain may be older than the one that built garble. # The current toolchain may be older than the one that built garble.
env GARBLE_TEST_GOVERSION='go1.21' env GARBLE_TEST_GOVERSION='go1.22'
env TOOLCHAIN_GOVERSION='go1.20.3' env TOOLCHAIN_GOVERSION='go1.21.3'
! exec garble build ! exec garble build
stderr 'mocking the real build' stderr 'mocking the real build'
# The current toolchain may be equal to the one that built garble. # 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 GARBLE_TEST_GOVERSION='devel go1.21-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 TOOLCHAIN_GOVERSION='devel go1.21-6673d5d701 Sun Mar 20 16:05:03 2023 +0000'
! exec garble build ! exec garble build
stderr 'mocking the real build' stderr 'mocking the real build'
# The current toolchain must not be newer than the one that built garble. # The current toolchain must not be newer than the one that built garble.
env GARBLE_TEST_GOVERSION='go1.18' env GARBLE_TEST_GOVERSION='go1.18'
env TOOLCHAIN_GOVERSION='go1.20.1' env TOOLCHAIN_GOVERSION='go1.21.1'
! exec garble build ! 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. # 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. # 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 GARBLE_TEST_GOVERSION='go1.21.11'
env TOOLCHAIN_GOVERSION='go1.20.14' env TOOLCHAIN_GOVERSION='go1.21.14'
! exec garble build ! 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. # 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. # As a fallback, we drop the comparison against the toolchain's version.
env GARBLE_TEST_GOVERSION='bogus version' env GARBLE_TEST_GOVERSION='bogus version'
env TOOLCHAIN_GOVERSION='go1.20.3' env TOOLCHAIN_GOVERSION='go1.21.3'
! exec garble build ! exec garble build
stderr 'mocking the real build' stderr 'mocking the real build'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -78,8 +78,7 @@ stderr 'must precede command, like: garble -seed=random build \./pkg'
stderr 'did you run.*instead of "garble \[command\]"' stderr 'did you run.*instead of "garble \[command\]"'
! exec garble build badpackage ! exec garble build badpackage
[!go1.21] stderr 'package badpackage is not in GOROOT' stderr 'package badpackage is not in std'
[go1.21] stderr 'package badpackage is not in std'
! stdout . ! stdout .
! exec garble build ./badpackage ! exec garble build ./badpackage
@ -118,6 +117,6 @@ stderr 'usage: garble version'
-- go.mod -- -- go.mod --
module dummy module dummy
go 1.20 go 1.21
-- dummy.go -- -- dummy.go --
package dummy package dummy

@ -13,7 +13,7 @@ cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -42,7 +42,7 @@ cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
require ( require (
gopkg.in/garbletest.v2 v2.999.0 gopkg.in/garbletest.v2 v2.999.0

@ -12,7 +12,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -28,7 +28,7 @@ binsubstr main$exe 'unexportedVersion' 'ExportedUnset' 'v1.22.33' 'garble_replac
-- go.mod -- -- go.mod --
module domain.test/main module domain.test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -34,7 +34,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -14,7 +14,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
replace big.chungus/meme => ./big.chungus/meme replace big.chungus/meme => ./big.chungus/meme
@ -149,7 +149,7 @@ func ByteIndex(s string, c byte) int
-- big.chungus/meme/go.mod -- -- big.chungus/meme/go.mod --
module test/main module test/main
go 1.20 go 1.21
-- big.chungus/meme/dante.go -- -- big.chungus/meme/dante.go --
package meme package meme

@ -1,19 +1,14 @@
! exec garble build ./... ! exec garble build ./...
[!go1.21] cmpenv stderr stderr-go1.20.golden cmpenv stderr stderr.golden
[go1.21] cmpenv stderr stderr-go1.21.golden
-- stderr-go1.20.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 GOROOT (${GOROOT}${/}src${/}test${/}main${/}missing)
-- stderr-go1.21.golden --
# test/main/broken # test/main/broken
broken${/}broken.go:5:16: cannot use 123 (untyped int constant) as string value in variable declaration 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) imports_missing${/}imports.go:5:8: package test/main/missing is not in std (${GOROOT}${/}src${/}test${/}main${/}missing)
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- broken/broken.go -- -- broken/broken.go --
package broken package broken

@ -59,7 +59,7 @@ exec garble -literals build std
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -26,7 +26,7 @@ stdout 'build\s*vcs.revision='${HEAD_COMMIT_SHA}
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -26,7 +26,7 @@ cmp stderr main.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- plugin/main.go -- -- plugin/main.go --
package main package main

@ -16,7 +16,7 @@ stdout 'varPositions is sorted'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -14,7 +14,7 @@ cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -53,7 +53,7 @@ cmp stdout main-literals.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- long_main.go -- -- long_main.go --
package main package main

@ -14,7 +14,7 @@ stdout 'garble_main\.go 9$'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -32,7 +32,7 @@ cd ..
-- mod1/go.mod -- -- mod1/go.mod --
module test/main/mod1 module test/main/mod1
go 1.20 go 1.21
require gopkg.in/garbletest.v2 v2.999.0 require gopkg.in/garbletest.v2 v2.999.0
@ -52,7 +52,7 @@ func main() { garbletest.Test() }
-- mod2/go.mod -- -- mod2/go.mod --
module test/main/mod2 module test/main/mod2
go 1.20 go 1.21
require gopkg.in/garbletest.v2 v2.999.0 require gopkg.in/garbletest.v2 v2.999.0

@ -97,7 +97,7 @@ cmp stderr importedpkg.stderr
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- main.go -- -- main.go --
package main package main

@ -16,7 +16,7 @@ binsubstr main$exe 'globalVar' # 'globalType' matches on some, but not all, plat
-- extra/go.mod -- -- extra/go.mod --
module private.source/extra module private.source/extra
go 1.20 go 1.21
-- extra/extra.go -- -- extra/extra.go --
package extra package extra
@ -26,7 +26,7 @@ func Func() string {
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
// We include an extra module to obfuscate, included in the same original source // We include an extra module to obfuscate, included in the same original source
// code via a replace directive. // code via a replace directive.

@ -52,7 +52,7 @@ stdout 'package bar_test, func name: test/bar\.OriginalFuncName'
-- go.mod -- -- go.mod --
module test/bar module test/bar
go 1.20 go 1.21
-- bar.go -- -- bar.go --
package bar package bar

@ -27,7 +27,7 @@ stderr 'funcStructExported false funcStructUnexported false'
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

@ -3,7 +3,7 @@ exec garble build
-- go.mod -- -- go.mod --
module test/main module test/main
go 1.20 go 1.21
-- garble_main.go -- -- garble_main.go --
package main package main

Loading…
Cancel
Save