]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix -Wl,--whole-archive for aix/ppc64
authorClément Chigot <clement.chigot@atos.net>
Wed, 27 Feb 2019 12:49:17 +0000 (13:49 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 27 Feb 2019 15:56:45 +0000 (15:56 +0000)
--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>
src/cmd/go/internal/work/gccgo.go

index 69a25bea62ff449894c996bd985bdc0735f094b6..184d2919ca61a8643d5552d4187326f9fb0662e9 100644 (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")