Finding LLVM location for use with the inkwell Rust crate

Sorry if I mix up some terminology, I’m new to using LLVM and Nix. This is what I am currently using with nix-shell:

with import <nixpkgs> { };

  moz_overlay = import (builtins.fetchTarball
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };

  rust = (nixpkgs.rustChannelOf {
    date = "2023-03-03";
    channel = "nightly";

in mkShell {
  name = "nightly-rust";

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [

    (rust.override { targets = [ "wasm32-unknown-unknown" ]; })

    # Rust wasm builds

    # for wasm target

    # for LLVM target


  # Set Environment Variables

The wasm stuff is for another part of my project, the relevant bit is the llvmPackages_15.clangUseLLVM package. I can confirm that I am able to use clang to compile LLVM IR along with some C functions for printing.

I am trying to use the inkwell Rust crate for working with LLVM. In Cargo.toml, I have specified the LLVM version using features = ["llvm15-0"]

When I try to compile their example, it gives an error about finding LLVM:

Compiling llvm-sys v150.1.2
error: No suitable version of LLVM was found system-wide or pointed to by LLVM_SYS_150_PREFIX.

I figured that maybe I need to find the location myself and set it as this environment variable, but I’m not sure where to look. Or maybe having just clang isn’t enough and I need to include another Nix package for LLVM? I tried adding llvmPackages_15.llvm, but got the same error message.

1 Like

I’m not specifically familiar, but searching around github ( led me to a few results that all ~look like they’re addressing this same issue with llvm-sys. Here are a couple:

1 Like

Thanks, this got me to the right answer!

For future readers: I needed to add the packages llvmPackages_15.llvm, libxml2, libffi, and set the environment variable LLVM_SYS_150_PREFIX = "${}";

1 Like