1{ version, sha256 }:
2{ stdenv, fetchurl
3# By default, jemalloc puts a je_ prefix onto all its symbols on OSX, which
4# then stops downstream builds (mariadb in particular) from detecting it. This
5# option should remove the prefix and give us a working jemalloc.
6# Causes segfaults with some software (ex. rustc), but defaults to true for backward
7# compatibility.
8, stripPrefix ? stdenv.hostPlatform.isDarwin
9, disableInitExecTls ? false
10}:
11
12with stdenv.lib;
13
14stdenv.mkDerivation rec {
15 name = "jemalloc-${version}";
16 inherit version;
17
18 src = fetchurl {
19 url = "https://github.com/jemalloc/jemalloc/releases/download/${version}/${name}.tar.bz2";
20 inherit sha256;
21 };
22
23 # see the comment on stripPrefix
24 configureFlags = []
25 ++ optional stripPrefix "--with-jemalloc-prefix="
26 ++ optional disableInitExecTls "--disable-initial-exec-tls"
27 ;
28
29 doCheck = true;
30
31 enableParallelBuilding = true;
32
33 meta = with stdenv.lib; {
34 homepage = http://jemalloc.net;
35 description = "General purpose malloc(3) implementation";
36 longDescription = ''
37 malloc(3)-compatible memory allocator that emphasizes fragmentation
38 avoidance and scalable concurrency support.
39 '';
40 license = licenses.bsd2;
41 platforms = platforms.all;
42 };
43}