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

CL 621995 disrupted the behavior
introduced by CL 450739, now restore it.

Fixes #75340

Change-Id: Icd1a0eb970876995f9446e0547ceb9e78990f6ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/703555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Ian Alexander <jitsu@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
This commit is contained in:
qiulaidongfeng 2025-09-14 02:32:24 +08:00 committed by Michael Matloob
parent ac82fe68aa
commit c2d85eb999

View file

@ -145,7 +145,8 @@ 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