From 23074d5de8c46e0b66e805e853e905656d9d2b7f Mon Sep 17 00:00:00 2001 From: Philipp Bartsch Date: Wed, 10 Apr 2024 13:47:38 +0200 Subject: [PATCH 1/2] vectorscan: improve FAT_RUNTIME and run checks --- .../libraries/vectorscan/default.nix | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/vectorscan/default.nix b/pkgs/development/libraries/vectorscan/default.nix index 12fa0735b27f1..57445d4526702 100644 --- a/pkgs/development/libraries/vectorscan/default.nix +++ b/pkgs/development/libraries/vectorscan/default.nix @@ -30,11 +30,37 @@ stdenv.mkDerivation rec { boost ]; - cmakeFlags = lib.optional enableShared "-DBUILD_STATIC_AND_SHARED=ON" - ++ [ "-DFAT_RUNTIME=${if stdenv.hostPlatform.isLinux then "ON" else "OFF"}" ] - ++ lib.optional stdenv.hostPlatform.avx2Support "-DBUILD_AVX2=ON" - ++ lib.optional stdenv.hostPlatform.avx512Support "-DBUILD_AVX512=ON" - ; + # FAT_RUNTIME bundles optimized implementations for different CPU extensions and uses CPUID to + # transparently select the fastest for the current hardware. + # This feature is only available on linux for x86, x86_64, and aarch64. + # + # If FAT_RUNTIME is not available, we fall back to building for a single extension based + # on stdenv.hostPlatform. + # + # For generic builds (e.g. x86_64) this can mean using an implementation not optimized for the + # potentially available more modern hardware extensions (e.g. x86_64 with AVX512). + cmakeFlags = [ (if enableShared then "-DBUILD_SHARED_LIBS=ON" else "BUILD_STATIC_LIBS=ON") ] + ++ + (if lib.elem stdenv.hostPlatform.system [ "x86_64-linux" "i686-linux" ] then + [ "-DBUILD_AVX2=ON" "-DBUILD_AVX512=ON" "-DBUILD_AVX512VBMI=ON" "-DFAT_RUNTIME=ON" ] + else + (if (stdenv.isLinux && stdenv.isAarch64) then + [ "-DBUILD_SVE=ON" "-DBUILD_SVE2=ON" "-DBUILD_SVE2_BITPERM=ON" "-DFAT_RUNTIME=ON" ] + else + [ "-DFAT_RUNTIME=OFF" ] + ++ lib.optional stdenv.hostPlatform.avx2Support "-DBUILD_AVX2=ON" + ++ lib.optional stdenv.hostPlatform.avx512Support "-DBUILD_AVX512=ON" + ) + ); + + doCheck = true; + checkPhase = '' + runHook preCheck + + ./bin/unit-hyperscan + + runHook postCheck + ''; meta = with lib; { description = "A portable fork of the high-performance regular expression matching library"; From dbaa125957f8b68a28d556a165dabab89be56d1c Mon Sep 17 00:00:00 2001 From: Philipp Bartsch Date: Wed, 10 Apr 2024 13:51:36 +0200 Subject: [PATCH 2/2] vectorscan: 5.4.10.1 -> 5.4.11 The darwin (or libcxxStdenv) builds use C++17, which only seems to work with boost >= 1.83. The errors look like this: include/boost/functional.hpp:454:62: error: no template named 'binary_function' in namespace 'boost::functional::detail'; did you mean '__binary_function'? class mem_fun1_ref_t : public boost::functional::detail::binary_function ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ include/boost/functional.hpp:46:24: note: '__binary_function' declared here using std::binary_function; --- pkgs/development/libraries/vectorscan/default.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/vectorscan/default.nix b/pkgs/development/libraries/vectorscan/default.nix index 57445d4526702..e9724ced0c70f 100644 --- a/pkgs/development/libraries/vectorscan/default.nix +++ b/pkgs/development/libraries/vectorscan/default.nix @@ -2,32 +2,38 @@ , stdenv , fetchFromGitHub , cmake +, pkg-config , ragel , util-linux , python3 -, boost +, boost184 +, sqlite +, pcre , enableShared ? !stdenv.hostPlatform.isStatic }: stdenv.mkDerivation rec { pname = "vectorscan"; - version = "5.4.10.1"; + version = "5.4.11"; src = fetchFromGitHub { owner = "VectorCamp"; repo = "vectorscan"; rev = "vectorscan/${version}"; - hash = "sha256-x6FefOrUvpN/A4GXTd+3SGZEAQL6pXt83ufxRIY3Q9k="; + hash = "sha256-wz2oIhau/vjnri3LOyPZSCFAWg694FTLVt7+SZYEsL4="; }; nativeBuildInputs = [ cmake + pkg-config ragel python3 ] ++ lib.optional stdenv.isLinux util-linux; buildInputs = [ - boost + boost184 + sqlite + pcre ]; # FAT_RUNTIME bundles optimized implementations for different CPU extensions and uses CPUID to