11 stdenv.mkDerivation rec {
15 src = fetchFromGitHub {
18 rev = "${pname}-${version}";
19 sha256 = "sha256-3ibr8AHzo7txX1U+9oOWA60qeeJs/OGeevv+sgBwQa0=";
23 # Add the --disable-general-dynamic-tls configure option:
24 # https://bugzilla.redhat.com/show_bug.cgi?id=1483558
26 url = "https://src.fedoraproject.org/rpms/gperftools/raw/f62d87a34f56f64fb8eb86727e34fbc2d3f5294a/f/gperftools-2.7.90-disable-generic-dynamic-tls.patch";
27 sha256 = "02falhpaqkl27hl1dib4yvmhwsddmgbw0krb46w31fyf3awb2ydv";
31 nativeBuildInputs = [ autoreconfHook ];
33 # tcmalloc uses libunwind in a way that works correctly only on non-ARM dynamically linked linux
37 stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isStatic)
40 # Disable general dynamic TLS on AArch to support dlopen()'ing the library:
41 # https://bugzilla.redhat.com/show_bug.cgi?id=1483558
42 configureFlags = lib.optional stdenv.hostPlatform.isAarch "--disable-general-dynamic-tls";
44 prePatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
45 substituteInPlace Makefile.am --replace stdc++ c++
48 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-D_XOPEN_SOURCE";
50 # some packages want to link to the static tcmalloc_minimal
51 # to drop the runtime dependency on gperftools
52 dontDisableStatic = true;
54 enableParallelBuilding = true;
57 homepage = "https://github.com/gperftools/gperftools";
58 description = "Fast, multi-threaded malloc() and nifty performance analysis tools";
59 platforms = platforms.all;
60 license = licenses.bsd3;
61 maintainers = with maintainers; [ vcunat ];