}
return stat.IsDir()
}
-
-// ExternalLinkingForced reports whether external linking is being
-// forced even for programs that do not use cgo.
-func ExternalLinkingForced() bool {
- // Some targets must use external linking even inside GOROOT.
- switch BuildContext.GOOS {
- case "android":
- return true
- case "darwin":
- switch BuildContext.GOARCH {
- case "arm", "arm64":
- return true
- }
- }
-
- if !BuildContext.CgoEnabled {
- return false
- }
- // Currently build modes c-shared, pie (on systems that do not
- // support PIE with internal linking mode (currently all
- // systems: issue #18968)), plugin, and -linkshared force
- // external linking mode, as of course does
- // -ldflags=-linkmode=external. External linking mode forces
- // an import of runtime/cgo.
- pieCgo := BuildBuildmode == "pie"
- linkmodeExternal := false
- for i, a := range BuildLdflags {
- if a == "-linkmode=external" {
- linkmodeExternal = true
- }
- if a == "-linkmode" && i+1 < len(BuildLdflags) && BuildLdflags[i+1] == "external" {
- linkmodeExternal = true
- }
- }
-
- return BuildBuildmode == "c-shared" || BuildBuildmode == "plugin" || pieCgo || BuildLinkshared || linkmodeExternal
-}
deps := []string{"runtime"}
// External linking mode forces an import of runtime/cgo.
- if cfg.ExternalLinkingForced() {
+ if externalLinkingForced() {
deps = append(deps, "runtime/cgo")
}
// On ARM with GOARM=5, it forces an import of math, for soft floating point.
return deps
}
+// externalLinkingForced reports whether external linking is being
+// forced even for programs that do not use cgo.
+func externalLinkingForced() bool {
+ // Some targets must use external linking even inside GOROOT.
+ switch cfg.BuildContext.GOOS {
+ case "android":
+ return true
+ case "darwin":
+ switch cfg.BuildContext.GOARCH {
+ case "arm", "arm64":
+ return true
+ }
+ }
+
+ if !cfg.BuildContext.CgoEnabled {
+ return false
+ }
+ // Currently build modes c-shared, pie (on systems that do not
+ // support PIE with internal linking mode (currently all
+ // systems: issue #18968)), plugin, and -linkshared force
+ // external linking mode, as of course does
+ // -ldflags=-linkmode=external. External linking mode forces
+ // an import of runtime/cgo.
+ pieCgo := cfg.BuildBuildmode == "pie"
+ linkmodeExternal := false
+ for i, a := range cfg.BuildLdflags {
+ if a == "-linkmode=external" {
+ linkmodeExternal = true
+ }
+ if a == "-linkmode" && i+1 < len(cfg.BuildLdflags) && cfg.BuildLdflags[i+1] == "external" {
+ linkmodeExternal = true
+ }
+ }
+
+ return cfg.BuildBuildmode == "c-shared" || cfg.BuildBuildmode == "plugin" || pieCgo || cfg.BuildLinkshared || linkmodeExternal
+}
+
// mkAbs rewrites list, which must be paths relative to p.Dir,
// into a sorted list of absolute paths. It edits list in place but for
// convenience also returns list back to its caller.