forked from M-Labs/nac3
1
0
Fork 0

flake: provide mimalloc-enabled Python

The Linux linker and the libc are garbage, so there isn't much of an alternative to using the Nix wrapper and LD_PRELOAD.
This commit is contained in:
Sebastien Bourdeauducq 2022-01-04 21:52:26 +08:00
parent 7193e3f328
commit 4904610dc6
1 changed files with 6 additions and 2 deletions

View File

@ -66,6 +66,10 @@
''; '';
} }
); );
python3-mimalloc = pkgs.python3 // rec {
withMimalloc = pkgs.python3.buildEnv.override({ makeWrapperArgs = [ "--set LD_PRELOAD ${pkgs.mimalloc}/lib/libmimalloc.so" ]; });
withPackages = f: let packages = f pkgs.python3.pkgs; in withMimalloc.override { extraLibs = packages; };
};
# LLVM PGO support # LLVM PGO support
llvm-nac3-instrumented = pkgs.callPackage "${self}/llvm" { llvm-nac3-instrumented = pkgs.callPackage "${self}/llvm" {
@ -96,7 +100,7 @@
nac3artiq-profile = pkgs.stdenvNoCC.mkDerivation { nac3artiq-profile = pkgs.stdenvNoCC.mkDerivation {
name = "nac3artiq-profile"; name = "nac3artiq-profile";
src = self; src = self;
buildInputs = [ (pkgs.python3.withPackages(ps: [ ps.numpy nac3artiq-instrumented ])) pkgs.lld_13 pkgs.llvmPackages_13.libllvm ]; buildInputs = [ (python3-mimalloc.withPackages(ps: [ ps.numpy nac3artiq-instrumented ])) pkgs.lld_13 pkgs.llvmPackages_13.libllvm ];
phases = [ "buildPhase" "installPhase" ]; phases = [ "buildPhase" "installPhase" ];
# TODO: get more representative code. # TODO: get more representative code.
buildPhase = "python $src/nac3artiq/demo/demo.py"; buildPhase = "python $src/nac3artiq/demo/demo.py";
@ -179,7 +183,7 @@
cargo-insta cargo-insta
rustc rustc
clippy clippy
(python3.withPackages(ps: [ ps.numpy ])) (packages.x86_64-linux.python3-mimalloc.withPackages(ps: [ ps.numpy ]))
]; ];
}; };