aboutsummaryrefslogtreecommitdiff
path: root/test/linkx_run.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2014-12-31 13:25:52 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2015-01-02 18:36:44 +0000
commit8bbd80063b986e106ab35727e483be8bdcfd9f5b (patch)
treeb3409081c0f692183f29c633477fe45d97ba9e18 /test/linkx_run.go
parent79c4fad8c2416bd7c7865b337d70bc7f92153415 (diff)
downloadgo-8bbd80063b986e106ab35727e483be8bdcfd9f5b.tar.gz
go-8bbd80063b986e106ab35727e483be8bdcfd9f5b.zip
cmd/go: put user ldflags at the end of the linker invocation
If the user provided a key but no value via -ldflag -X, another linker flag was used as the value. Placing the user's flags at the end avoids this problem. It also provides the user the opportunity to override existing linker flags. Fixes #8810. Change-Id: I96f4190713dc9a9c29142e56658446fba7fb6bc8 Reviewed-on: https://go-review.googlesource.com/2242 Reviewed-by: Minux Ma <minux@golang.org>
Diffstat (limited to 'test/linkx_run.go')
-rw-r--r--test/linkx_run.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/linkx_run.go b/test/linkx_run.go
index 11b66ed5a9..f3029f50a9 100644
--- a/test/linkx_run.go
+++ b/test/linkx_run.go
@@ -16,6 +16,7 @@ import (
)
func main() {
+ // Successful run
cmd := exec.Command("go", "run", "-ldflags=-X main.tbd hello -X main.overwrite trumped -X main.nosuchsymbol neverseen", "linkx.go")
out, err := cmd.CombinedOutput()
if err != nil {
@@ -30,4 +31,12 @@ func main() {
fmt.Printf("got %q want %q\n", got, want)
os.Exit(1)
}
+
+ // Issue 8810
+ cmd = exec.Command("go", "run", "-ldflags=-X main.tbd", "linkx.go")
+ _, err = cmd.CombinedOutput()
+ if err == nil {
+ fmt.Println("-X linker flag should not accept keys without values")
+ os.Exit(1)
+ }
}