diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67fe24c..8bec42b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: test: strategy: matrix: - go-version: [1.15.x, 1.16.x] + go-version: [1.16.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/README.md b/README.md index d111c46..e74a3de 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ GO111MODULE=on go get mvdan.cc/garble -Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.15 or later. +Obfuscate Go code by wrapping the Go toolchain. Requires Go 1.16 or later. garble build [build flags] [packages] @@ -41,12 +41,12 @@ what packages to obfuscate, set `GOPRIVATE`, documented at `go help private`. Note that commands like `garble build` will use the `go` version found in your `$PATH`. To use different versions of Go, you can [install them](https://golang.org/doc/manage-install#installing-multiple) -and set up `$PATH` with them. For example, for Go 1.15.8: +and set up `$PATH` with them. For example, for Go 1.16.1: ```sh -$ go get golang.org/dl/go1.15.8 -$ go1.15.8 download -$ PATH=$(go1.15.8 env GOROOT)/bin:${PATH} garble build +$ go get golang.org/dl/go1.16.1 +$ go1.16.1 download +$ PATH=$(go1.16.1 env GOROOT)/bin:${PATH} garble build ``` You can also declare a function to make multiple uses simpler: @@ -58,7 +58,7 @@ $ withgo() { PATH=$(${gocmd} env GOROOT)/bin:${PATH} "$@" } -$ withgo 1.15.8 garble build +$ withgo 1.16.1 garble build ``` ### Caveats diff --git a/go.mod b/go.mod index 6d5816c..b644b6c 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module mvdan.cc/garble -go 1.15 +go 1.16 require ( - github.com/google/go-cmp v0.5.4 + github.com/google/go-cmp v0.5.5 github.com/rogpeppe/go-internal v1.7.1-0.20210131190821-dc4b49510d96 golang.org/x/mod v0.4.1 - golang.org/x/tools v0.0.0-20210115202250-e0d201561e39 + golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9 ) diff --git a/go.sum b/go.sum index 6f9f6b0..fa5b8db 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -11,7 +11,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -22,12 +21,13 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20210115202250-e0d201561e39 h1:BTs2GMGSMWpgtCpv1CE7vkJTv7XcHdcLLnAMu7UbgTY= -golang.org/x/tools v0.0.0-20210115202250-e0d201561e39/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9 h1:lQ9QDTM4SHDP/S/bmj2wjNMQ93AvRYf7kuoqr2MDxmc= +golang.org/x/tools v0.1.1-0.20210304221016-50ca8d007de9/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index 34b204f..7f4be49 100644 --- a/main.go +++ b/main.go @@ -166,13 +166,13 @@ var errJustExit = errors.New("") func goVersionOK() bool { const ( - minGoVersion = "v1.15.0" + minGoVersion = "v1.16.0" suggestedGoVersion = "1.16.x" gitTimeFormat = "Mon Jan 2 15:04:05 2006 -0700" ) - // Go 1.15 was released on August 11th, 2020. - minGoVersionDate := time.Date(2020, 8, 11, 0, 0, 0, 0, time.UTC) + // Go 1.16 was released on Febuary 16th, 2021. + minGoVersionDate := time.Date(2021, 2, 16, 0, 0, 0, 0, time.UTC) out, err := exec.Command("go", "version").CombinedOutput() rawVersion := strings.TrimSpace(string(out)) @@ -811,21 +811,13 @@ var runtimeRelated = map[string]bool{ "vendor/golang.org/x/net/dns/dnsmessage": true, "vendor/golang.org/x/net/route": true, - // These packages were moved in Go 1.16, but 1.15's runtime still - // linknames to them. - "io/ioutil": true, - "path/filepath": true, - - // Go 1.15's "net" package depends on "math/rand", but 1.16's does not. - // Keep it here to support 1.15. - "math/rand": true, - // These packages call pure Go functions from assembly functions. // We obfuscate the pure Go function name, breaking the assembly. // We do not deal with that edge case just yet, so for now, // never obfuscate these packages. // TODO: remove once we fix issue 261. "math/big": true, + "math/rand": true, "crypto/sha512": true, "crypto": true, } diff --git a/main_test.go b/main_test.go index e40d23d..1d5b685 100644 --- a/main_test.go +++ b/main_test.go @@ -60,7 +60,6 @@ func TestScripts(t *testing.T) { env.Vars = append(env.Vars, "GOPROXY="+proxyURL, "GONOSUMDB=*", - "GOFLAGS=-mod=readonly", // TODO(mvdan): remove once we switch to Go 1.16 "gofullversion="+runtime.Version(), ) diff --git a/runtime_strip.go b/runtime_strip.go index ac78644..1448070 100644 --- a/runtime_strip.go +++ b/runtime_strip.go @@ -123,7 +123,6 @@ func stripRuntime(filename string, file *ast.File) { case "runtime1.go": // On Go 1.16.x, the code above results in runtime1.go having an // unused import. Mark it as used via "var _ = pkg.Func". - // Note that the file in Go 1.15.x does not import bytealg. // If this is a recurring problem, we could go for a more // generic solution like x/tools/imports. for _, imp := range file.Imports { diff --git a/shared.go b/shared.go index 0877b3f..369e955 100644 --- a/shared.go +++ b/shared.go @@ -218,15 +218,7 @@ func setListedPackages(patterns []string) error { return err } if pkg.Export != "" { - buildID := pkg.BuildID - if buildID == "" { - // go list only includes BuildID in 1.16+ - buildID, err = buildidOf(pkg.Export) - if err != nil { - panic(err) // shouldn't happen - } - } - actionID := decodeHash(splitActionID(buildID)) + actionID := decodeHash(splitActionID(pkg.BuildID)) h := sha256.New() h.Write(actionID) h.Write(cache.BinaryContentID) diff --git a/testdata/scripts/asm.txt b/testdata/scripts/asm.txt index 47b5b9e..522d861 100644 --- a/testdata/scripts/asm.txt +++ b/testdata/scripts/asm.txt @@ -19,7 +19,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/basic.txt b/testdata/scripts/basic.txt index ee2dbc2..604805d 100644 --- a/testdata/scripts/basic.txt +++ b/testdata/scripts/basic.txt @@ -58,7 +58,7 @@ binsubstr main$exe 'main.go' 'globalVar' 'globalFunc' $gofullversion -- go.mod -- module test/mainfoo -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/cgo.txt b/testdata/scripts/cgo.txt index 99369e2..409253c 100644 --- a/testdata/scripts/cgo.txt +++ b/testdata/scripts/cgo.txt @@ -19,7 +19,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/debugdir.txt b/testdata/scripts/debugdir.txt index ef575a2..8243200 100644 --- a/testdata/scripts/debugdir.txt +++ b/testdata/scripts/debugdir.txt @@ -18,7 +18,7 @@ stderr 'test/main' # we force rebuilds with -debugdir -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/goprivate.txt b/testdata/scripts/goprivate.txt index 9a6c0b4..39c42bf 100644 --- a/testdata/scripts/goprivate.txt +++ b/testdata/scripts/goprivate.txt @@ -26,7 +26,7 @@ garble build -o=out ./stdimporter -- go.mod -- module test/main -go 1.15 +go 1.16 -- standalone/main.go -- package main diff --git a/testdata/scripts/goversion.txt b/testdata/scripts/goversion.txt index 7873b34..58eba11 100644 --- a/testdata/scripts/goversion.txt +++ b/testdata/scripts/goversion.txt @@ -20,13 +20,12 @@ env GO_VERSION='go version devel +afb5fca Sun Sep 99 99:99:99 9999 +0000 linux/a stderr 'Can''t recognize devel build timestamp: parsing time' # We should error on a devel version that's too old. -# We support Go 1.15 and later, released on August 11th, 2020. env GO_VERSION='go version devel +afb5fca Sun Aug 07 00:00:00 2020 +0000 linux/amd64' ! garble build stderr 'Go version.*Aug 07.*too old; please upgrade to Go 1.16.x or a newer devel version' -# A recent enough devel timestamp should be fine. -env GO_VERSION='go version devel +afb5fca Sun Sep 13 07:54:42 2020 +0000 linux/amd64' +# A future devel timestamp should be fine. +env GO_VERSION='go version devel +afb5fca Sun Sep 13 07:54:42 2021 +0000 linux/amd64' ! garble build stderr 'mocking the real build' @@ -36,15 +35,15 @@ env GO_VERSION='go version go1.14 windows/amd64' stderr 'Go version.*go1.14.*too old; please upgrade to Go 1.16.x' ! stderr 'or a newer devel version' -# We should accept a supported stable version. -env GO_VERSION='go version go1.15.2 windows/amd64' +# We should accept a future stable version. +env GO_VERSION='go version go1.16.2 windows/amd64' ! garble build stderr 'mocking the real build' -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/implement.txt b/testdata/scripts/implement.txt index 44a7a6d..06ce3f8 100644 --- a/testdata/scripts/implement.txt +++ b/testdata/scripts/implement.txt @@ -9,7 +9,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/imports.txt b/testdata/scripts/imports.txt index f47f279..41b3248 100644 --- a/testdata/scripts/imports.txt +++ b/testdata/scripts/imports.txt @@ -45,7 +45,7 @@ cmp stdout main.stdout -- go.mod -- module test/main -go 1.15 +go 1.16 require ( rsc.io/quote v1.5.2 diff --git a/testdata/scripts/init.txt b/testdata/scripts/init.txt index a9ccc51..f3364d2 100644 --- a/testdata/scripts/init.txt +++ b/testdata/scripts/init.txt @@ -13,7 +13,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/ldflags.txt b/testdata/scripts/ldflags.txt index 3a7acc0..c76fe31 100644 --- a/testdata/scripts/ldflags.txt +++ b/testdata/scripts/ldflags.txt @@ -23,7 +23,7 @@ binsubstr main$exe 'unexportedVersion' -- go.mod -- module domain.test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/linkname.txt b/testdata/scripts/linkname.txt index 7333af6..ef78e57 100644 --- a/testdata/scripts/linkname.txt +++ b/testdata/scripts/linkname.txt @@ -15,7 +15,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/literals.txt b/testdata/scripts/literals.txt index fb88970..8514ee5 100644 --- a/testdata/scripts/literals.txt +++ b/testdata/scripts/literals.txt @@ -55,7 +55,7 @@ grep '^\s+type \w+ func\(byte\) \w+$' .obf-src/main/extra_literals.go -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/modinfo.txt b/testdata/scripts/modinfo.txt index 614f2dc..970ba40 100644 --- a/testdata/scripts/modinfo.txt +++ b/testdata/scripts/modinfo.txt @@ -15,7 +15,7 @@ binsubstr main$exe '(devel)' -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/plugin.txt b/testdata/scripts/plugin.txt index 11a677d..762eabb 100644 --- a/testdata/scripts/plugin.txt +++ b/testdata/scripts/plugin.txt @@ -29,7 +29,7 @@ cmp stderr main.stderr -- go.mod -- module test/main -go 1.15 +go 1.16 -- plugin/main.go -- package main diff --git a/testdata/scripts/position.txt b/testdata/scripts/position.txt index f8fa909..186c26e 100644 --- a/testdata/scripts/position.txt +++ b/testdata/scripts/position.txt @@ -17,7 +17,7 @@ stdout 'varLines is sorted' -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/reverse.txt b/testdata/scripts/reverse.txt index 0721d1c..a04c5be 100644 --- a/testdata/scripts/reverse.txt +++ b/testdata/scripts/reverse.txt @@ -30,7 +30,7 @@ cmp stderr reverse.stdout -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/seed.txt b/testdata/scripts/seed.txt index 4dfd755..01bbe08 100644 --- a/testdata/scripts/seed.txt +++ b/testdata/scripts/seed.txt @@ -40,7 +40,7 @@ stderr . -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main diff --git a/testdata/scripts/syntax.txt b/testdata/scripts/syntax.txt index b964fed..2befd78 100644 --- a/testdata/scripts/syntax.txt +++ b/testdata/scripts/syntax.txt @@ -13,13 +13,13 @@ go build exec ./main$exe cmp stderr main.stderr -binsubstr main$exe 'globalVar' # 'globalType' only matches on go < 1.15 +binsubstr main$exe 'globalVar' # 'globalType' matches on some, but not all, platforms ! binsubstr main$exe 'localName' 'globalConst' 'remoteIntReturn' 'intReturn' -- extra/go.mod -- module private.source/extra -go 1.15 +go 1.16 -- extra/extra.go -- package extra @@ -29,7 +29,7 @@ func Func() string { -- go.mod -- module test/main -go 1.15 +go 1.16 // We include an extra module to obfuscate, included in the same original source // code via a replace directive. diff --git a/testdata/scripts/test.txt b/testdata/scripts/test.txt index 5f9a5ba..7f409fc 100644 --- a/testdata/scripts/test.txt +++ b/testdata/scripts/test.txt @@ -22,7 +22,7 @@ stdout 'PASS.*TestFoo' -- go.mod -- module test/bar -go 1.15 +go 1.16 -- bar.go -- package bar diff --git a/testdata/scripts/tiny.txt b/testdata/scripts/tiny.txt index 93194d9..5397371 100644 --- a/testdata/scripts/tiny.txt +++ b/testdata/scripts/tiny.txt @@ -27,7 +27,7 @@ stderr 'panic: oh noes' -- go.mod -- module test/main -go 1.15 +go 1.16 -- main.go -- package main