cmd: always allow bigtoc generation with gcc on aix/ppc64

-mcmodel=large and -Wl,-bbigtoc must always be passed to gcc in order to
prevent TOC overflow error. However, a warning is still issued by ld. It
is removed as it doesn't give any useful information.

Change-Id: I95a78e8993cc7b5c0f329654d507409785f7eea6
Reviewed-on: https://go-review.googlesource.com/c/go/+/164008
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-20 16:42:11 +01:00 committed by Ian Lance Taylor
parent b6544a2a87
commit a891f2e2ae
3 changed files with 23 additions and 0 deletions

View file

@ -1153,6 +1153,10 @@ func (ctxt *Link) hostlink() {
// prevent ld to reorder .text functions to keep the same
// first/last functions for moduledata.
argv = append(argv, "-Wl,-bnoobjreorder")
// mcmodel=large is needed for every gcc generated files, but
// ld still need -bbigtoc in order to allow larger TOC.
argv = append(argv, "-mcmodel=large")
argv = append(argv, "-Wl,-bbigtoc")
}
switch ctxt.BuildMode {
@ -1387,11 +1391,24 @@ func (ctxt *Link) hostlink() {
// Filter out useless linker warnings caused by bugs outside Go.
// See also cmd/go/internal/work/exec.go's gccld method.
var save [][]byte
var skipLines int
for _, line := range bytes.SplitAfter(out, []byte("\n")) {
// golang.org/issue/26073 - Apple Xcode bug
if bytes.Contains(line, []byte("ld: warning: text-based stub file")) {
continue
}
if skipLines > 0 {
skipLines--
continue
}
// Remove TOC overflow warning on AIX.
if bytes.Contains(line, []byte("ld: 0711-783")) {
skipLines = 2
continue
}
save = append(save, line)
}
out = bytes.Join(save, nil)