From d6c8512617b7a7960e0c134eb4451276e6548d47 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 22 Mar 2022 12:36:52 +0100 Subject: [PATCH] Fixes for AddressSanitizer not working in valgrind. --- .drone.yml | 15 +++++++++++++-- CMakeLists.txt | 7 +++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index d2fe529..971cc90 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,8 +26,19 @@ steps: commands: - cmake -GNinja -DCMAKE_BUILD_TYPE=Release . -B build-release -DSTATICC=ON -DARBUTILS_TESTS=ON - cmake --build build-release --target all -- -j 4 - - cd build-debug + - cd build-release - ./ArbutilsTests -s --duration=true --force-colors=true + - name: test-release-linux_valgrind + image: deukhoofd/linux64builder + environment: + CC: /usr/bin/clang + CXX: /usr/bin/clang++ + CMAKE_RANLIB: /usr/bin/llvm-ranlib + CMAKE_AR: /usr/bin/llvm-ar + commands: + - cmake -GNinja -DCMAKE_BUILD_TYPE=Release . -B build-release_valgrind -DSTATICC=ON -DARBUTILS_TESTS=ON -DSANITIZER_TESTS=OFF + - cmake --build build-release_valgrind --target all -- -j 4 + - cd build-release_valgrind - valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 ./ArbutilsTests - name: test-release-windows image: deukhoofd/windowsbuilder @@ -63,6 +74,6 @@ volumes: path: /home/docs/Arbutils --- kind: signature -hmac: 38b3e0329693c61f83bcee5a596e6c560a591dc9f8ac8362e60387a99acb3626 +hmac: 8ee9294785e0ce2853d4cfb01ae39ddd82e1c3152b8917cc459d84cbc82e8aaf ... diff --git a/CMakeLists.txt b/CMakeLists.txt index 6922e85..1acfeae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ endif () option(WINDOWS "Whether the build target is Windows or not." OFF) option(SHARED "Whether we should build a shared library, instead of a static one." OFF) option(ARBUTILS_TESTS "Whether the test executable should be build as well." OFF) +option(SANITIZER_TESTS "Whether the test executable should be built using address sanitizer." ON) option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) option(PRETTYTRACES "Whether full stacktraces should be included. Note that this adds a dependency to libdw." ON) option(SIGNAL_HANDLING "whether to include signal handling." OFF) @@ -120,8 +121,10 @@ if (ARBUTILS_TESTS) # Add a compilation definition to the code that we are building a test build. target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD) - target_compile_options(ArbutilsTests PRIVATE -fsanitize=address) - target_link_options(ArbutilsTests PRIVATE -fsanitize=address) + if (SANITIZER_TESTS) + target_compile_options(ArbutilsTests PRIVATE -fsanitize=address) + target_link_options(ArbutilsTests PRIVATE -fsanitize=address) + endif() endif ()