]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: remove special case for prebuilt cgo library cache keys
authorBryan C. Mills <bcmills@google.com>
Tue, 22 Nov 2022 03:12:15 +0000 (22:12 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 22 Nov 2022 15:58:43 +0000 (15:58 +0000)
This was an oversight from CL 452457 that I noticed while
investigating #56889.

This change essentially undoes CL 335409, which is no longer needed
after CL 450739 because we no longer attempt to use cgo by default
when no C compiler is present.

Updates #47257.
Updates #40042.
Updates #47215.

Change-Id: I29c7ce777a9ec7ba5820dc1d836b12a61b86bc37
Reviewed-on: https://go-review.googlesource.com/c/go/+/452677
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/cgo_stale_precompiled.txt

index 7569935926133a11f5b6aaeaabd8fc354b4f20c5..8c143e4588f4228c4b1be5a0a47b92aacd397149 100644 (file)
@@ -278,13 +278,8 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
                fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
                // Include the C compiler tool ID so that if the C
                // compiler changes we rebuild the package.
-               // But don't do that for standard library packages like net,
-               // so that the prebuilt .a files from a Go binary install
-               // don't need to be rebuilt with the local compiler.
-               if !p.Standard {
-                       if ccID, _, err := b.gccToolID(ccExe[0], "c"); err == nil {
-                               fmt.Fprintf(h, "CC ID=%q\n", ccID)
-                       }
+               if ccID, _, err := b.gccToolID(ccExe[0], "c"); err == nil {
+                       fmt.Fprintf(h, "CC ID=%q\n", ccID)
                }
                if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
                        cxxExe := b.cxxExe()
index e446758ed8527d38980c00d6855ad2eb111ad8d1..eb7e10557b0c1528487d18623b7585744a0dc54f 100644 (file)
 go build -x runtime/cgo
 [!short] stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
 
-# https://go.dev/issue/47215: a missing $(go env CC) caused the precompiled net to be stale.
-[!GOOS:plan9] env PATH=''  # Guaranteed not to include $(go env CC)!
-[GOOS:plan9] env path=''
-go build -x runtime/cgo
-! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
-
 # https://go.dev/issue/50183: a mismatched GOROOT_FINAL caused net to be stale.
+env oldGOROOT_FINAL=$GOROOT_FINAL
 env GOROOT_FINAL=$WORK${/}goroot
 go build -x runtime/cgo
 ! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
+
+env GOROOT_FINAL=$oldGOROOT_FINAL
+
+# https://go.dev/issue/47215: a missing $(go env CC) caused the precompiled net
+# to be stale. But as of https://go.dev/cl/452457 the precompiled libraries are
+# no longer installed anyway! Since we're requiring a C compiler in order to
+# build and use cgo libraries in the standard library, we should make sure it
+# matches what's in the cache.
+[!abscc] env CGO_ENABLED=1
+[!abscc] [!GOOS:plan9] env PATH=''  # Guaranteed not to include $(go env CC)!
+[!abscc] [GOOS:plan9] env path=''
+[!abscc] ! go build -x runtime/cgo
+[!abscc] stderr 'C compiler .* not found'