Skip to content

Commit

Permalink
cmd/go: remove special case for prebuilt cgo library cache keys
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Nov 22, 2022
1 parent 5b1b080 commit 5c9a506
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 2 additions & 7 deletions src/cmd/go/internal/work/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 14 additions & 6 deletions src/cmd/go/testdata/script/cgo_stale_precompiled.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@
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'

0 comments on commit 5c9a506

Please sign in to comment.