mirror of
https://github.com/golang/go
synced 2024-11-25 22:28:02 -07:00
n
Change-Id: I23851c3d47c5727fe9ccf6b318693ca30c872409
This commit is contained in:
parent
4ece9ceb75
commit
6543df4784
@ -13,7 +13,6 @@ import (
|
|||||||
"go/build"
|
"go/build"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"internal/cfg"
|
"internal/cfg"
|
||||||
"internal/platform"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -128,14 +127,16 @@ func defaultContext() build.Context {
|
|||||||
ctxt.ToolTags = save
|
ctxt.ToolTags = save
|
||||||
|
|
||||||
// The go/build rule for whether cgo is enabled is:
|
// The go/build rule for whether cgo is enabled is:
|
||||||
// 1. If $CGO_ENABLED is set, respect it.
|
// 1. If $CGO_ENABLED is set, respect it.
|
||||||
// 2. Otherwise, if this is a cross-compile, disable cgo.
|
// 2. Otherwise, if this is a cross-compile, disable cgo.
|
||||||
// 3. Otherwise, use built-in default for GOOS/GOARCH.
|
// 3. Otherwise, use built-in default for GOOS/GOARCH.
|
||||||
|
//
|
||||||
// Recreate that logic here with the new GOOS/GOARCH setting.
|
// Recreate that logic here with the new GOOS/GOARCH setting.
|
||||||
if v := Getenv("CGO_ENABLED"); v == "0" || v == "1" {
|
// We need to run steps 2 and 3 to determine what the default value
|
||||||
ctxt.CgoEnabled = v[0] == '1'
|
// of CgoEnabled would be for computing CGOChanged.
|
||||||
} else if ctxt.GOOS != runtime.GOOS || ctxt.GOARCH != runtime.GOARCH {
|
defaultCgoEnabled := ctxt.CgoEnabled
|
||||||
ctxt.CgoEnabled = false
|
if ctxt.GOOS != runtime.GOOS || ctxt.GOARCH != runtime.GOARCH {
|
||||||
|
defaultCgoEnabled = false
|
||||||
} else {
|
} else {
|
||||||
// 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
|
||||||
@ -162,17 +163,16 @@ func defaultContext() build.Context {
|
|||||||
if os.Getenv("CC") == "" {
|
if os.Getenv("CC") == "" {
|
||||||
cc := DefaultCC(ctxt.GOOS, ctxt.GOARCH)
|
cc := DefaultCC(ctxt.GOOS, ctxt.GOARCH)
|
||||||
if _, err := LookPath(cc); err != nil {
|
if _, err := LookPath(cc); err != nil {
|
||||||
ctxt.CgoEnabled = false
|
defaultCgoEnabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CGOChanged = ctxt.CgoEnabled != func() bool {
|
ctxt.CgoEnabled = defaultCgoEnabled
|
||||||
if runtime.GOARCH == ctxt.GOARCH && runtime.GOOS == ctxt.GOOS {
|
if v := Getenv("CGO_ENABLED"); v == "0" || v == "1" {
|
||||||
return platform.CgoSupported(ctxt.GOOS, ctxt.GOARCH)
|
ctxt.CgoEnabled = v[0] == '1'
|
||||||
}
|
}
|
||||||
return false
|
CGOChanged = ctxt.CgoEnabled != defaultCgoEnabled
|
||||||
}()
|
|
||||||
|
|
||||||
ctxt.OpenFile = func(path string) (io.ReadCloser, error) {
|
ctxt.OpenFile = func(path string) (io.ReadCloser, error) {
|
||||||
return fsys.Open(path)
|
return fsys.Open(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user