2022-05-29 17:26:23 +02:00
|
|
|
{ stdenv
|
|
|
|
, runCommand
|
|
|
|
, makeBinaryWrapper
|
|
|
|
, binutils
|
2023-09-15 07:47:42 +02:00
|
|
|
, lib
|
2022-05-29 17:26:23 +02:00
|
|
|
, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
|
|
|
|
}:
|
|
|
|
|
2023-09-15 07:47:42 +02:00
|
|
|
|
2022-05-29 17:26:23 +02:00
|
|
|
runCommand "make-binary-wrapper-test-cross" {
|
|
|
|
nativeBuildInputs = [
|
|
|
|
makeBinaryWrapper
|
|
|
|
binutils
|
|
|
|
];
|
2023-09-15 07:47:42 +02:00
|
|
|
# For x86_64-linux the machine field is
|
|
|
|
# Advanced Micro Devices X86-64
|
|
|
|
# and uses a dash instead of a underscore unlike x86_64-linux in hostPlatform.parsed.cpu.name
|
|
|
|
expectedArch = lib.replaceStrings ["_"] ["-"] expectedArch;
|
2022-05-29 17:26:23 +02:00
|
|
|
} ''
|
|
|
|
touch prog
|
|
|
|
chmod +x prog
|
|
|
|
makeWrapper prog $out
|
|
|
|
read -r _ arch < <($READELF --file-header $out | grep Machine:)
|
|
|
|
if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
|
|
|
|
echo "expected $expectedArch, got $arch"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
''
|