re PR go/85429 (Several gotools tests FAIL with Solaris as)
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 1 May 2018 14:08:44 +0000 (14:08 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 1 May 2018 14:08:44 +0000 (14:08 +0000)
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
libgo/go/cmd/go/internal/work/buildid.go

index 24592d26a10e3ff65c8b06fca82a77bf8e1b2d66..61a5bc2206b760ebc97ab720ff805cc905ff03c1 100644 (file)
@@ -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 7f1ee50632964b56c946e375d20a3c0f3d6d6050..2636128b1a7ec25e2dcdbd7fa956796776ab1e3b 100644 (file)
@@ -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++ {