]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist
authorqiulaidongfeng <2645477756@qq.com>
Sat, 13 Sep 2025 18:32:24 +0000 (02:32 +0800)
committerMichael Matloob <matloob@golang.org>
Tue, 16 Sep 2025 19:23:37 +0000 (12:23 -0700)
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>
src/cmd/go/internal/cfg/cfg.go

index a4edd854f1d35a787b4768c00ed3688a42948d5e..97e4eeeff3c8cf93b629c0c3069052f5f6a289be 100644 (file)
@@ -145,7 +145,8 @@ func defaultContext() build.Context {
        if buildcfg.DefaultCGO_ENABLED == "1" {
                defaultCgoEnabled = true
        } 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)
                // Use built-in default cgo setting for GOOS/GOARCH.
                // Note that ctxt.GOOS/GOARCH are derived from the preference list