rspamd: build with vectorscan (#370169)

This commit is contained in:
Arne Keller
2025-01-02 12:13:54 +01:00
committed by GitHub
3 changed files with 75 additions and 49 deletions
+2 -2
View File
@@ -56,8 +56,8 @@ stdenv.mkDerivation (finalAttrs: {
postPatch = ''
sed -i '/examples/d' CMakeLists.txt
substituteInPlace libhs.pc.in \
--replace "libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" "libdir=@CMAKE_INSTALL_LIBDIR@" \
--replace "includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@" "includedir=@CMAKE_INSTALL_INCLUDEDIR@"
--replace-fail "libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" "libdir=@CMAKE_INSTALL_LIBDIR@" \
--replace-fail "includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@" "includedir=@CMAKE_INSTALL_INCLUDEDIR@"
'';
doCheck = true;
+19 -22
View File
@@ -14,7 +14,7 @@
sqlite,
ragel,
icu,
hyperscan,
vectorscan,
jemalloc,
blas,
lapack,
@@ -24,13 +24,10 @@
zstd,
libarchive,
withBlas ? true,
withHyperscan ? stdenv.hostPlatform.isx86_64,
withLuaJIT ? stdenv.hostPlatform.isx86_64,
nixosTests,
}:
assert withHyperscan -> stdenv.hostPlatform.isx86_64;
stdenv.mkDerivation rec {
pname = "rspamd";
version = "3.11.0";
@@ -48,7 +45,9 @@ stdenv.mkDerivation rec {
cmake
pkg-config
perl
ragel
];
buildInputs =
[
doctest
@@ -64,8 +63,8 @@ stdenv.mkDerivation rec {
xxHash
zstd
libarchive
vectorscan
]
++ lib.optional withHyperscan hyperscan
++ lib.optionals withBlas [
blas
lapack
@@ -73,23 +72,21 @@ stdenv.mkDerivation rec {
++ lib.optional withLuaJIT luajit
++ lib.optional (!withLuaJIT) lua;
cmakeFlags =
[
# pcre2 jit seems to cause crashes: https://github.com/NixOS/nixpkgs/pull/181908
"-DENABLE_PCRE2=OFF"
"-DDEBIAN_BUILD=ON"
"-DRUNDIR=/run/rspamd"
"-DDBDIR=/var/lib/rspamd"
"-DLOGDIR=/var/log/rspamd"
"-DLOCAL_CONFDIR=/etc/rspamd"
"-DENABLE_JEMALLOC=ON"
"-DSYSTEM_DOCTEST=ON"
"-DSYSTEM_FMT=ON"
"-DSYSTEM_XXHASH=ON"
"-DSYSTEM_ZSTD=ON"
]
++ lib.optional withHyperscan "-DENABLE_HYPERSCAN=ON"
++ lib.optional (!withLuaJIT) "-DENABLE_LUAJIT=OFF";
cmakeFlags = [
# pcre2 jit seems to cause crashes: https://github.com/NixOS/nixpkgs/pull/181908
"-DENABLE_PCRE2=OFF"
"-DDEBIAN_BUILD=ON"
"-DRUNDIR=/run/rspamd"
"-DDBDIR=/var/lib/rspamd"
"-DLOGDIR=/var/log/rspamd"
"-DLOCAL_CONFDIR=/etc/rspamd"
"-DENABLE_JEMALLOC=ON"
"-DSYSTEM_DOCTEST=ON"
"-DSYSTEM_FMT=ON"
"-DSYSTEM_XXHASH=ON"
"-DSYSTEM_ZSTD=ON"
"-DENABLE_HYPERSCAN=ON"
] ++ lib.optional (!withLuaJIT) "-DENABLE_LUAJIT=OFF";
passthru.tests.rspamd = nixosTests.rspamd;
+54 -25
View File
@@ -1,15 +1,16 @@
{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
, ragel
, util-linux
, python3
, boost
, sqlite
, pcre
, enableShared ? !stdenv.hostPlatform.isStatic
{
lib,
stdenv,
fetchFromGitHub,
cmake,
pkg-config,
ragel,
util-linux,
python3,
boost,
sqlite,
pcre,
enableShared ? !stdenv.hostPlatform.isStatic,
}:
stdenv.mkDerivation rec {
@@ -24,6 +25,10 @@ stdenv.mkDerivation rec {
};
postPatch = ''
sed -i '/examples/d' CMakeLists.txt
substituteInPlace libhs.pc.in \
--replace-fail "libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" "libdir=@CMAKE_INSTALL_LIBDIR@" \
--replace-fail "includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@" "includedir=@CMAKE_INSTALL_INCLUDEDIR@"
substituteInPlace cmake/build_wrapper.sh \
--replace-fail 'nm' '${stdenv.cc.targetPrefix}nm' \
--replace-fail 'objcopy' '${stdenv.cc.targetPrefix}objcopy'
@@ -51,18 +56,35 @@ stdenv.mkDerivation rec {
#
# 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.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) then
[ "-DBUILD_SVE=ON" "-DBUILD_SVE2=ON" "-DBUILD_SVE2_BITPERM=ON" "-DFAT_RUNTIME=ON" ]
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
[ "-DFAT_RUNTIME=OFF" ]
++ lib.optional stdenv.hostPlatform.avx2Support "-DBUILD_AVX2=ON"
++ lib.optional stdenv.hostPlatform.avx512Support "-DBUILD_AVX512=ON"
)
(
if (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.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;
@@ -91,7 +113,14 @@ stdenv.mkDerivation rec {
homepage = "https://www.vectorcamp.gr/vectorscan/";
changelog = "https://github.com/VectorCamp/vectorscan/blob/${src.rev}/CHANGELOG-vectorscan.md";
platforms = platforms.unix;
license = with licenses; [ bsd3 /* and */ bsd2 /* and */ licenses.boost ];
maintainers = with maintainers; [ tnias vlaci ];
license = with licenses; [
bsd3 # and
bsd2 # and
licenses.boost
];
maintainers = with maintainers; [
tnias
vlaci
];
};
}