darwin/make-bootstrap-tools: move "lib" from install name to rpath

The rpath structure for the bootstrap tools was reworked to minimize
the amount of rewriting required on unpack, but the test was not
updated to match the different structure.

Additionally [1] builds that use the bootstrap version of libc++
cannot find libc++abi if the reference includes the "lib"
component (ie, libc++ refers to libc++abi with
@rpath/lib/libc++abi.dylib).

[1] https://logs.nix.samueldr.com/nix-darwin/2021-05-18#4993282

Test failure observed on Hydra: https://hydra.nixos.org/build/143130126

(cherry picked from commit 38207735f4)
This commit is contained in:
Andrew Childs 2021-05-24 14:15:09 +09:00 committed by Jonathan Ringer
parent 677fab12a9
commit d2920be368

View File

@ -136,9 +136,7 @@ in rec {
local libs=$(${stdenv.cc.targetPrefix}otool -L "$1" | tail -n +2 | grep -o "$NIX_STORE.*-\S*") || true
local newlib
for lib in $libs; do
newlib=''${lib:${toString (storePrefixLen + 1)}}
newlib=''${newlib#*/}
${stdenv.cc.targetPrefix}install_name_tool -change $lib "@rpath/$newlib" "$1"
${stdenv.cc.targetPrefix}install_name_tool -change $lib "@rpath/$(basename "$lib")" "$1"
done
}
@ -160,7 +158,7 @@ in rec {
for i in $out/bin/*; do
if test -x "$i" -a ! -L "$i" -a "$(basename $i)" != codesign; then
echo "Adding @executable_path to rpath in $i"
${stdenv.cc.targetPrefix}install_name_tool -add_rpath '@executable_path/..' $i
${stdenv.cc.targetPrefix}install_name_tool -add_rpath '@executable_path/../lib' $i
fi
done