aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-01-21 09:11:14 +0000
committerGitHub <noreply@github.com>2020-01-21 09:11:14 +0000
commite5fb493dcf4de4d6afa14f7e129a5ac5c0580745 (patch)
treefdc72f29baaf81c5f10bb863a91d8a0f0c48d241
parent7d42200919e5fa63caf12bda7e2dd46dc1210b1a (diff)
parent3daf2762a956ee1c578f6320d6caf2885a2a8ea4 (diff)
downloadrspamd-e5fb493dcf4de4d6afa14f7e129a5ac5c0580745.tar.gz
rspamd-e5fb493dcf4de4d6afa14f7e129a5ac5c0580745.zip
Merge pull request #3228 from Lekensteyn/debian-reproducible-builds
[Minor] Fix Debian reproducible builds
-rw-r--r--cmake/FindRagel.cmake11
-rw-r--r--cmake/Toolset.cmake11
-rw-r--r--config.h.in2
-rw-r--r--contrib/libev/CMakeLists.txt5
-rw-r--r--contrib/snowball/CMakeLists.txt7
-rwxr-xr-xcontrib/snowball/libstemmer/mkmodules.pl11
-rw-r--r--debian/control6
-rwxr-xr-xdebian/rules29
-rw-r--r--test/rspamd_lua_pcall_vs_resume_test.c8
-rw-r--r--test/rspamd_lua_test.c7
-rw-r--r--test/rspamd_test_suite.c3
11 files changed, 61 insertions, 39 deletions
diff --git a/cmake/FindRagel.cmake b/cmake/FindRagel.cmake
index a058b7fb1..f17766ac6 100644
--- a/cmake/FindRagel.cmake
+++ b/cmake/FindRagel.cmake
@@ -72,9 +72,16 @@ ${RAGEL_version_error}")
macro(RAGEL_TARGET Name)
CMAKE_PARSE_ARGUMENTS(RAGEL "" "OUTPUT"
"INPUTS;DEPENDS;COMPILE_FLAGS" ${ARGN})
+
+ file(RELATIVE_PATH RAGEL_OUTPUT_RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${RAGEL_OUTPUT}")
+ file(RELATIVE_PATH RAGEL_INPUTS_RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${RAGEL_INPUTS}")
+
add_custom_command(OUTPUT ${RAGEL_OUTPUT}
COMMAND ${RAGEL_EXECUTABLE}
- ARGS ${RAGEL_COMPILE_FLAGS} -o${RAGEL_OUTPUT} ${RAGEL_INPUTS}
+ ARGS ${RAGEL_COMPILE_FLAGS}
+ -o${RAGEL_OUTPUT_RELATIVE} ${RAGEL_INPUTS_RELATIVE}
DEPENDS ${RAGEL_INPUTS} ${RAGEL_DEPENDS}
COMMENT
"[RAGEL][${Name}] Compiling state machine with Ragel ${RAGEL_VERSION}"
@@ -93,4 +100,4 @@ endif()
# use this include when module file is located in build tree
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(RAGEL REQUIRED_VARS RAGEL_EXECUTABLE
- VERSION_VAR RAGEL_VERSION) \ No newline at end of file
+ VERSION_VAR RAGEL_VERSION)
diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake
index 37019bc47..a60815d7a 100644
--- a/cmake/Toolset.cmake
+++ b/cmake/Toolset.cmake
@@ -166,9 +166,16 @@ else ()
endif()
+if (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE|RELWITHDEBINFO")
+ set(ENABLE_LTO_INIT ON)
+else()
+ set(ENABLE_LTO_INIT OFF)
+endif()
+option(ENABLE_LTO "Build rspamd with Link Time Optimization if supported [default: ${ENABLE_LTO_INIT}]" ${ENABLE_LTO_INIT})
+
if (CMAKE_BUILD_TYPE_UC MATCHES "COVERAGE")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
-elseif (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE")
+elseif (ENABLE_LTO)
if (${CMAKE_VERSION} VERSION_GREATER "3.9.0")
cmake_policy (SET CMP0069 NEW)
include (CheckIPOSupported)
@@ -183,4 +190,4 @@ elseif (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE")
endif ()
message (STATUS "Final CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
-message (STATUS "Final CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}") \ No newline at end of file
+message (STATUS "Final CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
diff --git a/config.h.in b/config.h.in
index e711af6d6..c2d73a0a9 100644
--- a/config.h.in
+++ b/config.h.in
@@ -248,8 +248,6 @@
#define MODULES_NUM ${RSPAMD_MODULES_NUM}
-#define BUILDROOT "${CMAKE_BINARY_DIR}"
-
/* sys/types */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
diff --git a/contrib/libev/CMakeLists.txt b/contrib/libev/CMakeLists.txt
index db380db95..591166a96 100644
--- a/contrib/libev/CMakeLists.txt
+++ b/contrib/libev/CMakeLists.txt
@@ -50,7 +50,8 @@ CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)
CONFIGURE_FILE(config.h.in libev-config.h)
ADD_LIBRARY(rspamd-ev SHARED ${LIBEVSRC})
-ADD_DEFINITIONS("-DEV_CONFIG_H=\"${CMAKE_CURRENT_BINARY_DIR}/libev-config.h\""
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+ADD_DEFINITIONS("-DEV_CONFIG_H=\"libev-config.h\""
-DEV_MULTIPLICITY=1
-DEV_USE_FLOOR=1
-DEV_NO_THREADS=1 # We do not have threads in Rspamd!
@@ -64,4 +65,4 @@ IF(ENABLE_FULL_DEBUG MATCHES "ON")
ADD_DEFINITIONS(-DEV_VERIFY=3)
ENDIF()
-INSTALL(TARGETS rspamd-ev LIBRARY DESTINATION ${RSPAMD_LIBDIR}) \ No newline at end of file
+INSTALL(TARGETS rspamd-ev LIBRARY DESTINATION ${RSPAMD_LIBDIR})
diff --git a/contrib/snowball/CMakeLists.txt b/contrib/snowball/CMakeLists.txt
index 8674e2d88..7910c7b3a 100644
--- a/contrib/snowball/CMakeLists.txt
+++ b/contrib/snowball/CMakeLists.txt
@@ -37,14 +37,14 @@ MACRO(gen_stem IN ENCODING)
SET(_input "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_${_in_enc}.sbl")
IF(${_in_enc} STREQUAL "Unicode" AND NOT EXISTS ${_input})
ADD_CUSTOM_COMMAND(OUTPUT ${_source}
- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_ISO_8859_1.sbl" -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ${CMAKE_CURRENT_SOURCE_DIR}/runtime -u
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_ISO_8859_1.sbl" -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ../runtime -u
DEPENDS snowball)
LIST(APPEND STEMMER_SOURCES ${_source})
ELSE()
IF(EXISTS "${_input}")
ADD_CUSTOM_COMMAND(OUTPUT ${_source}
- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball ${_input} -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ${CMAKE_CURRENT_SOURCE_DIR}/runtime -u
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball ${_input} -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ../runtime -u
DEPENDS snowball)
LIST(APPEND STEMMER_SOURCES ${_source})
ENDIF()
@@ -53,12 +53,11 @@ MACRO(gen_stem IN ENCODING)
ENDMACRO()
INCLUDE_DIRECTORIES("include")
-INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/libstemmer")
ADD_EXECUTABLE(snowball ${COMPILER_SOURCES})
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h
- COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/mkmodules.pl -f ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h ${CMAKE_CURRENT_BINARY_DIR}/libstemmer ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/modules.txt ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/mkinc.mak)
+ COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/mkmodules.pl libstemmer/modules.h libstemmer ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/modules.txt libstemmer/mkinc.mak)
ADD_CUSTOM_TARGET(modules DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h")
SET(STEMMER_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/libstemmer/libstemmer.c")
diff --git a/contrib/snowball/libstemmer/mkmodules.pl b/contrib/snowball/libstemmer/mkmodules.pl
index 93870b247..ff8c19e7c 100755
--- a/contrib/snowball/libstemmer/mkmodules.pl
+++ b/contrib/snowball/libstemmer/mkmodules.pl
@@ -1,17 +1,8 @@
#!/usr/bin/perl -w
use strict;
-use Getopt::Std;
my $progname = $0;
-my $include_path = '../';
-our($opt_f);
-
-getopts('f');
-if ($opt_f) {
- $include_path = '';
-}
-
if (scalar @ARGV < 4 || scalar @ARGV > 5) {
print "Usage: $progname <outfile> <C source directory> <modules description file> <source list file> [<extn>]\n";
exit 1;
@@ -109,7 +100,7 @@ EOS
foreach $lang (@algorithms) {
my $hashref = $algorithm_encs{$lang};
foreach $enc (sort keys (%$hashref)) {
- print OUT "#include \"${include_path}$c_src_dir/stem_${enc}_$lang.h\"\n";
+ print OUT "#include \"../$c_src_dir/stem_${enc}_$lang.h\"\n";
}
}
diff --git a/debian/control b/debian/control
index ab2614cb2..293777037 100644
--- a/debian/control
+++ b/debian/control
@@ -5,17 +5,17 @@ Maintainer: Mikhail Gusarov <dottedmag@debian.org>
Build-Depends: cmake,
debhelper (>= 10),
libcurl4-openssl-dev,
- libglib2.0-dev (>= 2.16.0),
+ libglib2.0-dev,
libhyperscan-dev [amd64 i386],
libicu-dev,
libjemalloc-dev,
- libluajit-5.1-dev [amd64 armel armhf i386 kfreebsd-i386 mips mipsel powerpc powerpcspe] | liblua5.1-dev,
+ libluajit-5.1-dev [amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el] | liblua5.1-dev,
libmagic-dev,
libpcre2-dev,
libsodium-dev,
libsqlite3-dev,
libssl-dev (>= 1.0),
- libunwind-dev | libunwind8-dev,
+ libunwind-dev,
perl,
ragel,
zlib1g-dev
diff --git a/debian/rules b/debian/rules
index d78c8ee5a..309bd0738 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,17 +1,24 @@
#!/usr/bin/make -f
-%:
- dh $@ --with systemd --parallel
-
-.PHONY: override_dh_strip
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all reproducible=+fixfilepath
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export ASAN_OPTIONS=detect_leaks=0
-ifneq ($(filter $(DEB_TARGET_ARCH),amd64 i386),)
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
+ifneq ($(filter $(DEB_HOST_ARCH),amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64 ppc64el),)
+ ENABLE_LUAJIT := ON
+else
+ ENABLE_LUAJIT := OFF
+endif
+
+ifneq ($(filter $(DEB_HOST_ARCH),amd64 i386),)
ENABLE_HYPERSCAN := -DENABLE_HYPERSCAN=ON
else
ENABLE_HYPERSCAN :=
endif
+%:
+ dh $@ --with systemd --parallel
override_dh_auto_configure:
dh_auto_configure -- -DCONFDIR=/etc/rspamd \
@@ -23,21 +30,23 @@ override_dh_auto_configure:
-DLIBDIR=/usr/lib/rspamd \
-DINCLUDEDIR=/usr/include \
-DSYSTEMDDIR=/lib/systemd/system \
- -DCMAKE_BUILD_TYPE=ReleaseWithDebInfo \
+ -DCMAKE_BUILD_TYPE=None \
+ -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
+ -DENABLE_LTO=ON \
-DDEBIAN_BUILD=1 \
-DENABLE_JEMALLOC=ON \
-DENABLE_PCRE2=OFF \
- -DENABLE_LUAJIT=ON \
+ -DENABLE_LUAJIT=$(ENABLE_LUAJIT) \
-DENABLE_LIBUNWIND=ON \
-DWANT_SYSTEMD_UNITS=ON \
$(ENABLE_HYPERSCAN)
-override_dh_makeshlibs:
- dh_makeshlibs -Xrspamd-actrie
-
override_dh_strip:
dh_strip --dbg-package=rspamd-dbg
+override_dh_makeshlibs:
+ dh_makeshlibs -Xrspamd-actrie
+
override_dh_auto_install:
dh_auto_install --destdir=debian/rspamd
diff --git a/test/rspamd_lua_pcall_vs_resume_test.c b/test/rspamd_lua_pcall_vs_resume_test.c
index 6cb05fd38..eb945b92f 100644
--- a/test/rspamd_lua_pcall_vs_resume_test.c
+++ b/test/rspamd_lua_pcall_vs_resume_test.c
@@ -19,7 +19,8 @@
#include "lua/lua_thread_pool.h"
#include "unix-std.h"
-static const char *lua_src = BUILDROOT "/test/lua/pcall_test.lua";
+static const char *lua_src_name = "lua/pcall_test.lua";
+extern gchar *argv0_dirname;
extern struct rspamd_main *rspamd_main;
@@ -126,12 +127,15 @@ void
rspamd_lua_lua_pcall_vs_resume_test_func (void)
{
lua_State *L = rspamd_main->cfg->lua_state;
+ gchar *lua_src;
gdouble t1, reference;
+ lua_src = g_build_filename (argv0_dirname, lua_src_name, NULL);
if (luaL_dofile (L, lua_src) != 0) {
msg_err ("failed to load test file: %s ", lua_tostring (L, -1));
g_assert (0);
}
+ g_free (lua_src);
gint function_call = luaL_ref (L, LUA_REGISTRYINDEX);
@@ -148,4 +152,4 @@ rspamd_lua_lua_pcall_vs_resume_test_func (void)
t1 = test_resume_get_new_thread (function_call);
msg_notice ("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference);
-} \ No newline at end of file
+}
diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c
index fc7979ee8..b014604b5 100644
--- a/test/rspamd_lua_test.c
+++ b/test/rspamd_lua_test.c
@@ -23,9 +23,10 @@
#include <glob.h>
#endif
-static const char *lua_src = BUILDROOT "/test/lua/tests.lua";
+static const char *lua_src_name = "lua/tests.lua";
extern gchar *lua_test;
extern gchar *lua_test_case;
+extern gchar *argv0_dirname;
extern struct rspamd_main *rspamd_main;
static int
@@ -59,7 +60,7 @@ void
rspamd_lua_test_func (void)
{
lua_State *L = (lua_State *)rspamd_main->cfg->lua_state;
- gchar *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern;
+ gchar *lua_src, *rp, rp_buf[PATH_MAX], path_buf[PATH_MAX], *tmp, *dir, *pattern;
const gchar *old_path;
glob_t globbuf;
gint i, len;
@@ -75,11 +76,13 @@ rspamd_lua_test_func (void)
rspamd_printf ("Starting lua tests\n");
+ lua_src = g_build_filename (argv0_dirname, lua_src_name, NULL);
if ((rp = realpath (lua_src, rp_buf)) == NULL) {
msg_err ("cannot find path %s: %s",
lua_src, strerror (errno));
g_assert (0);
}
+ g_free (lua_src);
tmp = g_strdup (rp);
dir = dirname (tmp);
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index d7b660642..48645ca93 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -12,6 +12,7 @@ worker_t *workers[] = { NULL };
gchar *lua_test = NULL;
gchar *lua_test_case = NULL;
gboolean verbose = FALSE;
+gchar *argv0_dirname = NULL;
static GOptionEntry entries[] =
{
@@ -45,6 +46,8 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
+ argv0_dirname = g_path_get_dirname (argv[0]);
+
context = g_option_context_new ("- run rspamd test");
g_option_context_add_main_entries (context, entries, NULL);