Skip to content

Commit 5c9a506

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
cmd/go: remove special case for prebuilt cgo library cache keys
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 <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 5b1b080 commit 5c9a506

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/cmd/go/internal/work/exec.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,8 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
278278
fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
279279
// Include the C compiler tool ID so that if the C
280280
// compiler changes we rebuild the package.
281-
// But don't do that for standard library packages like net,
282-
// so that the prebuilt .a files from a Go binary install
283-
// don't need to be rebuilt with the local compiler.
284-
if !p.Standard {
285-
if ccID, _, err := b.gccToolID(ccExe[0], "c"); err == nil {
286-
fmt.Fprintf(h, "CC ID=%q\n", ccID)
287-
}
281+
if ccID, _, err := b.gccToolID(ccExe[0], "c"); err == nil {
282+
fmt.Fprintf(h, "CC ID=%q\n", ccID)
288283
}
289284
if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
290285
cxxExe := b.cxxExe()

src/cmd/go/testdata/script/cgo_stale_precompiled.txt

+14-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
go build -x runtime/cgo
1717
[!short] stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
1818

19-
# https://go.dev/issue/47215: a missing $(go env CC) caused the precompiled net to be stale.
20-
[!GOOS:plan9] env PATH='' # Guaranteed not to include $(go env CC)!
21-
[GOOS:plan9] env path=''
22-
go build -x runtime/cgo
23-
! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
24-
2519
# https://go.dev/issue/50183: a mismatched GOROOT_FINAL caused net to be stale.
20+
env oldGOROOT_FINAL=$GOROOT_FINAL
2621
env GOROOT_FINAL=$WORK${/}goroot
2722
go build -x runtime/cgo
2823
! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
24+
25+
env GOROOT_FINAL=$oldGOROOT_FINAL
26+
27+
# https://go.dev/issue/47215: a missing $(go env CC) caused the precompiled net
28+
# to be stale. But as of https://go.dev/cl/452457 the precompiled libraries are
29+
# no longer installed anyway! Since we're requiring a C compiler in order to
30+
# build and use cgo libraries in the standard library, we should make sure it
31+
# matches what's in the cache.
32+
[!abscc] env CGO_ENABLED=1
33+
[!abscc] [!GOOS:plan9] env PATH='' # Guaranteed not to include $(go env CC)!
34+
[!abscc] [GOOS:plan9] env path=''
35+
[!abscc] ! go build -x runtime/cgo
36+
[!abscc] stderr 'C compiler .* not found'

0 commit comments

Comments
 (0)