Commit 71756355 authored by Srdjan Petrovic's avatar Srdjan Petrovic Committed by Ian Lance Taylor

cmd/go: add -asmflags build flag

We need this in order to pass the "-shared" flag to the assembler.

Change-Id: I9c15cfe4d32c1e5e8cae1b9b2c924cfd77923b55
Reviewed-on: https://go-review.googlesource.com/7694Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 8da54a4e
...@@ -88,6 +88,8 @@ and test commands: ...@@ -88,6 +88,8 @@ and test commands:
or, if set explicitly, has _race appended to it. or, if set explicitly, has _race appended to it.
-ldflags 'flag list' -ldflags 'flag list'
arguments to pass on each 5l, 6l, 8l, or 9l linker invocation. 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' -tags 'tag list'
a list of build tags to consider satisfied during the build. a list of build tags to consider satisfied during the build.
For more information about build tags, see the description of For more information about build tags, see the description of
...@@ -137,6 +139,7 @@ var buildX bool // -x flag ...@@ -137,6 +139,7 @@ var buildX bool // -x flag
var buildI bool // -i flag var buildI bool // -i flag
var buildO = cmdBuild.Flag.String("o", "", "output file") var buildO = cmdBuild.Flag.String("o", "", "output file")
var buildWork bool // -work flag var buildWork bool // -work flag
var buildAsmflags []string // -asmflags flag
var buildGcflags []string // -gcflags flag var buildGcflags []string // -gcflags flag
var buildLdflags []string // -ldflags flag var buildLdflags []string // -ldflags flag
var buildGccgoflags []string // -gccgoflags flag var buildGccgoflags []string // -gccgoflags flag
...@@ -188,6 +191,7 @@ func addBuildFlags(cmd *Command) { ...@@ -188,6 +191,7 @@ func addBuildFlags(cmd *Command) {
cmd.Flag.BoolVar(&buildV, "v", false, "") cmd.Flag.BoolVar(&buildV, "v", false, "")
cmd.Flag.BoolVar(&buildX, "x", false, "") cmd.Flag.BoolVar(&buildX, "x", false, "")
cmd.Flag.BoolVar(&buildWork, "work", false, "") cmd.Flag.BoolVar(&buildWork, "work", false, "")
cmd.Flag.Var((*stringsFlag)(&buildAsmflags), "asmflags", "")
cmd.Flag.Var((*stringsFlag)(&buildGcflags), "gcflags", "") cmd.Flag.Var((*stringsFlag)(&buildGcflags), "gcflags", "")
cmd.Flag.Var((*stringsFlag)(&buildLdflags), "ldflags", "") cmd.Flag.Var((*stringsFlag)(&buildLdflags), "ldflags", "")
cmd.Flag.Var((*stringsFlag)(&buildGccgoflags), "gccgoflags", "") cmd.Flag.Var((*stringsFlag)(&buildGccgoflags), "gccgoflags", "")
...@@ -1705,11 +1709,13 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error { ...@@ -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. // Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
inc := filepath.Join(goroot, "pkg", "include") inc := filepath.Join(goroot, "pkg", "include")
sfile = mkAbs(p.Dir, sfile) 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 { if err := b.run(p.Dir, p.ImportPath, nil, args...); err != nil {
return err 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 { if err := toolVerify(b, p, "old"+archChar()+"a", ofile, args); err != nil {
return err return err
} }
......
...@@ -81,7 +81,8 @@ and test commands: ...@@ -81,7 +81,8 @@ and test commands:
print the commands but do not run them. print the commands but do not run them.
-p n -p n
the number of builds that can be run in parallel. 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 -race
enable data race detection. enable data race detection.
Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64. Supported only on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64.
...@@ -106,6 +107,8 @@ and test commands: ...@@ -106,6 +107,8 @@ and test commands:
or, if set explicitly, has _race appended to it. or, if set explicitly, has _race appended to it.
-ldflags 'flag list' -ldflags 'flag list'
arguments to pass on each 5l, 6l, 8l, or 9l linker invocation. 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' -tags 'tag list'
a list of build tags to consider satisfied during the build. a list of build tags to consider satisfied during the build.
For more information about build tags, see the description of For more information about build tags, see the description of
...@@ -931,6 +934,9 @@ system. ...@@ -931,6 +934,9 @@ system.
- "std" is like all but expands to just the packages in the standard - "std" is like all but expands to just the packages in the standard
Go library. 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, 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 each of which can match any string, including the empty string and
strings containing slashes. Such a pattern expands to all package strings containing slashes. Such a pattern expands to all package
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment