]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make asm the first assembler
authorRob Pike <r@golang.org>
Tue, 24 Feb 2015 22:28:49 +0000 (14:28 -0800)
committerRob Pike <r@golang.org>
Wed, 25 Feb 2015 17:10:37 +0000 (17:10 +0000)
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>
src/cmd/asm/internal/flags/flags.go
src/cmd/asm/main.go
src/cmd/go/build.go

index df0049faa6d4fb14bea3b57be696ffe989b98a67..12bd585413c90dec0740a78a43114ce6fe6ac65c 100644 (file)
@@ -17,7 +17,7 @@ var (
        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 (
index 31d5b95d68bf1e790308ea7d82549190d3acc4aa..9df486e85c6caecf8a313d518778a91714179141 100644 (file)
@@ -40,6 +40,7 @@ func main() {
        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
index 382c4cd2762edf7c7c8183cd8aab2f4ee43273bf..df4260c359d085e43c83ed0e73625f317c990e16 100644 (file)
@@ -1703,7 +1703,7 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool,
 }
 
 // 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 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error {
        // 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
                }
        }