finding the right combination of compilation flags for locating headers and linking against the right libclang is tricky and not user-friendly as (mainly) there is no pkg-config support for neither LLVM nor CLang.
there is a llvm-config program that mimics what pkg-config can do, but only for LLVM libraries, not libclang.
On top of that, llvm-config may not have been installed, or with a slightly different name, depending on the Linux distribution or OS.
to ease the burden on our brave users, we should probably have either a go run ./config-cgo.go program or a go generate step to perform the following drudgery:
- find
llvm-config and extract/infer the correct CFLAGS and LDFLAGS (handling the possible naming variations of libclang.so[.MAJOR[.MINOR]]
- if no
llvm-config could be found, try to look into canonical locations for the given libclang version, depending on the Linux distribution (or OS.)
- then generate a
cgoflags_gen.go file with the correct // #cgo directives embedded and hard-coded.
finding the right combination of compilation flags for locating headers and linking against the right libclang is tricky and not user-friendly as (mainly) there is no
pkg-configsupport for neither LLVM nor CLang.there is a
llvm-configprogram that mimics whatpkg-configcan do, but only forLLVMlibraries, notlibclang.On top of that,
llvm-configmay not have been installed, or with a slightly different name, depending on the Linux distribution or OS.to ease the burden on our brave users, we should probably have either a
go run ./config-cgo.goprogram or ago generatestep to perform the following drudgery:llvm-configand extract/infer the correctCFLAGSandLDFLAGS(handling the possible naming variations oflibclang.so[.MAJOR[.MINOR]]llvm-configcould be found, try to look into canonical locations for the givenlibclangversion, depending on the Linux distribution (or OS.)cgoflags_gen.gofile with the correct// #cgodirectives embedded and hard-coded.