From e1daacf987d6064bd7dc65a30e7715990bc1c011 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 14 May 2023 04:10:20 +0200 Subject: [PATCH] pahole: patch to force single-threaded mode if reproducibility is desired pahole's processes DWARF -> BTF in a pseudo-random order if multi threading is enabled (default in the Linux kernel). This can be fixed in dependent derivation by making sure users don't ever pass "-j" or "-j N", but it seems easier and safer to just detect whether reprodubility is desired (by proxy: if SOURCE_DATE_EPOCH is set) and ignore the multi-threading flag. --- pkgs/development/tools/misc/pahole/default.nix | 2 ++ .../pahole/threading-reproducibility.patch | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 pkgs/development/tools/misc/pahole/threading-reproducibility.patch diff --git a/pkgs/development/tools/misc/pahole/default.nix b/pkgs/development/tools/misc/pahole/default.nix index 03b2a194d639..8b8d4e8c6e2f 100644 --- a/pkgs/development/tools/misc/pahole/default.nix +++ b/pkgs/development/tools/misc/pahole/default.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation rec { musl-obstack ]; + patches = [ ./threading-reproducibility.patch ]; + # Put libraries in "lib" subdirectory, not top level of $out cmakeFlags = [ "-D__LIB=lib" "-DLIBBPF_EMBEDDED=OFF" ]; diff --git a/pkgs/development/tools/misc/pahole/threading-reproducibility.patch b/pkgs/development/tools/misc/pahole/threading-reproducibility.patch new file mode 100644 index 000000000000..15893ce2d035 --- /dev/null +++ b/pkgs/development/tools/misc/pahole/threading-reproducibility.patch @@ -0,0 +1,18 @@ +diff --git a/pahole.c b/pahole.c +index 6fc4ed6..a4e306f 100644 +--- a/pahole.c ++++ b/pahole.c +@@ -1687,8 +1687,11 @@ static error_t pahole__options_parser(int key, char *arg, + class_name = arg; break; + case 'j': + #if _ELFUTILS_PREREQ(0, 178) +- conf_load.nr_jobs = arg ? atoi(arg) : +- sysconf(_SC_NPROCESSORS_ONLN) * 1.1; ++ // Force single thread if reproducibility is desirable. ++ if (!getenv("SOURCE_DATE_EPOCH")) { ++ conf_load.nr_jobs = arg ? atoi(arg) : ++ sysconf(_SC_NPROCESSORS_ONLN) * 1.1; ++ } + #else + fputs("pahole: Multithreading requires elfutils >= 0.178. Continuing with a single thread...\n", stderr); + #endif