mk-aggregated: prepend rpath instead of setting it

The original binary may have outstanding RPATH, eg. to libgcc_s, which
must be kept.
This commit is contained in:
oxalica
2024-06-03 15:18:04 -04:00
parent 711ff40be1
commit 025e1742de

View File

@@ -47,7 +47,9 @@ symlinkJoin {
[[ $file != */*clippy* ]] || cp --remove-destination "$(realpath -e $file)" $file
chmod +w $file
${lib.optionalString stdenv.isLinux ''
patchelf --set-rpath $out/lib "$file" || true
if prev_rpath="$(patchelf --print-rpath "$file")"; then
patchelf --set-rpath "$out/lib''${prev_rpath:+:}$prev_rpath" "$file"
fi
''}
${lib.optionalString stdenv.isDarwin ''
install_name_tool -add_rpath $out/lib "$file" || true