aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2012-12-19 01:48:09 +0800
committerShenghou Ma <minux.ma@gmail.com>2012-12-19 01:48:09 +0800
commit326ccebec8986de534c8608ff6f8fe7bd0070b10 (patch)
treebd417dd0f3862923d5f2d4d25330f8b00baddaa9 /src
parent70e967b7bc6583735c098a91395b9f42b017e006 (diff)
downloadgo-326ccebec8986de534c8608ff6f8fe7bd0070b10.tar.xz
cmd/go: pass gccgoflags at the end of gccgo command line, warn if user passes the wrong toolchain options
R=iant CC=golang-dev https://golang.org/cl/6940082
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/build.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 5f91227f15..e7046a9ef5 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -191,6 +191,21 @@ func runBuild(cmd *Command, args []string) {
*buildO += exeSuffix
}
+ // sanity check some often mis-used options
+ switch buildContext.Compiler {
+ case "gccgo":
+ if len(buildGcflags) != 0 {
+ fmt.Println("go build: when using gccgo toolchain, please pass compiler flags using -gccgoflags, not -gcflags")
+ }
+ if len(buildLdflags) != 0 {
+ fmt.Println("go build: when using gccgo toolchain, please pass linker flags using -gccgoflags, not -ldflags")
+ }
+ case "gc":
+ if len(buildGccgoflags) != 0 {
+ fmt.Println("go build: when using gc toolchain, please pass compile flags using -gcflags, and linker flags using -ldflags")
+ }
+ }
+
if *buildO != "" {
if len(pkgs) > 1 {
fatalf("go build: cannot use -o with multiple packages")
@@ -1451,7 +1466,7 @@ func (tools gccgcToolchain) ld(b *builder, p *Package, out string, allactions []
if usesCgo && goos == "linux" {
ldflags = append(ldflags, "-Wl,-E")
}
- return b.run(".", p.ImportPath, "gccgo", "-o", out, buildGccgoflags, ofiles, "-Wl,-(", ldflags, "-Wl,-)")
+ return b.run(".", p.ImportPath, "gccgo", "-o", out, ofiles, "-Wl,-(", ldflags, "-Wl,-)", buildGccgoflags)
}
func (gccgcToolchain) cc(b *builder, p *Package, objdir, ofile, cfile string) error {