In a certain project I need to use llvm-config as a build/test dependency. This tool is not something cabal can download and build because it is not based on Haskell source code. So I think build-depends or build-tool-depends would not help here.
How would I specify this dependency in a cabal file?
Alternatively how would I do the same in a package.yaml file which can be used to generate cabal file by running hpack?
@jaror llvm-config is used for figuring out the library path of llvm library for linking the generated code against. The project generates llvm bitcode for a DSL and the tests verify that the generated code can be linked with llvm and executed.
It is not my project, but I am trying to help with the CI for the project, and learn Haskell in the process
Cabal doesn’t handle installing non-Haskell tools and I think even tools written in Haskell should be installed through the package manager of your distribution if it has them. In the case of CI, you can probably run a command like apt install llvm.
The cxx-sources field is for when you are writing Haskell programs that use the FFI to call into C++ code. I don’t think that is relevant in this case.
Not a direct answer to your question (since indeed, I don’t believe Cabal supports this as-is): you could consider using Cabal’s pkg-config support, with a .pc file generated in some PKG_CONFIG_PATH using llvm-pkg-config: Generate Pkg-Config configuration file for LLVM.
@chreekat yes, nix dev shell is a good option that could work, but I am trying to postpone learning nix for the time being
pkg-confg is probably a linux specific mechanism? I am trying to get something working for both linux and macOS. I have llvm installed on macOS via brew and it doesn’t showup in pkg-config listing
It won’t show up on Linux either, because for some reason the LLVM devs seem not to ship a pc file but insist on using llvm-config. The tool I linked provides a work-around.