nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch,
6 autoreconfHook,
7 libunwind,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "gperftools";
12 version = "2.17.2";
13
14 src = fetchFromGitHub {
15 owner = "gperftools";
16 repo = "gperftools";
17 tag = "gperftools-${finalAttrs.version}";
18 hash = "sha256-WCEuiSjNIX/KhEBWndyVhrKlWs7H60mcHoPlWd7YWC4=";
19 };
20
21 patches = [
22 # Add the --disable-general-dynamic-tls configure option:
23 # https://bugzilla.redhat.com/show_bug.cgi?id=1483558
24 (fetchpatch {
25 url = "https://src.fedoraproject.org/rpms/gperftools/raw/88ce8ee43a12b1a8146781a1b4d9abbd8df8af0e/f/gperftools-2.17-disable-generic-dynamic-tls.patch";
26 hash = "sha256-IOLUf9mCEA+fVSJKU94akcnXTIm7+t+S9cjBHsEDwFA=";
27 })
28 ]
29 ++ lib.optionals stdenv.hostPlatform.isMinGW [
30 ./mingw-disable-benchmarks.patch
31 ];
32
33 nativeBuildInputs = [ autoreconfHook ];
34
35 # tcmalloc uses libunwind in a way that works correctly only on non-ARM dynamically linked linux
36 buildInputs = lib.optional (
37 stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isStatic)
38 ) libunwind;
39
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";
43
44 prePatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
45 substituteInPlace Makefile.am --replace stdc++ c++
46 '';
47
48 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-D_XOPEN_SOURCE";
49
50 # some packages want to link to the static tcmalloc_minimal
51 # to drop the runtime dependency on gperftools
52 dontDisableStatic = true;
53
54 enableParallelBuilding = true;
55
56 meta = {
57 changelog = "https://github.com/gperftools/gperftools/releases/tag/${finalAttrs.src.tag}";
58 homepage = "https://github.com/gperftools/gperftools";
59 description = "Fast, multi-threaded malloc() and nifty performance analysis tools";
60 platforms = lib.platforms.all;
61 license = lib.licenses.bsd3;
62 maintainers = with lib.maintainers; [ vcunat ];
63 };
64})