blob: 6ceb33bb70e7b75b2ac59044c4ad5c3ff3a5d493 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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() {}
|