diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-11-13 11:05:37 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-16 14:56:38 +0000 |
commit | 730d5f42f919f948ff2841581ecec6fe4b465aee (patch) | |
tree | 57152253494e668d081054f3c7f6797916e6fd19 /src/cmd/go/testdata/script/ldflag.txt | |
parent | d8c8fd6c305cf34a569e50a8d1f69aa123f9b32f (diff) | |
download | go-730d5f42f919f948ff2841581ecec6fe4b465aee.tar.gz go-730d5f42f919f948ff2841581ecec6fe4b465aee.zip |
[release-branch.go1.15] cmd/go: permit CGO_LDFLAGS to appear in //go:ldflag
For #42565
Fixes #42567
Change-Id: If7cf39905d124dbd54dfac6a53ee38270498efed
Reviewed-on: https://go-review.googlesource.com/c/go/+/269818
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 782cf560db4c919790fdb476d1bbe18e5ddf5ffd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/270137
Diffstat (limited to 'src/cmd/go/testdata/script/ldflag.txt')
-rw-r--r-- | src/cmd/go/testdata/script/ldflag.txt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/ldflag.txt b/src/cmd/go/testdata/script/ldflag.txt new file mode 100644 index 0000000000..6ceb33bb70 --- /dev/null +++ b/src/cmd/go/testdata/script/ldflag.txt @@ -0,0 +1,44 @@ +# Issue #42565 + +[!cgo] skip + +# We can't build package bad, which uses #cgo LDFLAGS. +cd bad +! go build +stderr no-such-warning + +# We can build package ok with the same flags in CGO_LDFLAGS. +env CGO_LDFLAGS=-Wno-such-warning -Wno-unknown-warning-option +cd ../ok +go build + +# Build a main program that actually uses LDFLAGS. +cd .. +go build -ldflags=-v + +# Because we passed -v the Go linker should print the external linker +# command which should include the flag we passed in CGO_LDFLAGS. +stderr no-such-warning + +-- go.mod -- +module ldflag + +-- bad/bad.go -- +package bad + +// #cgo LDFLAGS: -Wno-such-warning -Wno-unknown-warning +import "C" + +func F() {} +-- ok/ok.go -- +package ok + +import "C" + +func F() {} +-- main.go -- +package main + +import _ "ldflag/ok" + +func main() {} |