mimalloc: fix one final time

The library link name is embedded in the ELF executable, so renaming the
file doesn't work. This patch just bites the bullet and writes two
separate code paths for the secure vs non-secure build...

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2019-12-06 18:16:56 -06:00
parent 88f24e842b
commit 3c5767335e
No known key found for this signature in database
GPG key ID: 25D2038DEB08021D

View file

@ -1,5 +1,5 @@
{ stdenv, fetchFromGitHub, cmake, ninja
, secureBuild ? true
, secureBuild ? false
}:
let
@ -25,17 +25,21 @@ stdenv.mkDerivation rec {
mkdir -p $dev
mv $out/lib/*/include $dev/include
# move everything else into place
mv $out/lib/mimalloc-1.0/libmimalloc*${soext}.1.0 $out/lib/libmimalloc${soext}
# move .a and .o files into place
mv $out/lib/mimalloc-1.0/libmimalloc*.a $out/lib/libmimalloc.a
mv $out/lib/mimalloc-1.0/mimalloc*.o $out/lib/mimalloc.o
'' + (if secureBuild then ''
mv $out/lib/mimalloc-1.0/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc-secure${soext}.1.0
ln -sfv $out/lib/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc-secure${soext}
ln -sfv $out/lib/libmimalloc-secure${soext}.1.0 $out/lib/libmimalloc${soext}
'' else ''
mv $out/lib/mimalloc-1.0/libmimalloc${soext}.1.0 $out/lib/libmimalloc${soext}.1.0
ln -sfv $out/lib/libmimalloc${soext}.1.0 $out/lib/libmimalloc${soext}
'') + ''
# remote duplicate dir. FIXME: try to fix the .cmake file distribution
# so we can re-use it for dependencies...
rm -rf $out/lib/mimalloc-1.0
'' + stdenv.lib.optionalString secureBuild ''
# fix a broken symlink for the -secure alias
ln -sfv $out/lib/libmimalloc.so $out/lib/libmimalloc-secure.so
'';
outputs = [ "out" "dev" ];