Skip to content

Commit 4ece9ce

Browse files
n
Change-Id: Ib6afec3f7309f5190ac5e21d8fa9711aff1c29a3
1 parent c8744c5 commit 4ece9ce

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/cmd/go/internal/cfg/cfg.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"go/build"
1414
"internal/buildcfg"
1515
"internal/cfg"
16+
"internal/platform"
1617
"io"
1718
"os"
1819
"path/filepath"
@@ -132,7 +133,7 @@ func defaultContext() build.Context {
132133
// 3. Otherwise, use built-in default for GOOS/GOARCH.
133134
// Recreate that logic here with the new GOOS/GOARCH setting.
134135
if v := Getenv("CGO_ENABLED"); v == "0" || v == "1" {
135-
ctxt.CgoEnabled, CGOChanged = v[0] == '1', v[0] != '0'
136+
ctxt.CgoEnabled = v[0] == '1'
136137
} else if ctxt.GOOS != runtime.GOOS || ctxt.GOARCH != runtime.GOARCH {
137138
ctxt.CgoEnabled = false
138139
} else {
@@ -166,6 +167,12 @@ func defaultContext() build.Context {
166167
}
167168
}
168169
}
170+
CGOChanged = ctxt.CgoEnabled != func() bool {
171+
if runtime.GOARCH == ctxt.GOARCH && runtime.GOOS == ctxt.GOOS {
172+
return platform.CgoSupported(ctxt.GOOS, ctxt.GOARCH)
173+
}
174+
return false
175+
}()
169176

170177
ctxt.OpenFile = func(path string) (io.ReadCloser, error) {
171178
return fsys.Open(path)

src/cmd/go/internal/envcmd/env.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ func MkEnv() []cfg.EnvVar {
129129
env[i].Changed = true
130130
}
131131
case "GODEBUG":
132-
env[i].Value, env[i].Changed = cfg.EnvOrAndChanged("GODEBUG", "")
132+
env[i].Value = os.Getenv("GODEBUG")
133+
env[i].Changed = env[i].Value != ""
133134
}
134135
}
135136

src/internal/cfg/cfg.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@ const KnownEnv = `
6969
GOWORK
7070
GO_EXTLINK_ENABLED
7171
PKG_CONFIG
72-
GODEBUG
7372
`

0 commit comments

Comments
 (0)