From e61317e7ae44e6268510a31f720b2f47a52de50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 1 Nov 2022 16:48:15 +0000 Subject: [PATCH] fix garble with newer Go tip versions Some big changes landed in Go for the upcoming 1.20. While here, remove the use of GOGC=off with make.bash, as https://go.dev/cl/436235 makes that unnecessary now. --- .github/workflows/test.yml | 5 ++--- main.go | 6 +++++- shared.go | 6 +++++- testdata/script/reverse.txtar | 10 ++++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0600cc4f..d08f65d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,7 +78,7 @@ jobs: steps: - name: Install Go env: - GO_COMMIT: 5f566d35bf7d590c95f4d1b685b995deeb9ba957 # 2022-10-01 + GO_COMMIT: 122a22e0e9eba7fe712030d429fc4bcf6f447f5e # 2022-11-12 run: | cd $HOME mkdir $HOME/gotip @@ -89,8 +89,7 @@ jobs: echo "devel go1.20-${GO_COMMIT}" >VERSION cd src - # GOGC=off helps Go build about 20% faster, if we can spare memory. - GOGC=off ./make.bash + ./make.bash echo "GOROOT=$HOME/gotip" >>$GITHUB_ENV echo "$HOME/gotip/bin" >>$GITHUB_PATH - uses: actions/checkout@v3 diff --git a/main.go b/main.go index 23a00b85..7865b30a 100644 --- a/main.go +++ b/main.go @@ -729,8 +729,12 @@ func replaceAsmNames(buf *bytes.Buffer, remaining []byte) { // If the name was qualified, fetch the package, and write the // obfuscated import path if needed. + // Note that runtime/internal/startlinetest refers to runtime_test in + // one of its assembly files, and we currently do not always collect + // test packages in appendListedPackages for the sake of performance. + // We don't care about testing the runtime just yet, so work around it. lpkg := curPkg - if asmPkgPath != "" { + if asmPkgPath != "" && asmPkgPath != "runtime_test" { var err error lpkg, err = listPackage(goPkgPath) if err != nil { diff --git a/shared.go b/shared.go index 41120f47..2156eedc 100644 --- a/shared.go +++ b/shared.go @@ -336,14 +336,18 @@ func listPackage(path string) (*listedPackage, error) { panic(fmt.Sprintf("package %q still missing after go list call", path)) } startTime := time.Now() - // Obtained via scripts/runtime-linknamed-nodeps.sh as of 2022-10-01. + // Obtained via scripts/runtime-linknamed-nodeps.sh as of 2022-11-01. runtimeLinknamed := []string{ + "arena", "crypto/internal/boring", "crypto/internal/boring/bcache", "crypto/internal/boring/fipstls", "crypto/x509/internal/macos", + "internal/godebug", "internal/poll", "internal/reflectlite", + "internal/syscall/unix", + "math/rand", "net", "os", "os/signal", diff --git a/testdata/script/reverse.txtar b/testdata/script/reverse.txtar index fdbca36d..98d98543 100644 --- a/testdata/script/reverse.txtar +++ b/testdata/script/reverse.txtar @@ -30,7 +30,8 @@ cp stderr build-error.stderr stdin build-error.stderr garble reverse ./build-error -cmp stdout build-error-reverse.stdout +[!go1.20] cmp stdout build-error-reverse.stdout-go1.19 +[go1.20] cmp stdout build-error-reverse.stdout-go1.20 [short] stop # no need to verify this with -short @@ -158,8 +159,13 @@ main.main(...) test/main/long_main.go:11 +0x?? main filename: test/main/long_main.go --- build-error-reverse.stdout -- +-- build-error-reverse.stdout-go1.19 -- # test/main/build-error test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int} exit status 2 exit status 2 +-- build-error-reverse.stdout-go1.20 -- +go build test/main/build-error: # test/main/build-error +test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int} +exit status 2 +exit status 1