From 794640e07edcf93d18c565752cba1e3d8bacc624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 11 Feb 2026 21:30:33 +0100 Subject: [PATCH 1/2] Install LLVM DLL in the right place on Windows 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. --- src/bootstrap/src/core/build_steps/dist.rs | 9 +++++---- src/bootstrap/src/core/builder/mod.rs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index eee960027a9f9..4266b2e6237b4 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -35,7 +35,7 @@ use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::channel::{self, Info}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ - exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, + exe, is_dylib, libdir, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, LLVM_TOOLS, Mode, trace}; @@ -2518,7 +2518,7 @@ fn maybe_install_llvm( } } -/// Maybe add libLLVM.so to the target lib-dir for linking. +/// Maybe add libLLVM.so to the target runtime lib-dir. #[cfg_attr( feature = "tracing", instrument( @@ -2533,7 +2533,7 @@ fn maybe_install_llvm( ), )] pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { - let dst_libdir = sysroot.join("lib/rustlib").join(target).join("lib"); + let dst_libdir = sysroot.join("lib/rustlib").join(target).join(libdir(target)); // We do not need to copy LLVM files into the sysroot if it is not // dynamically linked; it is already included into librustc_llvm // statically. @@ -2557,7 +2557,8 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, ), )] 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.sysroot_runtime_libdir_relative(Compiler::new(1, target))); // We do not need to copy LLVM files into the sysroot if it is not // dynamically linked; it is already included into librustc_llvm // statically. diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index a995f5c8a219e..7bf2ccb4b35ce 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1363,6 +1363,25 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler } } + /// Returns the compiler's relative runtime libdir where shared libraries are found for a + /// compiler's sysroot. + /// + /// For example this returns `lib` on Unix and `bin` on Windows. + pub fn sysroot_runtime_libdir_relative(&self, compiler: Compiler) -> PathBuf { + let adjust_path = |path: &Path| -> PathBuf { + if compiler.host.is_windows() || compiler.host.contains("cygwin") { + path.parent().expect("original path should point to `lib` already").join("bin") + } else { + path.to_owned() + } + }; + match self.config.libdir_relative() { + Some(relative_libdir) if compiler.stage >= 1 => adjust_path(relative_libdir), + _ if compiler.stage == 0 => adjust_path(&self.build.initial_relative_libdir), + _ => PathBuf::from(libdir(compiler.host)), + } + } + pub fn rustc_lib_paths(&self, compiler: Compiler) -> Vec { let mut dylib_dirs = vec![self.rustc_libdir(compiler)]; From 813f3fa60565e5bf0791e0949f4c7e886080c198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 28 Jan 2026 21:10:05 +0100 Subject: [PATCH 2/2] Build shared LLVM lib for gnullvm --- src/ci/github-actions/jobs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 6e07ffc43bc21..9fa9577189f11 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -691,6 +691,7 @@ auto: --target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm --enable-full-tools --enable-profiler + --enable-llvm-link-shared DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift CC_i686_pc_windows_gnullvm: i686-w64-mingw32-clang @@ -703,6 +704,7 @@ auto: --build=x86_64-pc-windows-gnullvm --enable-full-tools --enable-profiler + --enable-llvm-link-shared DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift <<: *job-windows