...

Text file src/cmd/go/testdata/script/ldflag.txt

Documentation: cmd/go/testdata/script

     1# Issue #42565
     2
     3[!cgo] skip
     4
     5# We can't build package bad, which uses #cgo LDFLAGS.
     6cd bad
     7! go build
     8stderr no-such-warning
     9
    10# We can build package ok with the same flags in CGO_LDFLAGS.
    11env CGO_LDFLAGS=-Wno-such-warning -Wno-unknown-warning-option
    12cd ../ok
    13go build
    14
    15# Build a main program that actually uses LDFLAGS.
    16cd ..
    17go build -ldflags=-v
    18
    19# Because we passed -v the Go linker should print the external linker
    20# command which should include the flag we passed in CGO_LDFLAGS.
    21stderr no-such-warning
    22
    23-- go.mod --
    24module ldflag
    25
    26-- bad/bad.go --
    27package bad
    28
    29// #cgo LDFLAGS: -Wno-such-warning -Wno-unknown-warning
    30import "C"
    31
    32func F() {}
    33-- ok/ok.go --
    34package ok
    35
    36import "C"
    37
    38func F() {}
    39-- main.go --
    40package main
    41
    42import _ "ldflag/ok"
    43
    44func main() {}

View as plain text