rustllvm

llvm-sys - Didn't find usable system-wide LLVM


I'm trying to learn LLVM to make a programming language using Rust. I am using the llvm-sys crate that wraps around the LLVM API.

I have installed LLVM : LLVM-8.0.0-win64

My dependencies in cargo.toml

[dependencies]
llvm-sys = "80.1.1"

When I run cargo run I get the following error,

    Updating crates.io index
   Compiling memchr v2.2.1
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.12
   Compiling semver-parser v0.7.0
   Compiling libc v0.2.65
   Compiling cc v1.0.47
   Compiling thread_local v0.3.6
   Compiling semver v0.9.0
   Compiling aho-corasick v0.7.6
   Compiling regex v1.3.1
   Compiling llvm-sys v80.1.1
error: failed to run custom build command for `llvm-sys v80.1.1`

Caused by:
  process didn't exit successfully: `C:\Users\Name\Desktop\Carbon\carbon-lang\target\debug\build\llvm-sys-ed5d351b1ae6a41b\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=LLVM_SYS_80_PREFIX
cargo:rerun-if-env-changed=LLVM_SYS_80_IGNORE_BLACKLIST
cargo:rerun-if-env-changed=LLVM_SYS_80_STRICT_VERSIONING
cargo:rerun-if-env-changed=LLVM_SYS_80_NO_CLEAN_CFLAGS
cargo:rerun-if-env-changed=LLVM_SYS_80_USE_DEBUG_MSVCRT
cargo:rerun-if-env-changed=LLVM_SYS_80_FFI_WORKAROUND
Didn't find usable system-wide LLVM.

--- stderr
thread 'main' panicked at 'Failed to execute "C:\\Program Files\\LLVM\\bin\\llvm-config": Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', src\libcore\result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

But I have set the LLVM_SYS_80_PREFIX as C:\Program Files\LLVM which is where the bin folder is.

Should the llvm-config file be separately installed? I could not find it anywhere.

I'm on Windows 10


Solution

  • llvm-config is a developer-side tool, it is not shipped with binaries. You need to build LLVM from sources.