}
}
+func TestCgoCache(t *testing.T) {
+ if !canCgo {
+ t.Skip("no cgo")
+ }
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempFile("src/x/a.go", `package main
+ // #ifndef VAL
+ // #define VAL 0
+ // #endif
+ // int val = VAL;
+ import "C"
+ import "fmt"
+ func main() { fmt.Println(C.val) }
+ `)
+ tg.setenv("GOPATH", tg.path("."))
+ exe := tg.path("x.exe")
+ tg.run("build", "-o", exe, "x")
+ tg.setenv("CGO_LDFLAGS", "-lnosuchlibraryexists")
+ tg.runFail("build", "-o", exe, "x")
+ tg.grepStderr(`nosuchlibraryexists`, "did not run linker with changed CGO_LDFLAGS")
+}
+
// Issue 23982
func TestFilepathUnderCwdFormat(t *testing.T) {
tg := testgo(t)
}
if len(p.CgoFiles)+len(p.SwigFiles) > 0 {
fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo"))
- cppflags, cflags, cxxflags, fflags, _, _ := b.CFlags(p)
- fmt.Fprintf(h, "CC=%q %q %q\n", b.ccExe(), cppflags, cflags)
+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p)
+ fmt.Fprintf(h, "CC=%q %q %q %q\n", b.ccExe(), cppflags, cflags, ldflags)
if len(p.CXXFiles)+len(p.SwigFiles) > 0 {
fmt.Fprintf(h, "CXX=%q %q\n", b.cxxExe(), cxxflags)
}