Change:
// clear why this is the case, though. llvm-config will emit the versioned // paths and we don't want those in the sysroot (as we're expecting // unversioned paths). <del> if target.contains("apple-darwin") { </del> <ins> if target.contains("apple-darwin") && builder.config.llvm_link_shared { </ins> let src_libdir = builder.llvm_out(target).join("lib"); let llvm_dylib_path = src_libdir.join("libLLVM.dylib"); if llvm_dylib_path.exists() { builder.install(&llvm_dylib_path, dst_libdir, 0o644); } <ins> !builder.config.dry_run </ins> } else if let Ok(llvm_config) = crate::native::prebuilt_llvm_config(builder, target) { <del> let files = output(Command::new(llvm_config).arg("--libfiles")); for file in files.lines() { </del> <ins> let mut cmd = Command::new(llvm_config); cmd.arg("--libfiles"); builder.verbose(&format!("running {:?}", cmd)); let files = output(&mut cmd); for file in files.trim_end().split(' ') { </ins> builder.install(Path::new(file), dst_libdir, 0o644); } <ins> !builder.config.dry_run } else { false </ins> } } /// Maybe add libLLVM.so to the target lib-dir for linking. pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { let dst_libdir = sysroot.join("lib/rustlib").join(&*target.triple).join("lib"); <del> maybe_install_llvm(builder, target, &dst_libdir); </del> <ins> // 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. if builder.config.llvm_link_shared { maybe_install_llvm(builder, target, &dst_libdir); } </ins> } /// Maybe add libLLVM.so to the runtime lib-dir for rustc itself. pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) { let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler { stage: 1, host: target })); <del> maybe_install_llvm(builder, target, &dst_libdir); </del> <ins> // 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. if builder.config.llvm_link_shared { maybe_install_llvm(builder, target, &dst_libdir); } </ins> } #[derive(Clone, Debug, Eq, Hash, PartialEq)]

Discussion:
From Switching to static linking would preclude any of the improvements from , so it would be better to use dynamic linking instead which would allow any contributor to get started without building LLVM from source or using system LLVM. That said, it sounds like dynamic linking will be very hard to do on other platforms. cc
Cc - do we know what the right way to bring the issues (bugs?) I found to LLVM developers? Are there active maintainers of LLVMs build system?
LLVM’s bugzilla is pretty much the only place for bug reports. If its something less defined than a precise bug report, talking it out on the mailing lists is the way to go.
In which way is static linking making downloaded LLVM impossible?
I don't think it's impossible to download/ship the statically linked LLVM, it's something I want to explore. That said, we want to move to dynamically linking LLVM because we ideally want to be applying ThinLTO to LLVM everywhere, not just on x86_64-unknown-linux-gnu, and since LTO happens at link-time, we want that to happen once, not on the multiple LLVM links occurring during CI.