diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 38c16fb1cd6d5..cf50e866b22cc 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -402,6 +402,14 @@ fn main() { continue; } + let name = + if target.contains("apple-darwin") && llvm_kind == "dylib" && name.starts_with("LLVM-") + { + "LLVM" + } else { + name + }; + let kind = if name.starts_with("LLVM") { llvm_kind } else if is_static { diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 52b11615c76f0..98c32590f690b 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -57,6 +57,9 @@ pub fn walk_native_lib_search_dirs( f(&sess.target_tlib_path.dir.join("self-contained"), false)?; } + let has_shared_llvm_apple_darwin = + sess.target.is_like_darwin && sess.target_tlib_path.dir.join("libLLVM.dylib").exists(); + // Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot // library directory instead of the self-contained directories. // Sanitizer libraries have the same issue and are also linked by name on Apple targets. @@ -72,7 +75,8 @@ pub fn walk_native_lib_search_dirs( || sess.target.os == Os::Linux || sess.target.os == Os::Fuchsia || sess.target.is_like_aix - || sess.target.is_like_darwin && !sess.sanitizers().is_empty() + || sess.target.is_like_darwin + && (!sess.sanitizers().is_empty() || has_shared_llvm_apple_darwin) || sess.target.os == Os::Windows && sess.target.env == Env::Gnu && sess.target.abi == Abi::Llvm diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 0687d142a3504..c06c85513856b 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -504,7 +504,7 @@ auto: - name: dist-aarch64-apple env: SCRIPT: >- - ./x.py dist bootstrap + ./x.py dist bootstrap enzyme --include-default-paths --host=aarch64-apple-darwin --target=aarch64-apple-darwin @@ -513,6 +513,7 @@ auto: --enable-sanitizers --enable-profiler --set rust.jemalloc + --set llvm.link-shared=true --set rust.lto=thin --set rust.codegen-units=1 # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else