]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't assemble all .s files in a single cmd/asm run
authorIan Lance Taylor <iant@golang.org>
Mon, 12 Dec 2016 22:37:40 +0000 (14:37 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 13 Dec 2016 00:57:24 +0000 (00:57 +0000)
For the 1.8 release, go back to invoking the assembler once per .s
file, to avoid the problem in #18225. When the assembler is fixed, the
change to cmd/go/build.go can be rolled back, but the test in
cmd/go/go_test.go should remain.

Fixes #18225.
Update #15680.

Change-Id: Ibff8d0c638536efb50a2b2c280b41399332f4fe4
Reviewed-on: https://go-review.googlesource.com/34284
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/build.go
src/cmd/go/go_test.go

index e053b28c989272063e81cd95ebec9c958eb1d6a3..0027ca0fc0ff3d1b88d913ae9da09e74ce905c22 100644 (file)
@@ -2406,8 +2406,7 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool,
 func (gcToolchain) asm(b *builder, p *Package, obj string, sfiles []string) ([]string, error) {
        // Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
        inc := filepath.Join(goroot, "pkg", "include")
-       ofile := obj + "asm.o"
-       args := []interface{}{buildToolExec, tool("asm"), "-o", ofile, "-trimpath", b.work, "-I", obj, "-I", inc, "-D", "GOOS_" + goos, "-D", "GOARCH_" + goarch, buildAsmflags}
+       args := []interface{}{buildToolExec, tool("asm"), "-trimpath", b.work, "-I", obj, "-I", inc, "-D", "GOOS_" + goos, "-D", "GOARCH_" + goarch, buildAsmflags}
        if p.ImportPath == "runtime" && goarch == "386" {
                for _, arg := range buildAsmflags {
                        if arg == "-dynlink" {
@@ -2415,13 +2414,16 @@ func (gcToolchain) asm(b *builder, p *Package, obj string, sfiles []string) ([]s
                        }
                }
        }
+       var ofiles []string
        for _, sfile := range sfiles {
-               args = append(args, mkAbs(p.Dir, sfile))
-       }
-       if err := b.run(p.Dir, p.ImportPath, nil, args...); err != nil {
-               return nil, err
+               ofile := obj + sfile[:len(sfile)-len(".s")] + ".o"
+               ofiles = append(ofiles, ofile)
+               a := append(args, "-o", ofile, mkAbs(p.Dir, sfile))
+               if err := b.run(p.Dir, p.ImportPath, nil, a...); err != nil {
+                       return nil, err
+               }
        }
-       return []string{ofile}, nil
+       return ofiles, nil
 }
 
 // toolVerify checks that the command line args writes the same output file
index 1c84512ed49cabb109d3df407bdb66506893d570..88c54432fba2cf365d2722f7d9a8a8dfffb4afa0 100644 (file)
@@ -3727,3 +3727,19 @@ func TestLdBindNow(t *testing.T) {
        tg.setenv("LD_BIND_NOW", "1")
        tg.run("help")
 }
+
+// Issue 18225.
+// This is really a cmd/asm issue but this is a convenient place to test it.
+func TestConcurrentAsm(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.parallel()
+       asm := `DATA ·constants<>+0x0(SB)/8,$0
+GLOBL ·constants<>(SB),8,$8
+`
+       tg.tempFile("go/src/p/a.s", asm)
+       tg.tempFile("go/src/p/b.s", asm)
+       tg.tempFile("go/src/p/p.go", `package p`)
+       tg.setenv("GOPATH", tg.path("go"))
+       tg.run("build", "p")
+}