Skip to content

Commit 36c6230

Browse files
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 5929ead commit 36c6230

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/cmd/go/internal/work/exec.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,15 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe
24732473
// we need to use -pie for Linux/ARM to get accurate imported sym
24742474
ldflags := cgoLDFLAGS
24752475
if (cfg.Goarch == "arm" && cfg.Goos == "linux") || cfg.Goos == "android" {
2476-
ldflags = append(ldflags, "-pie")
2476+
// -static -pie doesn't make sense, and causes link errors.
2477+
// Issue 26197.
2478+
n := make([]string, 0, len(ldflags))
2479+
for _, flag := range ldflags {
2480+
if flag != "-static" {
2481+
n = append(n, flag)
2482+
}
2483+
}
2484+
ldflags = append(n, "-pie")
24772485
}
24782486
if err := b.gccld(p, objdir, dynobj, ldflags, linkobj); err != nil {
24792487
return err

0 commit comments

Comments
 (0)