]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't pass both -static and -pie to cgo compiler
authorIan Lance Taylor <iant@golang.org>
Tue, 3 Jul 2018 19:05:51 +0000 (12:05 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 4 Jul 2018 00:22:11 +0000 (00:22 +0000)
Along with CL 122135,
Fixes #26197

Change-Id: I61e8cfb0dcc39885acf8ffa1ffb34cbbe4dc1dc3
Reviewed-on: https://go-review.googlesource.com/122155
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/internal/work/exec.go

index 9a5a0dfc8eed785fb6a13c285c5d794768d3dc94..e886020cb7fc34bb5a0cef2024cdca111a934e8e 100644 (file)
@@ -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