2022-05-10 15:51:43 +02:00
|
|
|
{ stdenv
|
2022-05-29 17:26:23 +02:00
|
|
|
, targetPackages
|
2022-05-10 15:51:43 +02:00
|
|
|
, lib
|
|
|
|
, makeSetupHook
|
|
|
|
, dieHook
|
2022-05-11 22:00:24 +02:00
|
|
|
, writeShellScript
|
2022-05-10 15:51:43 +02:00
|
|
|
, tests
|
2022-05-29 17:26:23 +02:00
|
|
|
, cc ? targetPackages.stdenv.cc
|
2022-05-10 15:51:43 +02:00
|
|
|
, sanitizers ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
makeSetupHook {
|
2022-05-10 16:08:46 +02:00
|
|
|
deps = [ dieHook ]
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/148189
|
2022-05-22 21:46:06 +02:00
|
|
|
++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) cc;
|
2022-05-10 15:51:43 +02:00
|
|
|
|
|
|
|
substitutions = {
|
2022-05-29 17:26:23 +02:00
|
|
|
cc = "${cc}/bin/${cc.targetPrefix}cc ${lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)}";
|
2022-08-13 10:29:10 +02:00
|
|
|
};
|
2022-05-10 15:51:43 +02:00
|
|
|
|
2022-08-13 10:29:10 +02:00
|
|
|
passthru = {
|
2022-05-11 22:00:24 +02:00
|
|
|
# Extract the function call used to create a binary wrapper from its embedded docstring
|
2022-08-13 10:29:10 +02:00
|
|
|
extractCmd = writeShellScript "extract-binary-wrapper-cmd" ''
|
2022-05-11 22:00:24 +02:00
|
|
|
strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p'
|
|
|
|
'';
|
|
|
|
|
2022-08-13 10:29:10 +02:00
|
|
|
tests = tests.makeBinaryWrapper;
|
2022-05-10 15:51:43 +02:00
|
|
|
};
|
|
|
|
} ./make-binary-wrapper.sh
|