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> { };
let
moz_overlay = import (builtins.fetchTarball
"https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
rust = (nixpkgs.rustChannelOf {
date = "2023-03-03";
channel = "nightly";
}).rust;
in mkShell {
name = "nightly-rust";
nativeBuildInputs = [ pkg-config ];
buildInputs = [
(rust.override { targets = [ "wasm32-unknown-unknown" ]; })
# Rust wasm builds
wasm-pack
openssl
# for wasm target
wabt
nodejs_18
# for LLVM target
llvmPackages_15.clangUseLLVM
];
# Set Environment Variables
RUST_BACKTRACE = 1;
}
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.