# HG changeset patch # User Mike Becker # Date 1747921680 -7200 # Node ID f76b70a72614b301b4b374426d4637ecbc5e4d1f # Parent aa1f580f8f59966f487bb2c1f8f305cefdd30dbf add an option to enable address sanitizer diff -r aa1f580f8f59 -r f76b70a72614 configure --- a/configure Thu May 15 16:12:09 2025 +0200 +++ b/configure Thu May 22 15:48:00 2025 +0200 @@ -111,8 +111,9 @@ --release add extra compile flags for release builds Optional Features: - --enable-api-docs - --enable-coverage + --enable-api-docs run Doxygen during build + --enable-coverage test coverage with gcov + --enable-asan address sanitizer --disable-cxx-tests the check-cxx makefile target --disable-szmul-builtin use custom implementation, instead @@ -191,6 +192,8 @@ "--disable-api-docs") unset FEATURE_API_DOCS ;; "--enable-coverage") FEATURE_COVERAGE=on ;; "--disable-coverage") unset FEATURE_COVERAGE ;; + "--enable-asan") FEATURE_ASAN=on ;; + "--disable-asan") unset FEATURE_ASAN ;; "--enable-cxx-tests") FEATURE_CXX_TESTS=on ;; "--disable-cxx-tests") unset FEATURE_CXX_TESTS ;; "--enable-szmul-builtin") FEATURE_SZMUL_BUILTIN=on ;; @@ -339,6 +342,26 @@ dep_checked_coverage=1 return 0 } +dependency_error_asan() +{ + print_check_msg "$dep_checked_asan" "checking for asan... " + # dependency asan toolchain="gnuc" + while true + do + if notistoolchain "gnuc"; then + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -fsanitize=address" + TEMP_LDFLAGS="$TEMP_LDFLAGS -fsanitize=address" + print_check_msg "$dep_checked_asan" "yes\n" + dep_checked_asan=1 + return 1 + done + + print_check_msg "$dep_checked_asan" "no\n" + dep_checked_asan=1 + return 0 +} dependency_error_cxx() { print_check_msg "$dep_checked_cxx" "checking for cxx... " @@ -631,6 +654,26 @@ else : fi +if [ -n "$FEATURE_ASAN" ]; then + # check dependency + if dependency_error_asan ; then + # "auto" features can fail and are just disabled in this case + if [ "$FEATURE_ASAN" = "auto" ]; then + DISABLE_FEATURE_ASAN=1 + else + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED asan " + ERROR=1 + fi + fi + if [ -n "$DISABLE_FEATURE_ASAN" ]; then + unset FEATURE_ASAN + fi +fi +if [ -n "$FEATURE_ASAN" ]; then + : +else + : +fi if [ -n "$FEATURE_CXX_TESTS" ]; then # check dependency if dependency_error_cxx ; then @@ -772,6 +815,11 @@ else echo " coverage: off" fi +if [ -n "$FEATURE_ASAN" ]; then +echo " asan: on" +else +echo " asan: off" +fi if [ -n "$FEATURE_CXX_TESTS" ]; then echo " cxx-tests: on" else diff -r aa1f580f8f59 -r f76b70a72614 make/project.xml --- a/make/project.xml Thu May 15 16:12:09 2025 +0200 +++ b/make/project.xml Thu May 22 15:48:00 2025 +0200 @@ -80,6 +80,11 @@ command -v gcovr + + -fsanitize=address + -fsanitize=address + + test -z "$FEATURE_COVERAGE" @@ -87,14 +92,20 @@ doxygen + run Doxygen during build # Documentation WITH_API_DOCS=yes + test coverage with gcov coverage + + address sanitizer + asan + cxx the check-cxx makefile target