mstorsjo / llvm-mingw

An LLVM/Clang/LLD based mingw-w64 toolchain
Other
1.88k stars 184 forks source link

Add llvm-config to distribution #434

Open clin1234 opened 3 months ago

clin1234 commented 3 months ago

I'm trying to compile a Rust package, specifically ClangQL, that relies on a crate that, in turn, relies on a few features not included by default:

The following warnings were emitted during compilation:

warning: clang-sys@1.8.1: could not execute `llvm-config` one or more times, if the LLVM_CONFIG_PATH environment variable is set to a full path to valid `llvm-config` executable it will be used to try to find an instance of `libclang` on your system: "couldn't execute `llvm-config --prefix` (path=llvm-config) (error: program not found)"

error: failed to run custom build command for `clang-sys v1.8.1`

Caused by:
  process didn't exit successfully: `C:\Users\0BAC~1\AppData\Local\Temp\cargo-install7y9kS3\release\build\clang-sys-4522d44d0baf573c\build-script-build` (exit code: 101)
  --- stdout
  cargo:warning=could not execute `llvm-config` one or more times, if the LLVM_CONFIG_PATH environment variable is set to a full path to valid `llvm-config` executable it will be used to try to find an instance of `libclang` on your system: "couldn't execute `llvm-config --prefix` (path=llvm-config) (error: program not found)"

  --- stderr
  thread 'main' panicked at C:\Users\ךינשגכהד\.cargo\registry\src\index.crates.io-6f17d22bba15001f\clang-sys-1.8.1\build\dynamic.rs:225:45:
  called `Result::unwrap()` on an `Err` value: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `clangql v0.6.0 (https://github.com/AmrDeveloper/ClangQL#7e4e2add)`, intermediate artifacts can be found at `C:\Users\0BAC~1\AppData\Local\Temp\cargo-install7y9kS3`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
mstorsjo commented 3 months ago

Sorry, in most cases, if something requires llvm-config, it usually also intends to compile and link against the Clang/LLVM libraries - so it probably wouldn't be enough to just add the lone llvm-config binary, but it would also require including all the headers and link libraries. That increases the size of the distribution packages quite significantly.

It's quite straightforward to try this out for yourself, though, add --full-llvm to the invocation of build-cross-tools.sh (or the invocations of build-all.sh to have it included for the unix packages) in .github/workflows/build.yml, enable github actions on your fork of the repo, and push this modification to a branch in your fork.