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

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

View as plain text