Commit 62353ff8 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle Committed by Ian Lance Taylor

cmd/go: have go run, go list respect -buildmode/-linkshared

Change-Id: I749fd91cd3c7581cdcc97a15e8eeee0c20f0b259
Reviewed-on: https://go-review.googlesource.com/8805Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
parent e8b7133e
......@@ -159,6 +159,7 @@ var buildLinkshared bool // -linkshared flag
var buildContext = build.Default
var buildToolchain toolchain = noToolchain{}
var ldBuildmode string
// buildCompiler implements flag.Var.
// It implements Set by updating both
......@@ -307,7 +308,7 @@ func pkgsNotMain(pkgs []*Package) (res []*Package) {
var pkgsFilter = func(pkgs []*Package) []*Package { return pkgs }
func buildModeInit() {
var codegenArg, ldBuildmode string
var codegenArg string
platform := goos + "/" + goarch
switch buildBuildmode {
case "archive":
......@@ -362,9 +363,6 @@ func buildModeInit() {
// TODO(mwhudson): remove -w when that gets fixed in linker.
buildLdflags = append(buildLdflags, "-linkshared", "-w")
}
if ldBuildmode != "" {
buildLdflags = append(buildLdflags, "-buildmode="+ldBuildmode)
}
if codegenArg != "" {
buildAsmflags = append(buildAsmflags, codegenArg)
buildGcflags = append(buildGcflags, codegenArg)
......@@ -1286,6 +1284,7 @@ func (b *builder) linkShared(a *action) (err error) {
importArgs := b.includeArgs("-L", allactions[:len(allactions)-1])
// TODO(mwhudson): this does not check for cxx-ness, extldflags etc
ldflags := []string{"-installsuffix", buildContext.InstallSuffix}
ldflags = append(ldflags, "-buildmode="+ldBuildmode)
ldflags = append(ldflags, buildLdflags...)
for _, d := range a.deps {
if d.target != "" { // omit unsafe etc
......@@ -2082,6 +2081,7 @@ func (gcToolchain) ld(b *builder, p *Package, out string, allactions []*action,
}
}
}
ldflags = append(ldflags, "-buildmode="+ldBuildmode)
ldflags = append(ldflags, buildLdflags...)
return b.run(".", p.ImportPath, nil, buildToolExec, tool(archChar()+"l"), "-o", out, importArgs, ldflags, mainpkg)
}
......
......@@ -126,6 +126,7 @@ var listJson = cmdList.Flag.Bool("json", false, "")
var nl = []byte{'\n'}
func runList(cmd *Command, args []string) {
buildModeInit()
out := newTrackingWriter(os.Stdout)
defer out.w.Flush()
......
......@@ -64,6 +64,7 @@ func printStderr(args ...interface{}) (int, error) {
func runRun(cmd *Command, args []string) {
raceInit()
buildModeInit()
var b builder
b.init()
b.print = printStderr
......
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