1 # Issue #7573
2 # cmd/cgo: undefined reference when linking a C-library using gccgo
3
4 [!cgo] skip
5 [!exec:gccgo] skip
6 [cross] skip # gccgo can't necessarily cross-compile, so don't assume it will reach the step where we expect it to fail
7
8 ! go build -x -compiler gccgo
9 stderr 'gccgo.*\-L [^ ]*alibpath \-lalib' # make sure that Go-inline "#cgo LDFLAGS:" ("-L alibpath -lalib") passed to gccgo linking stage
10 ! stderr 'gccgo.*-lalib.*-lalib' # make sure -lalib is only passed once
11
12 -- go.mod --
13 module m
14 -- cgoref.go --
15 package main
16 // #cgo LDFLAGS: -L alibpath -lalib
17 // void f(void) {}
18 import "C"
19
20 func main() { C.f() }
21
View as plain text