From efa40191164bd19770c405d53425d1a8a9c44bb8 Mon Sep 17 00:00:00 2001 From: Thore Sommer Date: Fri, 24 Oct 2025 13:05:14 +0200 Subject: [PATCH] spdk: enable crypto support --- pkgs/by-name/sp/spdk/package.nix | 35 ++++++++++++++++++++ pkgs/by-name/sp/spdk/patches/configure.patch | 14 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 pkgs/by-name/sp/spdk/patches/configure.patch diff --git a/pkgs/by-name/sp/spdk/package.nix b/pkgs/by-name/sp/spdk/package.nix index 83fc98dbe95d..20abc59efc7d 100644 --- a/pkgs/by-name/sp/spdk/package.nix +++ b/pkgs/by-name/sp/spdk/package.nix @@ -10,6 +10,10 @@ libaio, libbsd, libuuid, + nasm, + autoconf, + automake, + libtool, numactl, openssl, pkg-config, @@ -76,24 +80,46 @@ stdenv.mkDerivation rec { ncurses zlib zstd + nasm + autoconf + automake + libtool ]; propagatedBuildInputs = [ python3.pkgs.configshell-fb ]; + patches = [ + # Otherwise the DPDK version is not detected correctly + # Fix already upstream: https://github.com/spdk/spdk/commit/c3618c42ac3f6fdfcc9c04e29953fd6cf4f71c11 + ./patches/configure.patch + ]; + postPatch = '' patchShebangs . # Override pip install command to use hatchling directly without downloading dependencies substituteInPlace python/Makefile \ --replace-fail "setup_cmd = pip install --prefix=\$(CONFIG_PREFIX)" \ "setup_cmd = python3 -m pip install --no-deps --no-build-isolation --prefix=\$(CONFIG_PREFIX)" + + # The nasm detection in the vendored version of isa-l_crypto is broken + # Upstream fix: https://github.com/intel/isa-l_crypto/commit/0850c01cc03e45f77d5883372dd6be983ba163ce + substituteInPlace isa-l-crypto/configure.ac \ + --replace-fail "AC_LANG_CONFTEST([AC_LANG_SOURCE([[vpcompressb zmm0, k1, zmm1;]])])" \ + "AC_LANG_CONFTEST([AC_LANG_SOURCE([[vpcompressb zmm0 {k1}, zmm1;]])])" ''; enableParallelBuilding = true; + # Required for the vendored isa-l version to find nasm + preConfigure = '' + export AS=nasm + ''; + configureFlags = [ "--with-dpdk=${dpdk'}" + "--with-crypto" ] ++ lib.optional (!stdenv.hostPlatform.isStatic) "--with-shared"; @@ -106,6 +132,15 @@ stdenv.mkDerivation rec { postInstall = '' unset patchelf + # Clean up rpaths to remove /build references to the vendored isa-l and isa-l_crypto libs + for f in $(find $out/lib $out/bin -executable -type f 2>/dev/null); do + if patchelf --print-rpath "$f" 2>/dev/null | grep /build; then + echo "Stripping rpath of $f" + newrp=$(patchelf --print-rpath "$f" | sed -r "s|/build[^:]*:||g") + patchelf --set-rpath "$newrp" "$f" + fi + done + # SPDK scripts assume that they can read the includes also relative to the scripts. # Therefore we are not copying them into $out/share. mkdir $out/scripts diff --git a/pkgs/by-name/sp/spdk/patches/configure.patch b/pkgs/by-name/sp/spdk/patches/configure.patch new file mode 100644 index 000000000000..93c221058adc --- /dev/null +++ b/pkgs/by-name/sp/spdk/patches/configure.patch @@ -0,0 +1,14 @@ +diff --git a/configure b/configure +index b0fdef9ec..413b7a968 100755 +--- a/configure ++++ b/configure +@@ -959,6 +959,9 @@ + dpdk_ver=$(< "$rootdir/dpdk/VERSION") + elif [[ -f "${CONFIG[DPDK_DIR]}"/../VERSION ]]; then + dpdk_ver=$(< "${CONFIG[DPDK_DIR]}"/../VERSION) ++ elif [[ "${CONFIG[DPDK_LIB_DIR]}" != "" && -e "${CONFIG[DPDK_LIB_DIR]}"/pkgconfig ]]; then ++ # Try pkg-config to figure out the module version ++ dpdk_ver=$(PKG_CONFIG_PATH="${CONFIG[DPDK_LIB_DIR]}"/pkgconfig pkg-config --modversion libdpdk) + fi + echo $dpdk_ver + }