Skip to content

Commit

Permalink
cmd/go: don't assemble all .s files in a single cmd/asm run
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Josh Bleecher Snyder <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
ianlancetaylor committed Dec 13, 2016
1 parent 9fe2291 commit b9ffcf9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/cmd/go/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2406,22 +2406,24 @@ 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" {
args = append(args, "-D=GOBUILDMODE_shared=1")
}
}
}
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
Expand Down
16 changes: 16 additions & 0 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit b9ffcf9

Please sign in to comment.