I've been experimenting with the go1.18 build tree ( to try to resolve https://github.com/golang/go/issues/50113 ) and it would appear that this version of GO has returned to CGO_ENABLED=0 being the default build mode. This causes the libcap/go/compare-cap.go build test to fail: $ make GO=~/gohacks/go/bin/go clean -C go compare-cap [...] go: no Go source files make: *** [Makefile:58: compare-cap] Error 1 $ cd go $ make GO=~/gohacks/go/bin/go all test [failure again, but dependencies set up..] $ CGO_ENABLED=1 CC="gcc" CGO_CFLAGS="-I$HOME/gits/libcap/libcap/include/uapi -I$HOME/gits/libcap/libcap/include" CGO_LDFLAGS="-L$HOME/gits/libcap/libcap" ~/gohacks/go/bin/go build -mod=vendor compare-cap.go $ That is, if I force CGO_ENABLED=1 the compilation work. $ go version ; go env CGO_ENABLED go version go1.16.13 linux/amd64 1 $ ~/gohacks/go/bin/go version ; ~/gohacks/go/bin/go env CGO_ENABLED go version devel go1.18-7fa52d74f2 Sun Feb 13 13:42:41 2022 -0800 linux/amd64 0
This is fixed with: https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=aae937481ae28c0cfe502309e9acb5c34ba0b2cd
For the record, the setup was slightly different. The Go team have not changed the default build characteristics of Go to CGO_ENABLED=0. Instead, I was building the Go build tree with that configuration (to run its in-build tests with CGO_ENABLED=0), and that causes the built compiler to default to CGO_ENABLED=0.
I've updated the bug title to reflect the actual issue.