Skip to content

Expose LLVM artifacts and fix warnings#1

Merged
Dragnalith merged 6 commits into
Dragnalith:mainfrom
mxpv:fixes
May 9, 2026
Merged

Expose LLVM artifacts and fix warnings#1
Dragnalith merged 6 commits into
Dragnalith:mainfrom
mxpv:fixes

Conversation

@mxpv

@mxpv mxpv commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for this project!

I'm building a project that mixes C++ and Rust (with Rust bindgen for FFI bindings). It builds on macOS via toolchains_llvm, but I hit a few gaps while trying to bridge the Windows build up via toolchains_msvc:

  • clang-format and clang-tidy are shipped in the LLVM tarball but aren't exposed as Bazel targets — aspects often run them against C++ sources.
  • libclang (DLL + import library) isn't exposed either, so Rust bindgen — which links against the Clang C API — can't locate it.
  • Per-version LLVM repos aren't declared as direct dependencies of the extension, so consumers that reach into them via use_repo(...) get Bazel's imported but reported as indirect dependencies warning.
  • Drops lock files. These are already gitignored, but not removed from the repository. Since my changes update them, I decided to remove the before.
  • -gno-codeview-command-line sits in the clang frontend's base_compile_flags but only has an effect alongside -gcodeview. Clang emits "argument unused during compilation" on every non debug compile. Moved alongside -gcodeview so both flags travel together
  • Clang's own intrinsic headers (at lib/clang/<version>/include/) aren't on the include search path, so SSE intrinsics (_mm_rsqrt_ss etc.) resolve to MSVC's extern declarations from the Windows SDK and fail to link. Wired the path into include_paths for both clang and clang-cl (msvc-cl is unaffected — native MSVC handles its own headers.)

mxpv added 3 commits April 18, 2026 12:16
These are not used by the toolchain itself but are often useful to
third-party tools and IDEs as complementary developer tools.
libclang is Clang's C API as a shared library. Exposing it here lets
downstream rules (most commonly Rust bindgen for generating FFI bindings
against C/C++ headers) consume the already-extracted DLL and import
library without a separate LLVM download.
Fixes the "imported but reported as indirect dependencies" warning for
consumers that `use_repo` an `llvm_<version>_<host>` repo.
@mxpv mxpv changed the title Expose clang-format, clang-tidy, and libclang from the LLVM distribution Expose LLVM artifacts Apr 18, 2026
mxpv added 2 commits April 18, 2026 14:48
Follow-up to e5b8d11 which added these paths to .gitignore.
The flag only affects CodeView output (enabled via -gcodeview). When kept
in base_compile_flags, clang warns "argument unused during compilation"
on every non-debug compile. Move it alongside -gcodeview so both flags
travel together.
@mxpv mxpv changed the title Expose LLVM artifacts Expose LLVM artifacts and fix warnings Apr 18, 2026
Clang ships intrinsic headers (xmmintrin.h, etc.) at
lib/clang/<version>/include/. Without that path on the include search,
Clang falls through to MSVC's headers from the Windows SDK sysroot,
which declare SSE intrinsics as `extern` rather than inline — leaving
them as unresolved symbols at link time.

Wire lib/clang/<version>/include/ into the `include_paths` cc_args for
both `clang` and `clang-cl` frontends, so Clang's own headers are
found first.

Resolve the {LLVM_VERSION} placeholder via ctx.template substitution
in private/llvm_repo.bzl so the path materializes to a concrete version.
@Dragnalith

Copy link
Copy Markdown
Owner

It is good improvement. I am expected a lot of corner cases like this, and I am glad people are contributing to fixing them.
Also good PR, good description, and good commit message. It was very easy to review.

I have enabled auto-merge. If the test pass, it will be merged.

Thank you

@Dragnalith Dragnalith enabled auto-merge (rebase) May 9, 2026 04:53
@Dragnalith Dragnalith disabled auto-merge May 9, 2026 08:34
@Dragnalith Dragnalith merged commit 671f483 into Dragnalith:main May 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants