]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: only pass -fsplit-stack to gccgo if supported
authorIan Lance Taylor <iant@golang.org>
Sat, 27 Jul 2019 23:14:16 +0000 (16:14 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 31 Jul 2019 23:53:23 +0000 (23:53 +0000)
Also add other gccgo options.

This ports CL 45695 and CL 48592 from the gofrontend repo to the gc repo.

CL 45695 (partial entry, other parts out of date and not ported):

    cmd/go: gccgo: consistent results

    Pass the -fdebug-prefix-map and -gno-record-gcc-switches compiler
    options to gccgo to generate consistent results.

CL 48592:

    cmd/go: use gccSupportsFlag for -fsplit-stack

    Don't assume that all (or only) 386/amd64 compilers support
    -fsplit-stack.

Fixes #33108

Change-Id: I61f9e5a67e4fb059f26750e97621d27afa566ec2
Reviewed-on: https://go-review.googlesource.com/c/go/+/187824
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/work/exec.go
src/cmd/go/internal/work/gccgo.go

index 944b23f1d8ffe7a24f77257f32738fba68feb0e1..b68f9028533ac34086778757ca5b3592bbca16c4 100644 (file)
@@ -2532,8 +2532,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
        }
 
        if cfg.BuildToolchainName == "gccgo" {
-               switch cfg.Goarch {
-               case "386", "amd64":
+               if b.gccSupportsFlag([]string{BuildToolchain.compiler()}, "-fsplit-stack") {
                        cgoCFLAGS = append(cgoCFLAGS, "-fsplit-stack")
                }
                cgoflags = append(cgoflags, "-gccgo")
index 36726d369b12d2b9ffff48059b42473eaf92055a..24d856ca1e020aa7ff96ed2ae25095bb223f472e 100644 (file)
@@ -67,6 +67,8 @@ func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg
        ofile = objdir + out
        gcargs := []string{"-g"}
        gcargs = append(gcargs, b.gccArchArgs()...)
+       gcargs = append(gcargs, "-fdebug-prefix-map="+b.WorkDir+"=/tmp/go-build")
+       gcargs = append(gcargs, "-gno-record-gcc-switches")
        if pkgpath := gccgoPkgpath(p); pkgpath != "" {
                gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath)
        }
@@ -528,12 +530,18 @@ func (tools gccgoToolchain) cc(b *Builder, a *Action, ofile, cfile string) error
        if pkgpath := gccgoCleanPkgpath(p); pkgpath != "" {
                defs = append(defs, `-D`, `GOPKGPATH="`+pkgpath+`"`)
        }
-       switch cfg.Goarch {
-       case "386", "amd64":
+       compiler := envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch))
+       if b.gccSupportsFlag(compiler, "-fsplit-stack") {
                defs = append(defs, "-fsplit-stack")
        }
        defs = tools.maybePIC(defs)
-       return b.run(a, p.Dir, p.ImportPath, nil, envList("CC", cfg.DefaultCC(cfg.Goos, cfg.Goarch)), "-Wall", "-g",
+       if b.gccSupportsFlag(compiler, "-fdebug-prefix-map=a=b") {
+               defs = append(defs, "-fdebug-prefix-map="+b.WorkDir+"=/tmp/go-build")
+       }
+       if b.gccSupportsFlag(compiler, "-gno-record-gcc-switches") {
+               defs = append(defs, "-gno-record-gcc-switches")
+       }
+       return b.run(a, p.Dir, p.ImportPath, nil, compiler, "-Wall", "-g",
                "-I", a.Objdir, "-I", inc, "-o", ofile, defs, "-c", cfile)
 }