Skip to content

Commit 1fcd0d4

Browse files
committed
cmd/cgo: less invasive way
1 parent d665784 commit 1fcd0d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2971,7 +2971,13 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe
29712971

29722972
ldflags := cgoLDFLAGS
29732973
if (cfg.Goarch == "arm" && cfg.Goos == "linux") || cfg.Goos == "android" {
2974-
if str.Contains(cgoLDFLAGS, "-pie") && str.Contains(cgoLDFLAGS, "-static") {
2974+
if !str.Contains(ldflags, "-no-pie") {
2975+
// if we do'nt see '-no-pie',
2976+
// we add "-pie" keep backward-compatibility
2977+
// (https://golang.org/cl/5989058)
2978+
ldflags = append(ldflags, "-pie")
2979+
}
2980+
if str.Contains(ldflags, "-pie") && str.Contains(ldflags, "-static") {
29752981
// -static -pie doesn't make sense, and causes link errors.
29762982
// Issue 26197.
29772983
n := make([]string, 0, len(ldflags))

0 commit comments

Comments
 (0)