From db863ae6a444853ba42ef89f52197041002587d2 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Sat, 25 May 2024 01:55:48 -0700 Subject: [PATCH 1/3] liburing: don't emit extra static libraries If the static libraries are available, rocksdb will try to link against them instead of the dynamic libraries. --- pkgs/development/libraries/liburing/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/libraries/liburing/default.nix b/pkgs/development/libraries/liburing/default.nix index 151305630b82..fc9213e38f67 100644 --- a/pkgs/development/libraries/liburing/default.nix +++ b/pkgs/development/libraries/liburing/default.nix @@ -35,6 +35,12 @@ stdenv.mkDerivation rec { ]; postInstall = '' + # Always builds both static and dynamic libraries, so we need to remove the + # libraries that don't match stdenv type. + rm $out/lib/liburing*${ + if stdenv.hostPlatform.isStatic then ".so*" else ".a" + } + # Copy the examples into $bin. Most reverse dependency of # this package should reference only the $out output for file in $(find ./examples -executable -type f); do From c9ab1fcb3722726c9f9e46680530a58c95189af7 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Sat, 25 May 2024 01:56:46 -0700 Subject: [PATCH 2/3] liburing: fix build with static stdenv --- pkgs/development/libraries/liburing/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/libraries/liburing/default.nix b/pkgs/development/libraries/liburing/default.nix index fc9213e38f67..8e04a1203389 100644 --- a/pkgs/development/libraries/liburing/default.nix +++ b/pkgs/development/libraries/liburing/default.nix @@ -19,6 +19,8 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; # Upstream's configure script is not autoconf generated, but a hand written one. setOutputFlags = false; + dontDisableStatic = true; + dontAddStaticConfigureFlags = true; configureFlags = [ "--includedir=${placeholder "dev"}/include" "--mandir=${placeholder "man"}/share/man" From 65a6502a69c4208fd326da0596feaa57de15328e Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Sat, 25 May 2024 02:03:21 -0700 Subject: [PATCH 3/3] rocksdb: add enableLiburing option --- .../development/libraries/rocksdb/default.nix | 6 ++++ .../libraries/rocksdb/fix-findliburing.patch | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 pkgs/development/libraries/rocksdb/fix-findliburing.patch diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index af52b6a9fa7c..9f662a8b1479 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -11,6 +11,8 @@ , windows , enableJemalloc ? false , jemalloc +, enableLiburing ? true +, liburing , enableShared ? !stdenv.hostPlatform.isStatic , sse42Support ? stdenv.hostPlatform.sse4_2Support }: @@ -26,11 +28,14 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-Zifn5Gu/4h6TaEqSaWQ2mFdryeAarqbHWW3fKUGGFac="; }; + patches = [ ./fix-findliburing.patch ]; + nativeBuildInputs = [ cmake ninja ]; propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ]; buildInputs = lib.optional enableJemalloc jemalloc + ++ lib.optional enableLiburing liburing ++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads; outputs = [ @@ -45,6 +50,7 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ "-DPORTABLE=1" "-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}" + "-DWITH_LIBURING=${if enableLiburing then "1" else "0"}" "-DWITH_JNI=0" "-DWITH_BENCHMARK_TOOLS=0" "-DWITH_TESTS=1" diff --git a/pkgs/development/libraries/rocksdb/fix-findliburing.patch b/pkgs/development/libraries/rocksdb/fix-findliburing.patch new file mode 100644 index 000000000000..c546577813ce --- /dev/null +++ b/pkgs/development/libraries/rocksdb/fix-findliburing.patch @@ -0,0 +1,29 @@ +From 23432b7958ecea64b49ba680767ea5dc696768c9 Mon Sep 17 00:00:00 2001 +From: Benjamin Lee +Date: Sun, 26 May 2024 17:17:01 -0700 +Subject: [PATCH] fix findliburing + +`find_package(... NAMES lib*)` is basically always wrong. The previous +code was just hardcoding the static library path to work around the fact +that this doesn't work. This breaks the build when only dynamic liburing +builds are available. +--- + cmake/modules/Finduring.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/modules/Finduring.cmake b/cmake/modules/Finduring.cmake +index 8cb14cb27..87f2df474 100644 +--- a/cmake/modules/Finduring.cmake ++++ b/cmake/modules/Finduring.cmake +@@ -7,7 +7,7 @@ + find_path(uring_INCLUDE_DIR + NAMES liburing.h) + find_library(uring_LIBRARIES +- NAMES liburing.a liburing) ++ NAMES uring) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(uring +-- +2.44.0 +