Unverified Commit 043f8e59 authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

rspamd: build with vectorscan (#370169)

parents 671f385b 3b11e0c5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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,8 +72,7 @@ stdenv.mkDerivation rec {
    ++ lib.optional withLuaJIT luajit
    ++ lib.optional (!withLuaJIT) lua;

  cmakeFlags =
    [
  cmakeFlags = [
    # pcre2 jit seems to cause crashes: https://github.com/NixOS/nixpkgs/pull/181908
    "-DENABLE_PCRE2=OFF"
    "-DDEBIAN_BUILD=ON"
@@ -87,9 +85,8 @@ stdenv.mkDerivation rec {
    "-DSYSTEM_FMT=ON"
    "-DSYSTEM_XXHASH=ON"
    "-DSYSTEM_ZSTD=ON"
    ]
    ++ lib.optional withHyperscan "-DENABLE_HYPERSCAN=ON"
    ++ lib.optional (!withLuaJIT) "-DENABLE_LUAJIT=OFF";
    "-DENABLE_HYPERSCAN=ON"
  ] ++ lib.optional (!withLuaJIT) "-DENABLE_LUAJIT=OFF";

  passthru.tests.rspamd = nixosTests.rspamd;

+54 −25
Original line number Diff line number Diff line
{ 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,13 +56,30 @@ 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" ]
  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" ]
        (
          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"
@@ -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
    ];
  };
}