This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=59268c3f1098114c0dc27b2129882faa96897a1a commit 59268c3f1098114c0dc27b2129882faa96897a1a Author: Guillem Jover <[email protected]> AuthorDate: Sun Jun 4 23:53:26 2023 +0200 build: Add support for compiler sanitizer flags Add a new configure option to detect and enable these compiler flags and use them when running the unit and functional tests from the CI. --- .gitlab-ci.yml | 4 ++-- configure.ac | 1 + m4/dpkg-compiler.m4 | 30 ++++++++++++++++++++++++++++++ scripts/t/dpkg_buildpackage.t | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd6abd26c..fed2e4a5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ unit-tests: stage: test script: - eatmydata apt -P pkg.dpkg.author-testing build-dep -qq -y . - - ./configure + - ./configure --enable-compiler-sanitizer - make authorcheck TESTSUITEFLAGS=--verbose TEST_PARALLEL=$(nproc) # Test whether the unit tests pass on a VPATH build. @@ -44,7 +44,7 @@ shared-tests: func-tests: stage: test script: - - ./configure + - ./configure --enable-compiler-sanitizer - make - cd tests - echo "DPKG_BUILDTREE = $(realpath ..)" >>.pkg-tests.conf diff --git a/configure.ac b/configure.ac index afc6d2bf7..4f1a98ca4 100644 --- a/configure.ac +++ b/configure.ac @@ -220,6 +220,7 @@ DPKG_USE_DISK_PREALLOCATE # Checks for the build machinery. AC_DEFINE([LIBDPKG_VOLATILE_API], [1], [Acknowledge the volatility of the API.]) DPKG_COMPILER_WARNINGS +DPKG_COMPILER_SANITIZER DPKG_COMPILER_OPTIMIZATIONS DPKG_LINKER_OPTIMIZATIONS DPKG_ARCHITECTURE diff --git a/m4/dpkg-compiler.m4 b/m4/dpkg-compiler.m4 index eab27d595..1e9cd6597 100644 --- a/m4/dpkg-compiler.m4 +++ b/m4/dpkg-compiler.m4 @@ -139,6 +139,36 @@ AC_DEFUN([DPKG_COMPILER_WARNINGS], [ ]) ]) +# DPKG_CHECK_COMPILER_SANITIZER +# ----------------------------- +# Check whether the compiler sanitizer options are supported. +AC_DEFUN([DPKG_CHECK_COMPILER_SANITIZER], [ + DPKG_CHECK_COMPILER_FLAG([-fsanitize=address]) + DPKG_CHECK_COMPILER_FLAG([-fsanitize=leak]) + DPKG_CHECK_COMPILER_FLAG([-fsanitize=undefined]) +]) + +# DPKG_COMPILER_SANITIZER +# ----------------------- +# Add configure option to enable compiler sanitizer support options. +AC_DEFUN([DPKG_COMPILER_SANITIZER], [ + AC_ARG_ENABLE([compiler-sanitizer], + [AS_HELP_STRING([--enable-compiler-sanitizer], + [Enable compiler sanitizer support])], + [], [enable_compiler_sanitizer=no]) + + AS_IF([test "x$enable_compiler_sanitizer" = "xyes"], [ + DPKG_CHECK_COMPILER_SANITIZER + AC_LANG_PUSH([C++]) + DPKG_CHECK_COMPILER_SANITIZER + AC_LANG_POP([C++]) + + LDFLAGS="$DPKG_COMPILER_CFLAGS $LDFLAGS" + CFLAGS="$DPKG_COMPILER_CFLAGS $CFLAGS" + CXXFLAGS="$DPKG_COMPILER_CXXFLAGS $CXXFLAGS" + ]) +]) + # DPKG_COMPILER_OPTIMIZATIONS # --------------------------- # Add configure option to disable optimizations. diff --git a/scripts/t/dpkg_buildpackage.t b/scripts/t/dpkg_buildpackage.t index 946bfa6df..bfcd23fd9 100644 --- a/scripts/t/dpkg_buildpackage.t +++ b/scripts/t/dpkg_buildpackage.t @@ -87,6 +87,9 @@ my $tmpl_rules = <<'TMPL_RULES'; DI := debian/${binary-name-all} DA := debian/${binary-name-any} +# fakeroot confuses ASAN link order check. +export ASAN_OPTIONS = verify_asan_link_order=0 + clean: rm -f debian/files rm -rf $(DI) $(DA) -- Dpkg.Org's dpkg

