From a5db992e6cfef4c0183ba84e7d2d4dd6088d3276 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Thu, 27 Aug 2026 09:49:07 +0200 Subject: [PATCH] rust: fix 1.98.0 build on darwin Since 1.98.0 the darwin tarball links LLVM dynamically and ships an unversioned libLLVM.dylib (rust-lang/rust#157205). This shadows our nixpkgs-built libLLVM.dylib when we run our own toolchain, leading to missing symbols. Rename the dylib that upstream ships to avoid the shadowing, similar to what upstream already does for linux. (cherry picked from commit 5b4742e823054dbfa66d3cc5ac67d6048eb12b48) --- pkgs/development/compilers/rust/binary.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/development/compilers/rust/binary.nix b/pkgs/development/compilers/rust/binary.nix index 7bf77a6832a2..a82bba68ee04 100644 --- a/pkgs/development/compilers/rust/binary.nix +++ b/pkgs/development/compilers/rust/binary.nix @@ -65,6 +65,22 @@ rec { + lib.optionalString stdenv.hostPlatform.isDarwin '' install_name_tool -change "/usr/lib/libcurl.4.dylib" \ "${lib.getLib curl}/lib/libcurl.4.dylib" "$out/bin/cargo" + '' + + lib.optionalString (stdenv.hostPlatform.isDarwin && (lib.versionAtLeast version "1.98")) '' + # Since 1.98.0 the darwin tarball links LLVM dynamically and ships an + # unversioned libLLVM.dylib (rust-lang/rust#157205). + # This shadows our nixpkgs-built libLLVM.dylib when we run our own + # toolchain, leading to missing symbols. + # Rename the dylib that upstream ships to avoid the shadowing, similar + # to what upstream already does for linux. + if [ -e "$out/lib/libLLVM.dylib" ]; then + versioned=libLLVM-rust-bootstrap-${version}.dylib + mv "$out/lib/libLLVM.dylib" "$out/lib/$versioned" + install_name_tool -id "@rpath/$versioned" "$out/lib/$versioned" + find "$out/bin" "$out/lib" -type f \( -perm -0100 -o -name '*.dylib' \) \ + -exec install_name_tool -change "@rpath/libLLVM.dylib" \ + "@rpath/$versioned" {} \; + fi ''; # The strip tool in cctools 973.0.1 and up appears to break rlibs in the