From 71756355dc18a3905bbaafeaed4b357558535454 Mon Sep 17 00:00:00 2001 From: Srdjan Petrovic Date: Tue, 17 Mar 2015 11:57:11 -0700 Subject: [PATCH] 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/7694 Reviewed-by: David Crawshaw Reviewed-by: Ian Lance Taylor --- src/cmd/go/build.go | 10 ++++++++-- src/cmd/go/doc.go | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index 70bbbdbd58..32a9f73ed5 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -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 } diff --git a/src/cmd/go/doc.go b/src/cmd/go/doc.go index 7c92389767..ba1a707132 100644 --- a/src/cmd/go/doc.go +++ b/src/cmd/go/doc.go @@ -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 -- 2.48.1