-buildmode mode
build mode to use. See 'go help buildmodes' for more.
+ -linkshared
+ link against shared libraries previously created with
+ -buildmode=shared
-compiler name
name of compiler to use, as in runtime.Compiler (gccgo or gc).
-gccgoflags 'arg list'
var buildRace bool // -race flag
var buildToolExec []string // -toolexec flag
var buildBuildmode string // -buildmode flag
+var buildLinkshared bool // -linkshared flag
var buildContext = build.Default
var buildToolchain toolchain = noToolchain{}
cmd.Flag.BoolVar(&buildRace, "race", false, "")
cmd.Flag.Var((*stringsFlag)(&buildToolExec), "toolexec", "")
cmd.Flag.StringVar(&buildBuildmode, "buildmode", "default", "")
+ cmd.Flag.BoolVar(&buildLinkshared, "linkshared", false, "")
}
func addBuildFlagsNX(cmd *Command) {
default:
fatalf("buildmode=%s not supported", buildBuildmode)
}
+ if buildLinkshared {
+ if goarch != "amd64" || goos != "linux" {
+ fmt.Fprintf(os.Stderr, "go %s: -linkshared is only supported on linux/amd64\n", flag.Args()[0])
+ os.Exit(2)
+ }
+ codegenArg = "-dynlink"
+ // TODO(mwhudson): remove -w when that gets fixed in linker.
+ buildLdflags = append(buildLdflags, "-linkshared", "-w")
+ }
if ldBuildmode != "" {
buildLdflags = append(buildLdflags, "-buildmode="+ldBuildmode)
}
{name: "tags"},
{name: "compiler"},
{name: "race", boolVar: &buildRace},
+ {name: "linkshared", boolVar: &buildLinkshared},
{name: "installsuffix"},
// passed to 6.out, adding a "test." prefix to the name if necessary: -v becomes -test.v.
var err error
switch f.name {
// bool flags.
- case "a", "c", "i", "n", "x", "v", "race", "cover", "work":
+ case "a", "c", "i", "n", "x", "v", "race", "cover", "work", "linkshared":
setBoolFlag(f.boolVar, value)
case "o":
testO = value