nixpkgs/pkgs/development/libraries/mimalloc/default.nix
Austin Seipp 4d39209961
mimalloc: un-break dynamic linking
Previous versions of the build assumed libmimalloc.so would be a hard
copy of mimalloc-secure.so iff secureBuild == true, but in 1.1.0 and
later it seems libmimalloc.so is a symlink to the -secure variant. This
apparently rectifies some behavior I noticed that was strange
previously.

This breakage wasn't caught because the 1.1.0 update was automatic in
5596317d4; there should be a checkPhase to ensure this doesn't happen
again...

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2019-12-03 13:50:14 -06:00

48 lines
1.3 KiB
Nix

{ stdenv, fetchFromGitHub, cmake, ninja
, secureBuild ? true
}:
let
soext = stdenv.hostPlatform.extensions.sharedLibrary;
in
stdenv.mkDerivation rec {
pname = "mimalloc";
version = "1.1.0";
src = fetchFromGitHub {
owner = "microsoft";
repo = pname;
rev = "refs/tags/v${version}";
sha256 = "1i8pwzpcmbf7dxncb984xrnczn1737xqhf1jaizlyw0k1hpiam4v";
};
nativeBuildInputs = [ cmake ninja ];
enableParallelBuilding = true;
cmakeFlags = stdenv.lib.optional secureBuild [ "-DMI_SECURE=ON" ];
postInstall = ''
# first, install headers, that's easy
mkdir -p $dev
mv $out/lib/*/include $dev/include
# move everything else into place
mv $out/lib/*/libmimalloc*${soext} $out/lib/libmimalloc${soext}
mv $out/lib/*/libmimalloc*.a $out/lib/libmimalloc.a
mv $out/lib/*/mimalloc*.o $out/lib/mimalloc.o
# remote duplicate dir. FIXME: try to fix the .cmake file distribution
# so we can re-use it for dependencies...
rm -r $out/lib/mimalloc-1.0/
'';
outputs = [ "out" "dev" ];
meta = with stdenv.lib; {
description = "Compact, fast, general-purpose memory allocator";
homepage = "https://github.com/microsoft/mimalloc";
license = licenses.bsd2;
platforms = platforms.unix;
maintainers = with maintainers; [ thoughtpolice ];
};
}