From: Ian Lance Taylor Date: Sat, 19 Aug 2017 00:46:03 +0000 (-0700) Subject: cmd/go: -buildmode=pie forces external linking mode on all systems X-Git-Tag: go1.10beta1~1432 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=eccd3ef526956ab404b8b4a724a9a3862c77f457;p=gostls13.git cmd/go: -buildmode=pie forces external linking mode on all systems The go tool assumed that -buildmode=pie implied internal linking on linux-amd64. However, that was changed by CL 36417 for issue #18968. Fixes #21452 Change-Id: I8ed13aea52959cc5c53223f4c41ba35329445545 Reviewed-on: https://go-review.googlesource.com/57231 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Avelino Reviewed-by: Rob Pike --- diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index d3d1922964..ae2151561a 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -953,11 +953,12 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package if cfg.BuildContext.CgoEnabled && p.Name == "main" && !p.Goroot { // Currently build modes c-shared, pie (on systems that do not - // support PIE with internal linking mode), plugin, and - // -linkshared force external linking mode, as of course does + // 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" && (cfg.BuildContext.GOOS != "linux" || cfg.BuildContext.GOARCH != "amd64") + pieCgo := cfg.BuildBuildmode == "pie" linkmodeExternal := false for i, a := range cfg.BuildLdflags { if a == "-linkmode=external" {