There are even more varieties of the Solaris assembler syntax on different platforms, as discussed on PR 85429. This patch by Rainer Orth should address them all, I hope. Committed to mainline.
OK for GCC 8 branch? Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 259719) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -32861fd0acb0f3232f66be4791388b27e71c9990 +380527c032f02446438c71b0ac0026bcab416be5 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/cmd/go/internal/work/buildid.go =================================================================== --- libgo/go/cmd/go/internal/work/buildid.go (revision 259719) +++ libgo/go/cmd/go/internal/work/buildid.go (working copy) @@ -303,16 +303,35 @@ func (b *Builder) gccgoToolID(name, lang return id, nil } +// Check if assembler used by gccgo is GNU as. +func assemblerIsGas() bool { + cmd := exec.Command(BuildToolchain.compiler(), "-print-prog-name=as") + assembler, err := cmd.Output() + if err == nil { + cmd := exec.Command(strings.TrimSpace(string(assembler)), "--version") + out, err := cmd.Output() + if err == nil && strings.Contains(string(out), "GNU") { + return true + } else { + return false + } + } else { + return false + } +} + // gccgoBuildIDELFFile creates an assembler file that records the // action's build ID in an SHF_EXCLUDE section. func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) { sfile := a.Objdir + "_buildid.s" var buf bytes.Buffer - if cfg.Goos != "solaris" { + if cfg.Goos != "solaris" || assemblerIsGas() { fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n") - } else { + } else if cfg.Goarch == "sparc" || cfg.Goarch == "sparc64" { fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n") + } else { // cfg.Goarch == "386" || cfg.Goarch == "amd64" + fmt.Fprintf(&buf, "\t"+`.section .go.buildid,#exclude`+"\n") } fmt.Fprintf(&buf, "\t.byte ") for i := 0; i < len(a.buildID); i++ {