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>
This commit is contained in:
Austin Seipp 2019-12-03 13:41:28 -06:00
parent a431ee8441
commit 4d39209961
No known key found for this signature in database
GPG Key ID: 25D2038DEB08021D

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, cmake { stdenv, fetchFromGitHub, cmake, ninja
, secureBuild ? true , secureBuild ? true
}: }:
@ -6,32 +6,33 @@ let
soext = stdenv.hostPlatform.extensions.sharedLibrary; soext = stdenv.hostPlatform.extensions.sharedLibrary;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "mimalloc-${version}"; pname = "mimalloc";
version = "1.1.0"; version = "1.1.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "microsoft"; owner = "microsoft";
repo = "mimalloc"; repo = pname;
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
sha256 = "1i8pwzpcmbf7dxncb984xrnczn1737xqhf1jaizlyw0k1hpiam4v"; sha256 = "1i8pwzpcmbf7dxncb984xrnczn1737xqhf1jaizlyw0k1hpiam4v";
}; };
nativeBuildInputs = [ cmake ]; nativeBuildInputs = [ cmake ninja ];
enableParallelBuilding = true; enableParallelBuilding = true;
cmakeFlags = stdenv.lib.optional secureBuild [ "-DMI_SECURE=ON" ]; cmakeFlags = stdenv.lib.optional secureBuild [ "-DMI_SECURE=ON" ];
postInstall = '' postInstall = ''
# first, install headers, that's easy
mkdir -p $dev mkdir -p $dev
mv $out/lib/*/include $dev/include mv $out/lib/*/include $dev/include
rm -f $out/lib/libmimalloc*${soext} # weird duplicate # move everything else into place
mv $out/lib/*/libmimalloc*${soext} $out/lib/libmimalloc${soext} mv $out/lib/*/libmimalloc*${soext} $out/lib/libmimalloc${soext}
mv $out/lib/*/libmimalloc*.a $out/lib/libmimalloc.a mv $out/lib/*/libmimalloc*.a $out/lib/libmimalloc.a
mv $out/lib/*/mimalloc*.o $out/lib/mimalloc.o mv $out/lib/*/mimalloc*.o $out/lib/mimalloc.o
rm -rf $out/lib/mimalloc-* # 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" ]; outputs = [ "out" "dev" ];