]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: move cfg.ExternalLinkingForced to internal/load
authorRuss Cox <rsc@golang.org>
Wed, 8 Nov 2017 01:39:54 +0000 (20:39 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 9 Nov 2017 15:03:49 +0000 (15:03 +0000)
It needs to refer to packages, so it can no longer be in cfg.
No semantic changes here.

Can now be unexported, so that was a net win anyway.

Change-Id: I58bf6cdcd435e6e019291bb8dcd5d5b7f1ac03a3
Reviewed-on: https://go-review.googlesource.com/76550
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/load/pkg.go

index 5f93f39f904c88f53b157edcf2221f5042e9f5a2..ab20c20e2fc09412afbc6eac8897c6f58fb31fc9 100644 (file)
@@ -151,40 +151,3 @@ func isGOROOT(path string) bool {
        }
        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
-}
index dfc5fa51f40f95285860cc0e9bd0a2b0267e0cae..1752f7de6653d7aa05f0f65bfec43217feb9c12c 100644 (file)
@@ -1103,7 +1103,7 @@ func LinkerDeps(p *Package) []string {
        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.
@@ -1122,6 +1122,43 @@ func LinkerDeps(p *Package) []string {
        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.