9 stdenv.mkDerivation rec {
13 src = fetchFromGitHub {
16 rev = "${pname}-${version}";
17 sha256 = "19bj2vlsbfwq7m826v2ccqg47kd7cb5vcz1yw2x0v5qzhaxbakk1";
21 # Add the --disable-general-dynamic-tls configure option:
22 # https://bugzilla.redhat.com/show_bug.cgi?id=1483558
24 url = "https://src.fedoraproject.org/rpms/gperftools/raw/f62d87a34f56f64fb8eb86727e34fbc2d3f5294a/f/gperftools-2.7.90-disable-generic-dynamic-tls.patch";
25 sha256 = "02falhpaqkl27hl1dib4yvmhwsddmgbw0krb46w31fyf3awb2ydv";
29 nativeBuildInputs = [ autoreconfHook ];
31 # tcmalloc uses libunwind in a way that works correctly only on non-ARM linux
32 buildInputs = lib.optional (stdenv.isLinux && !(stdenv.isAarch64 || stdenv.isAarch32)) libunwind;
34 # Disable general dynamic TLS on AArch to support dlopen()'ing the library:
35 # https://bugzilla.redhat.com/show_bug.cgi?id=1483558
36 configureFlags = lib.optional (stdenv.isAarch32 || stdenv.isAarch64)
37 "--disable-general-dynamic-tls";
39 prePatch = lib.optionalString stdenv.isDarwin ''
40 substituteInPlace Makefile.am --replace stdc++ c++
43 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin
46 # some packages want to link to the static tcmalloc_minimal
47 # to drop the runtime dependency on gperftools
48 dontDisableStatic = true;
50 enableParallelBuilding = true;
53 homepage = "https://github.com/gperftools/gperftools";
54 description = "Fast, multi-threaded malloc() and nifty performance analysis tools";
55 platforms = with platforms; linux ++ darwin;
56 license = licenses.bsd3;
57 maintainers = with maintainers; [ vcunat ];