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:
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:

@ -1,6 +1,6 @@
module mvdan.cc/garble
go 1.20
go 1.21
require (
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/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=

@ -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,

@ -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

@ -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 {

@ -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

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

@ -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

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

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

@ -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

@ -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

@ -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

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

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

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

@ -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

@ -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

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

@ -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

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

@ -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

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

@ -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

@ -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

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

@ -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

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

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

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

@ -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

@ -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

@ -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

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

@ -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.

@ -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

@ -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

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

Loading…
Cancel
Save