1{ stdenv
2, runCommand
3, makeBinaryWrapper
4, binutils
5, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
6}:
7
8runCommand "make-binary-wrapper-test-cross" {
9 nativeBuildInputs = [
10 makeBinaryWrapper
11 binutils
12 ];
13 inherit expectedArch;
14} ''
15 touch prog
16 chmod +x prog
17 makeWrapper prog $out
18 read -r _ arch < <($READELF --file-header $out | grep Machine:)
19 if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
20 echo "expected $expectedArch, got $arch"
21 exit 1
22 fi
23''