MyNixOS website logo
Description

FFI bindings to the LLVM compiler toolkit.

FFI bindings to the LLVM compiler toolkit.

Installation cannot be done fully automatically. It would require Cabal code that is bound to certain Cabal versions and is prone to fail. We give several non-automatic ways that also allow you to choose a particular LLVM version.

First possibility is to point Cabal to the LLVM installation directories manually. It is recommended to add options to your global .cabal/config:

extra-include-dirs: /usr/lib/llvm-16/include
extra-lib-dirs: /usr/lib/llvm-16/lib

This works for both v1-build and v2-build. The shown paths work for Debian and Ubuntu using the LLVM repositories at https://apt.llvm.org/. You can obtain them with

llvm-config-16 --includedir --libdir

You can choose specific LLVM versions per project. For v1-builds it works like so:

cabal install -fllvm900 --extra-include-dirs=$(llvm-config-9 --includedir) --extra-lib-dirs=$(llvm-config-9 --libdir) yourpackage

For Nix-style build you must add some options to the cabal.project.local file of your LLVM-related project:

package llvm-ffi
  flags: +llvm900
  extra-include-dirs: /usr/lib/llvm-9/include
  extra-lib-dirs: /usr/lib/llvm-9/lib

The second way uses pkg-config. You can store above paths permanently in a pkg-config file like llvm.pc. The optimal way would be if LLVM installations or GNU/Linux distributions would contain such a file, but they don't. Instead, you may generate it using the llvm-pkg-config package or write one manually. Then you run

cabal install -fpkgConfig

We try to stay up to date with LLVM releases. The current version of this package is compatible with LLVM 8-16. Please understand that the package may or may not work against older LLVM releases.

Warning for inplace builds: Re-configuring the package using, say -fllvm1100, and re-buildung it might result in corrupt code. You must make sure that the stuff in cbits is re-compiled. Cabal or GHC may forget about that. You are safe if you run cabal clean.

Caution: Ugly crashes can occur if you have configured paths for LLVM version X in .cabal/config and try to build llvm-ffi for a different LLVM version Y. Counterintuitively, global search paths have higher precedence than local ones: https://github.com/haskell/cabal/issues/7782. But that does not simply mean that the local configuration is ignored completely. Instead the local library file is found, because its name libLLVM-Y.so is unique, whereas the include file names clash, thus the ones from the global include directory are used.

Metadata

Version

16.0

Maintainers (1)

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows