1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:50:05 -07:00

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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Clément Chigot 2019-02-27 13:49:17 +01:00 committed by Ian Lance Taylor
parent 850e3636d5
commit 0d8c3637b1

View File

@ -407,6 +407,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
}
var realOut string
goLibBegin := str.StringList(wholeArchive, "-lgolibbegin", noWholeArchive)
switch buildmode {
case "exe":
if usesCgo && cfg.Goos == "linux" {
@ -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
// link, and libgo picks up non-split-stack code from
// 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 != "" {
ldflags = append(ldflags, nopie)
@ -443,7 +445,10 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
out = out + ".o"
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":
if cfg.Goos != "aix" {
ldflags = append(ldflags, "-zdefs")