Revert "cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist"

This reverts commit c2d85eb999.

Reason for revert: change was incorrect. ignores setting of CGO_ENABLED in some cases

Change-Id: I8e6e68dd600be5306a247a3314f4b57175f1aa56
Reviewed-on: https://go-review.googlesource.com/c/go/+/705495
Auto-Submit: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Alexander <jitsu@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Matloob 2025-09-19 09:25:20 -07:00 committed by Gopher Robot
parent ee7bf06cb3
commit 51dc5bfe6c

View file

@ -145,8 +145,7 @@ func defaultContext() build.Context {
if buildcfg.DefaultCGO_ENABLED == "1" { if buildcfg.DefaultCGO_ENABLED == "1" {
defaultCgoEnabled = true defaultCgoEnabled = true
} else if buildcfg.DefaultCGO_ENABLED == "0" { } else if buildcfg.DefaultCGO_ENABLED == "0" {
} } else if runtime.GOARCH == ctxt.GOARCH && runtime.GOOS == ctxt.GOOS {
if runtime.GOARCH == ctxt.GOARCH && runtime.GOOS == ctxt.GOOS {
defaultCgoEnabled = platform.CgoSupported(ctxt.GOOS, ctxt.GOARCH) defaultCgoEnabled = platform.CgoSupported(ctxt.GOOS, ctxt.GOARCH)
// Use built-in default cgo setting for GOOS/GOARCH. // Use built-in default cgo setting for GOOS/GOARCH.
// Note that ctxt.GOOS/GOARCH are derived from the preference list // Note that ctxt.GOOS/GOARCH are derived from the preference list