From 8c2e1d6ca5497c08ec72abe9da93e4a7869e0f0e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 1 May 2018 14:08:44 +0000 Subject: [PATCH] re PR go/85429 (Several gotools tests FAIL with Solaris as) PR go/85429 cmd/go: support more Solaris assembler syntaxes Patch by Rainer Orth. Reviewed-on: https://go-review.googlesource.com/110563 From-SVN: r259797 --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/cmd/go/internal/work/buildid.go | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 24592d26a10..61a5bc2206b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -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. diff --git a/libgo/go/cmd/go/internal/work/buildid.go b/libgo/go/cmd/go/internal/work/buildid.go index 7f1ee506329..2636128b1a7 100644 --- a/libgo/go/cmd/go/internal/work/buildid.go +++ b/libgo/go/cmd/go/internal/work/buildid.go @@ -303,16 +303,35 @@ func (b *Builder) gccgoToolID(name, language string) (string, error) { 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++ { -- 2.30.2