mirror of
https://github.com/golang/go
synced 2024-11-20 03:44:40 -07:00
cmd/go: start support for -linkshared
This will fruitlessly rebuild stale packages that are in a shared library. Change-Id: I66a6e1adf7818558e7d1351ab215a5021b4a8a6b Reviewed-on: https://go-review.googlesource.com/8333 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
c3ddb97022
commit
09fb56dc7d
@ -77,6 +77,9 @@ and test commands:
|
|||||||
|
|
||||||
-buildmode mode
|
-buildmode mode
|
||||||
build mode to use. See 'go help buildmodes' for more.
|
build mode to use. See 'go help buildmodes' for more.
|
||||||
|
-linkshared
|
||||||
|
link against shared libraries previously created with
|
||||||
|
-buildmode=shared
|
||||||
-compiler name
|
-compiler name
|
||||||
name of compiler to use, as in runtime.Compiler (gccgo or gc).
|
name of compiler to use, as in runtime.Compiler (gccgo or gc).
|
||||||
-gccgoflags 'arg list'
|
-gccgoflags 'arg list'
|
||||||
@ -149,6 +152,7 @@ var buildGccgoflags []string // -gccgoflags flag
|
|||||||
var buildRace bool // -race flag
|
var buildRace bool // -race flag
|
||||||
var buildToolExec []string // -toolexec flag
|
var buildToolExec []string // -toolexec flag
|
||||||
var buildBuildmode string // -buildmode flag
|
var buildBuildmode string // -buildmode flag
|
||||||
|
var buildLinkshared bool // -linkshared flag
|
||||||
|
|
||||||
var buildContext = build.Default
|
var buildContext = build.Default
|
||||||
var buildToolchain toolchain = noToolchain{}
|
var buildToolchain toolchain = noToolchain{}
|
||||||
@ -204,6 +208,7 @@ func addBuildFlags(cmd *Command) {
|
|||||||
cmd.Flag.BoolVar(&buildRace, "race", false, "")
|
cmd.Flag.BoolVar(&buildRace, "race", false, "")
|
||||||
cmd.Flag.Var((*stringsFlag)(&buildToolExec), "toolexec", "")
|
cmd.Flag.Var((*stringsFlag)(&buildToolExec), "toolexec", "")
|
||||||
cmd.Flag.StringVar(&buildBuildmode, "buildmode", "default", "")
|
cmd.Flag.StringVar(&buildBuildmode, "buildmode", "default", "")
|
||||||
|
cmd.Flag.BoolVar(&buildLinkshared, "linkshared", false, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func addBuildFlagsNX(cmd *Command) {
|
func addBuildFlagsNX(cmd *Command) {
|
||||||
@ -307,6 +312,15 @@ func buildModeInit() {
|
|||||||
default:
|
default:
|
||||||
fatalf("buildmode=%s not supported", buildBuildmode)
|
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 != "" {
|
if ldBuildmode != "" {
|
||||||
buildLdflags = append(buildLdflags, "-buildmode="+ldBuildmode)
|
buildLdflags = append(buildLdflags, "-buildmode="+ldBuildmode)
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,9 @@ and test commands:
|
|||||||
|
|
||||||
-buildmode mode
|
-buildmode mode
|
||||||
build mode to use. See 'go help buildmodes' for more.
|
build mode to use. See 'go help buildmodes' for more.
|
||||||
|
-linkshared
|
||||||
|
link against shared libraries previously created with
|
||||||
|
-buildmode=shared
|
||||||
-compiler name
|
-compiler name
|
||||||
name of compiler to use, as in runtime.Compiler (gccgo or gc).
|
name of compiler to use, as in runtime.Compiler (gccgo or gc).
|
||||||
-gccgoflags 'arg list'
|
-gccgoflags 'arg list'
|
||||||
|
@ -314,6 +314,7 @@ func runTest(cmd *Command, args []string) {
|
|||||||
findExecCmd() // initialize cached result
|
findExecCmd() // initialize cached result
|
||||||
|
|
||||||
raceInit()
|
raceInit()
|
||||||
|
buildModeInit()
|
||||||
pkgs := packagesForBuild(pkgArgs)
|
pkgs := packagesForBuild(pkgArgs)
|
||||||
if len(pkgs) == 0 {
|
if len(pkgs) == 0 {
|
||||||
fatalf("no packages to test")
|
fatalf("no packages to test")
|
||||||
|
@ -48,6 +48,7 @@ var testFlagDefn = []*testFlagSpec{
|
|||||||
{name: "tags"},
|
{name: "tags"},
|
||||||
{name: "compiler"},
|
{name: "compiler"},
|
||||||
{name: "race", boolVar: &buildRace},
|
{name: "race", boolVar: &buildRace},
|
||||||
|
{name: "linkshared", boolVar: &buildLinkshared},
|
||||||
{name: "installsuffix"},
|
{name: "installsuffix"},
|
||||||
|
|
||||||
// passed to 6.out, adding a "test." prefix to the name if necessary: -v becomes -test.v.
|
// passed to 6.out, adding a "test." prefix to the name if necessary: -v becomes -test.v.
|
||||||
@ -115,7 +116,7 @@ func testFlags(args []string) (packageNames, passToTest []string) {
|
|||||||
var err error
|
var err error
|
||||||
switch f.name {
|
switch f.name {
|
||||||
// bool flags.
|
// 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)
|
setBoolFlag(f.boolVar, value)
|
||||||
case "o":
|
case "o":
|
||||||
testO = value
|
testO = value
|
||||||
|
Loading…
Reference in New Issue
Block a user