Make sure we use the liburing of the platform we're building for

Signed-off-by: morguldir <morguldir@protonmail.com>
This commit is contained in:
morguldir 2024-05-07 04:55:45 +02:00 committed by June 🍓🦴
parent 70047ff26d
commit 8ba9b33a95
2 changed files with 13 additions and 10 deletions

View file

@ -42,12 +42,6 @@
(builtins.fromJSON (builtins.readFile ./flake.lock))
.nodes.rocksdb.original.ref;
});
# liburing's configure file is handwritten so the default assumptions don't apply
liburing = pkgs.liburing.overrideAttrs {
dontAddStaticConfigureFlags = true;
dontDisableStatic = true;
configureFlags = [];
};
});
scopeHost = mkScope pkgsHost;

View file

@ -9,6 +9,7 @@
, rust
, rust-jemalloc-sys
, stdenv
, pkgsStatic
# Options (keep sorted)
, default_features ? true
@ -55,11 +56,15 @@ rust-jemalloc-sys' = (rust-jemalloc-sys.override {
# tikv-jemalloc-sys/profiling feature
lib.optional (featureEnabled "jemalloc_prof") "--enable-prof";
});
liburing' = pkgsStatic.liburing.overrideAttrs {
configureFlags = []; # liburing's configure file is handwritten so the default assumptions don't apply
isStatic = true;
};
buildDepsOnlyEnv =
let
uring = featureEnabled "io_uring";
extraDeps = lib.optionals uring [pkgsBuildHost.liburing.dev pkgsBuildHost.liburing.out];
uring = featureEnabled "io_uring" && stdenv.isLinux;
extraDeps = lib.optionals uring [ liburing'.dev liburing'.out];
rocksdb' = (rocksdb.override {
jemalloc = rust-jemalloc-sys';
# rocksdb fails to build with prefixed jemalloc, which is required on
@ -96,10 +101,14 @@ buildPackageEnv = {
} // buildDepsOnlyEnv // {
CARGO_BUILD_RUSTFLAGS =
let
uring = default_features || builtins.elem "io_uring" features;
uring = featureEnabled "io_uring";
valid = (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64)
&& stdenv.hostPlatform.isStatic
&& !stdenv.isDarwin
&& !stdenv.cc.bintools.isLLVM;
in
buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS
+ lib.optionalString uring " -L${pkgsBuildHost.liburing}/lib/ -luring";
+ lib.optionalString (uring && valid) " -L${lib.getLib liburing'}/lib/ -luring";
};