-
-
Notifications
You must be signed in to change notification settings - Fork 508
Description
Describe the bug
When cross-compiling to a host platform whose binaries are executable by the build system (e.g. x86_64-linux-gnu -> x86_64-linux-musl cross), it is typically possible to also run that packages' tests. This cross-compilation behavior has recently been enabled in nixpkgs.
patchelf's tests refer to unprefixed bintools binaries on the path, which does not work in this scenario, since in cross-compiling scenarios these binaries will be prepended with the host's targetPrefix. E.g. for the previous example, we need to use x86_64-unknown-linux-musl-readelf
instead of plain readelf
.
Steps To Reproduce
nix-build '<nixpkgs>' -A pkgsCross.musl64.patchelf
An example failure log can be viewed here: https://hydra.nixos.org/build/194616146/nixlog/2
Expected behavior
patchelf should either detect the targetPrefix from the toolchain, or allow the user to specify the targetPrefix at configure time.
Here is a postPatch for nixpkgs' patchelf derivation which currently fixes this, for patchelf 0.15:
postPatch = ''
substituteInPlace tests/add-debug-tag.sh --replace \
'$(readelf' '$(${stdenv.cc.targetPrefix}readelf'
substituteInPlace tests/no-rpath-pie-powerpc.sh --replace \
'$(readelf' '$(${stdenv.cc.targetPrefix}readelf'
substituteInPlace tests/force-rpath.sh --replace \
'$(objdump' '$(${stdenv.cc.targetPrefix}objdump'
substituteInPlace tests/phdr-corruption.sh --replace \
'$(readelf' '$(${stdenv.cc.targetPrefix}readelf'
substituteInPlace tests/no-gnu-hash.sh --replace \
strip ${stdenv.cc.targetPrefix}strip
'';
However, it is probably more robust to address this upstream.