Rollup merge of #152609 - mati865:gnullvm-llvm-dll, r=bjorn3

Install LLVM DLL in the right place on Windows

Continuation of https://github.com/rust-lang/rust/pull/151795 towards https://github.com/rust-lang/rust/issues/151774.

Unlike other systems, Windows requires runtime libraries to be present in `PATH` or right next to the binary.
So, we copy the library next to the binary as the easier solution.

Tested building `rust-openssl` in debug and release modes, but the difference is within noise margin.
This commit is contained in:
Jana Dönszelmann 2026-02-17 14:18:43 +01:00 committed by GitHub
commit 485f76b835
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -61,6 +61,8 @@ pub fn walk_native_lib_search_dirs<R>(
// library directory instead of the self-contained directories. // library directory instead of the self-contained directories.
// Sanitizer libraries have the same issue and are also linked by name on Apple targets. // Sanitizer libraries have the same issue and are also linked by name on Apple targets.
// The targets here should be in sync with `copy_third_party_objects` in bootstrap. // The targets here should be in sync with `copy_third_party_objects` in bootstrap.
// Finally there is shared LLVM library, which unlike compiler libraries, is linked by the name,
// therefore requiring the search path for the linker.
// FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind // FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
// and sanitizers to self-contained directory, and stop adding this search path. // and sanitizers to self-contained directory, and stop adding this search path.
// FIXME: On AIX this also has the side-effect of making the list of library search paths // FIXME: On AIX this also has the side-effect of making the list of library search paths
@ -71,6 +73,9 @@ pub fn walk_native_lib_search_dirs<R>(
|| sess.target.os == Os::Fuchsia || sess.target.os == Os::Fuchsia
|| sess.target.is_like_aix || sess.target.is_like_aix
|| sess.target.is_like_darwin && !sess.sanitizers().is_empty() || sess.target.is_like_darwin && !sess.sanitizers().is_empty()
|| sess.target.os == Os::Windows
&& sess.target.env == Env::Gnu
&& sess.target.abi == Abi::Llvm
{ {
f(&sess.target_tlib_path.dir, false)?; f(&sess.target_tlib_path.dir, false)?;
} }

View file

@ -2557,7 +2557,7 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection,
), ),
)] )]
pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler::new(1, target))); let dst_libdir = sysroot.join(builder.libdir_relative(Compiler::new(1, target)));
// We do not need to copy LLVM files into the sysroot if it is not // We do not need to copy LLVM files into the sysroot if it is not
// dynamically linked; it is already included into librustc_llvm // dynamically linked; it is already included into librustc_llvm
// statically. // statically.

View file

@ -712,6 +712,7 @@ auto:
--target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm --target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm
--enable-full-tools --enable-full-tools
--enable-profiler --enable-profiler
--enable-llvm-link-shared
DIST_REQUIRE_ALL_TOOLS: 1 DIST_REQUIRE_ALL_TOOLS: 1
CODEGEN_BACKENDS: llvm,cranelift CODEGEN_BACKENDS: llvm,cranelift
CC_i686_pc_windows_gnullvm: i686-w64-mingw32-clang CC_i686_pc_windows_gnullvm: i686-w64-mingw32-clang
@ -724,6 +725,7 @@ auto:
--build=x86_64-pc-windows-gnullvm --build=x86_64-pc-windows-gnullvm
--enable-full-tools --enable-full-tools
--enable-profiler --enable-profiler
--enable-llvm-link-shared
DIST_REQUIRE_ALL_TOOLS: 1 DIST_REQUIRE_ALL_TOOLS: 1
CODEGEN_BACKENDS: llvm,cranelift CODEGEN_BACKENDS: llvm,cranelift
<<: *job-windows <<: *job-windows