about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/pahole
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/tools/misc/pahole')
-rw-r--r--nixpkgs/pkgs/development/tools/misc/pahole/default.nix46
-rw-r--r--nixpkgs/pkgs/development/tools/misc/pahole/threading-reproducibility.patch18
2 files changed, 64 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/misc/pahole/default.nix b/nixpkgs/pkgs/development/tools/misc/pahole/default.nix
new file mode 100644
index 000000000000..8b8d4e8c6e2f
--- /dev/null
+++ b/nixpkgs/pkgs/development/tools/misc/pahole/default.nix
@@ -0,0 +1,46 @@
+{ lib
+, stdenv
+, fetchzip
+, pkg-config
+, libbpf
+, cmake
+, elfutils
+, zlib
+, argp-standalone
+, musl-obstack
+, nixosTests
+}:
+
+stdenv.mkDerivation rec {
+  pname = "pahole";
+  version = "1.25";
+  src = fetchzip {
+    url = "https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot/pahole-${version}.tar.gz";
+    hash = "sha256-s0YVT2UnMSO8jS/4XCt06wNPV4czHH6bmZRy/snO3jg=";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ elfutils zlib libbpf ]
+    ++ lib.optionals stdenv.hostPlatform.isMusl [
+    argp-standalone
+    musl-obstack
+  ];
+
+  patches = [ ./threading-reproducibility.patch ];
+
+  # Put libraries in "lib" subdirectory, not top level of $out
+  cmakeFlags = [ "-D__LIB=lib" "-DLIBBPF_EMBEDDED=OFF" ];
+
+  passthru.tests = {
+    inherit (nixosTests) bpf;
+  };
+
+  meta = with lib; {
+    homepage = "https://git.kernel.org/pub/scm/devel/pahole/pahole.git/";
+    description = "Shows, manipulates, and pretty-prints debugging information in DWARF, CTF, and BTF formats";
+    license = licenses.gpl2Only;
+
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ bosu martinetd ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/tools/misc/pahole/threading-reproducibility.patch b/nixpkgs/pkgs/development/tools/misc/pahole/threading-reproducibility.patch
new file mode 100644
index 000000000000..15893ce2d035
--- /dev/null
+++ b/nixpkgs/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