Commit 0d8c3637 authored by Clément Chigot's avatar Clément Chigot Committed by Ian Lance Taylor

cmd/go: fix -Wl,--whole-archive for aix/ppc64

--whole-archive doesn't exist on AIX. It was already removed most of
the time but was still added with c-archive or c-shared buildmodes.

Change-Id: Ia7360638509d4a4d91674b0281ed4b112508a2c9
Reviewed-on: https://go-review.googlesource.com/c/164037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 850e3636
...@@ -407,6 +407,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string ...@@ -407,6 +407,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
} }
var realOut string var realOut string
goLibBegin := str.StringList(wholeArchive, "-lgolibbegin", noWholeArchive)
switch buildmode { switch buildmode {
case "exe": case "exe":
if usesCgo && cfg.Goos == "linux" { if usesCgo && cfg.Goos == "linux" {
...@@ -428,7 +429,8 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string ...@@ -428,7 +429,8 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
// split-stack and non-split-stack code in a single -r // split-stack and non-split-stack code in a single -r
// link, and libgo picks up non-split-stack code from // link, and libgo picks up non-split-stack code from
// libffi. // libffi.
ldflags = append(ldflags, "-Wl,-r", "-nostdlib", "-Wl,--whole-archive", "-lgolibbegin", "-Wl,--no-whole-archive") ldflags = append(ldflags, "-Wl,-r", "-nostdlib")
ldflags = append(ldflags, goLibBegin...)
if nopie := b.gccNoPie([]string{tools.linker()}); nopie != "" { if nopie := b.gccNoPie([]string{tools.linker()}); nopie != "" {
ldflags = append(ldflags, nopie) ldflags = append(ldflags, nopie)
...@@ -443,7 +445,10 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string ...@@ -443,7 +445,10 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
out = out + ".o" out = out + ".o"
case "c-shared": case "c-shared":
ldflags = append(ldflags, "-shared", "-nostdlib", "-Wl,--whole-archive", "-lgolibbegin", "-Wl,--no-whole-archive", "-lgo", "-lgcc_s", "-lgcc", "-lc", "-lgcc") ldflags = append(ldflags, "-shared", "-nostdlib")
ldflags = append(ldflags, goLibBegin...)
ldflags = append(ldflags, "-lgo", "-lgcc_s", "-lgcc", "-lc", "-lgcc")
case "shared": case "shared":
if cfg.Goos != "aix" { if cfg.Goos != "aix" {
ldflags = append(ldflags, "-zdefs") ldflags = append(ldflags, "-zdefs")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment