I am working with LLVM to build a small compiler in Rust using inkwell (inkwell uses llvm-sys, so it is relevant to it too).
First of all, compiled windows binaries on llvm's github do not include needed tools for building on top of llvm. Also after compiling llvm from sources, I was having an issues of not able to compile said crates, having different errors saying things like "Files/LLVM/Target.h not found!", etc.
First of all some solutions that worked for some people:
Cleaning the project (
cargo clean)Adding "<installation path>/LLVM/bin" to env Path.
If you are using inkwell, you still need to reference appropriate llvm-sys version in
Cargo.toml:llvm-sys-160 = { package="llvm-sys", version = "160.1.4" } # For LLVM 16.x
Turns out llvm-sys doesn't understand spaces in the path to LLVM (default installation path for LLVM is
C:\Program Files\LLVM\). So the whole solution will be install it into the directory with no spaces:(Delete LLVM, if you already have one, -> install cmake and visual studio (I used 2022))
(Everything is done from VS Developer Console)
Visual C++ ATL v141-143orC++ ATL for latest v141-143git clone https://github.com/llvm/llvm-project.git --branch release/16.x(change the release version to one you need, it has to have format ofrelease/<major>.x)cd llvm-project->cd llvm->mkdir build->cd buildcmake .. "-DCMAKE_INSTALL_PREFIX=C:\LLVM\"(add more cmake flags if you want)cmake --build . --target install --config ReleaseC:\LLVM\binis in your PATH, if not add it. Done, this should allows the llvm-sys/inkwell to build.