diff --git a/lib/mk-component-set.nix b/lib/mk-component-set.nix index 3a75b978..eba36dfa 100644 --- a/lib/mk-component-set.nix +++ b/lib/mk-component-set.nix @@ -143,6 +143,25 @@ let fi '' + # Darwin rustlib helper tools live under `lib/rustlib//bin` + # and use `@loader_path/../lib`, so expose rustc's LLVM dylib there. + + optionalString (hostPlatform.isDarwin && pname == "rustc") '' + if [[ -e "$out/lib/libLLVM.dylib" ]]; then + for binDir in "$out"/lib/rustlib/*/bin; do + if [[ ! -d "$binDir" ]]; then + continue + fi + if [[ -e "$binDir/rust-lld" || -e "$binDir/rust-objcopy" || -e "$binDir/wasm-component-ld" ]]; then + libDir="$(dirname "$binDir")/lib" + mkdir -p "$libDir" + if [[ ! -e "$libDir/libLLVM.dylib" && ! -L "$libDir/libLLVM.dylib" ]]; then + ln -s ../../../libLLVM.dylib "$libDir/libLLVM.dylib" + fi + fi + done + fi + '' + # Wrap the shipped `rust-lld` (lld), which is used by default on some targets. # Unfortunately there is no hook to conveniently wrap CC tools inside # derivation and `wrapBintools` is designed for wrapping a standalone diff --git a/tests/default.nix b/tests/default.nix index d43d5e5e..7f4a0aba 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -48,6 +48,7 @@ let date = "2026-01-10"; version = "1.93.0-beta.6-2026-01-10"; }; + sharedLlvmNightly = "2026-06-02"; in # Check only tier 1 targets. @@ -236,4 +237,17 @@ optionalAttrs targets = [ "x86_64-apple-darwin" ]; targetExtensions = [ "rust-docs" ]; }; + aarch64-darwin-rustlib-tools-shared-llvm = + pkgs.runCommand "aarch64-darwin-rustlib-tools-shared-llvm" { } + '' + for rustlib in \ + "${nightly.${sharedLlvmNightly}.rustc}/lib/rustlib/${rustHostPlatform}" \ + "${nightly.${sharedLlvmNightly}.default}/lib/rustlib/${rustHostPlatform}" + do + "$rustlib/bin/rust-lld" -flavor wasm --version + "$rustlib/bin/rust-objcopy" --version + "$rustlib/bin/wasm-component-ld" --version + done + touch "$out" + ''; }