cmd/go: make asm the first assembler
verifyAsm is still on, but this CL changes the order to asm then 6a.
Before, it was 6a then asm, but that meant that any bugs in asm
for bad input would be prevented from happening because 6a would
catch them. Now asm gets first crack, as it must.
Also implement the -trimpath flag in asm. It's necessary and trivial.
Change-Id: Ifb2ab870de1aa1b53dec76a78ac697a0d36fa80a
Reviewed-on: https://go-review.googlesource.com/5850
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/cmd/asm/internal/flags/flags.go b/src/cmd/asm/internal/flags/flags.go
index df0049f..12bd585 100644
--- a/src/cmd/asm/internal/flags/flags.go
+++ b/src/cmd/asm/internal/flags/flags.go
@@ -17,7 +17,7 @@
Debug = flag.Bool("debug", false, "dump instructions as they are parsed")
OutputFile = flag.String("o", "", "output file; default foo.6 for /a/b/c/foo.s on amd64")
PrintOut = flag.Bool("S", false, "print assembly and machine code")
- TrimPath = flag.String("trimpath", "", "remove prefix from recorded source file paths (unused TODO)")
+ TrimPath = flag.String("trimpath", "", "remove prefix from recorded source file paths")
)
var (
diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go
index 31d5b95..9df486e 100644
--- a/src/cmd/asm/main.go
+++ b/src/cmd/asm/main.go
@@ -40,6 +40,7 @@
if *flags.PrintOut {
ctxt.Debugasm = 1
}
+ ctxt.Trimpath = *flags.TrimPath
ctxt.Bso = obj.Binitw(os.Stdout)
defer obj.Bflush(ctxt.Bso)
ctxt.Diag = log.Fatalf
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 382c4cd..df4260c 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -1703,7 +1703,7 @@
}
// verifyAsm specifies whether to check the assemblers written in Go
-// against the assemblers written in C. If set, asm will run both (say) 6a and new6a
+// against the assemblers written in C. If set, asm will run both asm and (say) 6a
// and fail if the two produce different output files.
const verifyAsm = true
@@ -1711,12 +1711,12 @@
// Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
inc := filepath.Join(goroot, "pkg", fmt.Sprintf("%s_%s", goos, goarch))
sfile = mkAbs(p.Dir, sfile)
- args := []interface{}{buildToolExec, tool(archChar + "a"), "-o", ofile, "-trimpath", b.work, "-I", obj, "-I", inc, "-D", "GOOS_" + goos, "-D", "GOARCH_" + goarch, sfile}
+ args := []interface{}{buildToolExec, tool("asm"), "-o", ofile, "-trimpath", b.work, "-I", obj, "-I", inc, "-D", "GOOS_" + goos, "-D", "GOARCH_" + goarch, sfile}
if err := b.run(p.Dir, p.ImportPath, nil, args...); err != nil {
return err
}
if verifyAsm {
- if err := toolVerify(b, p, "asm", ofile, args); err != nil {
+ if err := toolVerify(b, p, archChar+"a", ofile, args); err != nil {
return err
}
}