From: Ian Lance Taylor Date: Tue, 3 Jul 2018 19:05:51 +0000 (-0700) Subject: cmd/go: don't pass both -static and -pie to cgo compiler X-Git-Tag: go1.11beta2~212 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=36c623046b9d9da2ae614f9dd526709271160c3c;p=gostls13.git cmd/go: don't pass both -static and -pie to cgo compiler Along with CL 122135, Fixes #26197 Change-Id: I61e8cfb0dcc39885acf8ffa1ffb34cbbe4dc1dc3 Reviewed-on: https://go-review.googlesource.com/122155 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 9a5a0dfc8e..e886020cb7 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -2473,7 +2473,15 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe // we need to use -pie for Linux/ARM to get accurate imported sym ldflags := cgoLDFLAGS if (cfg.Goarch == "arm" && cfg.Goos == "linux") || cfg.Goos == "android" { - ldflags = append(ldflags, "-pie") + // -static -pie doesn't make sense, and causes link errors. + // Issue 26197. + n := make([]string, 0, len(ldflags)) + for _, flag := range ldflags { + if flag != "-static" { + n = append(n, flag) + } + } + ldflags = append(n, "-pie") } if err := b.gccld(p, objdir, dynobj, ldflags, linkobj); err != nil { return err