1{
2 stdenv,
3 runCommand,
4 makeBinaryWrapper,
5 binutils,
6 lib,
7 expectedArch ? stdenv.hostPlatform.parsed.cpu.name,
8}:
9
10runCommand "make-binary-wrapper-test-cross"
11 {
12 nativeBuildInputs = [
13 makeBinaryWrapper
14 binutils
15 ];
16 # For x86_64-linux the machine field is
17 # Advanced Micro Devices X86-64
18 # and uses a dash instead of a underscore unlike x86_64-linux in hostPlatform.parsed.cpu.name
19 expectedArch = lib.replaceStrings [ "_" ] [ "-" ] expectedArch;
20 }
21 ''
22 touch prog
23 chmod +x prog
24 makeWrapper prog $out
25 read -r _ arch < <($READELF --file-header $out | grep Machine:)
26 if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
27 echo "expected $expectedArch, got $arch"
28 exit 1
29 fi
30 ''