]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: always allow bigtoc generation with gcc on aix/ppc64
authorClément Chigot <clement.chigot@atos.net>
Wed, 20 Feb 2019 15:42:11 +0000 (16:42 +0100)
committerIan Lance Taylor <iant@golang.org>
Wed, 13 Mar 2019 04:17:56 +0000 (04:17 +0000)
-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>
src/cmd/cgo/gcc.go
src/cmd/go/internal/work/exec.go
src/cmd/link/internal/ld/lib.go

index 915ad66111b8987dad2201ff279dff8a6e716db5..9428ffd3bf910f83cef691a6f6292a6931d60fbd 100644 (file)
@@ -1587,6 +1587,7 @@ func (p *Package) gccCmd() []string {
        c = append(c, p.gccMachine()...)
        if goos == "aix" {
                c = append(c, "-maix64")
+               c = append(c, "-mcmodel=large")
        }
        c = append(c, "-") //read input from standard input
        return c
index 62ae01e5551250d06c1ad7571607fbe351679207..e53ef6cdd35725ea29decdf17fd99937571ec2e8 100644 (file)
@@ -2244,6 +2244,11 @@ func (b *Builder) compilerCmd(compiler []string, incdir, workdir string) []strin
                }
        }
 
+       if cfg.Goos == "aix" {
+               // mcmodel=large must always be enabled to allow large TOC.
+               a = append(a, "-mcmodel=large")
+       }
+
        // disable ASCII art in clang errors, if possible
        if b.gccSupportsFlag(compiler, "-fno-caret-diagnostics") {
                a = append(a, "-fno-caret-diagnostics")
index d5efcee34b89d8236f1ba4dc52bd6b48c22d5a48..5e1b04207320ee112fd9777eb6c941f61853cda3 100644 (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)