diff options
author | Ian Lance Taylor <iant@golang.org> | 2016-12-12 14:37:40 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2016-12-13 00:57:24 +0000 |
commit | b9ffcf961e54419dc46f8338d86398665e719623 (patch) | |
tree | 09dde8e3e784d5828bcf7a334fd49464b3d3c968 | |
parent | 9fe2291efdfd6257b97a3271b1145b67a3e7089d (diff) | |
download | go-b9ffcf961e54419dc46f8338d86398665e719623.tar.gz go-b9ffcf961e54419dc46f8338d86398665e719623.zip |
cmd/go: don't assemble all .s files in a single cmd/asm run
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>
-rw-r--r-- | src/cmd/go/build.go | 16 | ||||
-rw-r--r-- | src/cmd/go/go_test.go | 16 |
2 files changed, 25 insertions, 7 deletions
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index e053b28c98..0027ca0fc0 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -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 diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 1c84512ed4..88c54432fb 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -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") +} |