]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add -asmflags build flag
authorSrdjan Petrovic <spetrovic@google.com>
Tue, 17 Mar 2015 18:57:11 +0000 (11:57 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 27 Mar 2015 22:52:48 +0000 (22:52 +0000)
We need this in order to pass the "-shared" flag to the assembler.

Change-Id: I9c15cfe4d32c1e5e8cae1b9b2c924cfd77923b55
Reviewed-on: https://go-review.googlesource.com/7694
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/build.go
src/cmd/go/doc.go

index 70bbbdbd58d1c6b757cdeeaaf17e104c41caab96..32a9f73ed59ca9ad6ffe9dc768884c39479d9b30 100644 (file)
@@ -88,6 +88,8 @@ and test commands:
                or, if set explicitly, has _race appended to it.
        -ldflags 'flag list'
                arguments to pass on each 5l, 6l, 8l, or 9l linker invocation.
+       -asmflags 'flag list'
+               arguments to pass on each asm assembler invocation.
        -tags 'tag list'
                a list of build tags to consider satisfied during the build.
                For more information about build tags, see the description of
@@ -137,6 +139,7 @@ var buildX bool               // -x flag
 var buildI bool               // -i flag
 var buildO = cmdBuild.Flag.String("o", "", "output file")
 var buildWork bool           // -work flag
+var buildAsmflags []string   // -asmflags flag
 var buildGcflags []string    // -gcflags flag
 var buildLdflags []string    // -ldflags flag
 var buildGccgoflags []string // -gccgoflags flag
@@ -188,6 +191,7 @@ func addBuildFlags(cmd *Command) {
        cmd.Flag.BoolVar(&buildV, "v", false, "")
        cmd.Flag.BoolVar(&buildX, "x", false, "")
        cmd.Flag.BoolVar(&buildWork, "work", false, "")
+       cmd.Flag.Var((*stringsFlag)(&buildAsmflags), "asmflags", "")
        cmd.Flag.Var((*stringsFlag)(&buildGcflags), "gcflags", "")
        cmd.Flag.Var((*stringsFlag)(&buildLdflags), "ldflags", "")
        cmd.Flag.Var((*stringsFlag)(&buildGccgoflags), "gccgoflags", "")
@@ -1705,11 +1709,13 @@ 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", "include")
        sfile = mkAbs(p.Dir, sfile)
-       args := []interface{}{buildToolExec, tool("asm"), "-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, buildAsmflags, sfile}
        if err := b.run(p.Dir, p.ImportPath, nil, args...); err != nil {
                return err
        }
-       if verifyAsm && goarch != "arm64" {
+       // Disable checks when additional flags are passed, as the old assemblers
+       // don't implement some of them (e.g., -shared).
+       if verifyAsm && goarch != "arm64" && len(buildAsmflags) == 0 {
                if err := toolVerify(b, p, "old"+archChar()+"a", ofile, args); err != nil {
                        return err
                }
index 7c92389767d43b67884e772a593f1ca1cec96f68..ba1a7071321ade99801c5e71eb53ef25364d9b72 100644 (file)
@@ -81,7 +81,8 @@ and test commands:
                print the commands but do not run them.
        -p n
                the number of builds that can be run in parallel.
-               The default is the number of CPUs available.
+               The default is the number of CPUs available, except
+               on darwin/arm which defaults to 1.
        -race
                enable data race detection.
                Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64.
@@ -106,6 +107,8 @@ and test commands:
                or, if set explicitly, has _race appended to it.
        -ldflags 'flag list'
                arguments to pass on each 5l, 6l, 8l, or 9l linker invocation.
+       -asmflags 'flag list'
+               arguments to pass on each asm assembler invocation.
        -tags 'tag list'
                a list of build tags to consider satisfied during the build.
                For more information about build tags, see the description of
@@ -931,6 +934,9 @@ system.
 - "std" is like all but expands to just the packages in the standard
 Go library.
 
+- "cmd" expands to the Go repository's commands and their
+internal libraries.
+
 An import path is a pattern if it includes one or more "..." wildcards,
 each of which can match any string, including the empty string and
 strings containing slashes.  Such a pattern expands to all package