diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-04-04 21:30:43 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-06-03 22:19:38 +0200 |
commit | 01540cf1d33ece8ebe0edcace0801c8de07e0d0d (patch) | |
tree | 0b5a7786458f4df0e78511d8297e0fe39c13beae /configure.ac | |
parent | b5efd22c14d127de330f5e20ec7740256dd25afa (diff) | |
download | NetworkManager-01540cf1d33ece8ebe0edcace0801c8de07e0d0d.tar.gz |
build: add options to compile with address/undefined sanitizers
This adds two new options to the configure scripts to compile NM,
clients and libraries with the address and undefined-behavior
sanitizers available in recent GCC versions. Clang is not supported at
moment.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index e56062a8f7..c8d72d3cca 100644 --- a/configure.ac +++ b/configure.ac @@ -972,6 +972,39 @@ if (test "${enable_ld_gc}" != "no"); then fi fi +AC_ARG_ENABLE(address-sanitizer, AS_HELP_STRING([--enable-address-sanitizer], + [Compile with address sanitizer (default: no)])) +if (test "${enable_address_sanitizer}" = "yes"); then + CC_CHECK_FLAGS_APPEND([asan_cflags], [CFLAGS], [-fsanitize=address]) + AS_IF([test -z "$asan_cflags"], + [AC_MSG_ERROR([*** -fsanitize=address is not supported])]) + + sanitizer_cflags="$sanitizer_cflags -fsanitize=address" + sanitizer_ldflags="$sanitizer_ldflags -Wc,-fsanitize=address" + sanitizers="${sanitizers}asan " +fi + +AC_ARG_ENABLE(undefined-sanitizer, AS_HELP_STRING([--enable-undefined-sanitizer], + [Compile with undefined behavior sanitizer (default: no)])) +if (test "${enable_undefined_sanitizer}" = "yes"); then + CC_CHECK_FLAGS_APPEND([ubsan_cflags], [CFLAGS], [-fsanitize=undefined]) + AS_IF([test -z "$ubsan_cflags"], + [AC_MSG_ERROR([*** -fsanitize=undefined is not supported])]) + + sanitizer_cflags="$sanitizer_cflags -fsanitize=undefined" + sanitizer_ldflags="$sanitizer_ldflags -Wc,-fsanitize=undefined" + sanitizers="${sanitizers}ubsan " +fi + +if test -n "$sanitizers"; then + CFLAGS="$CFLAGS $sanitizer_cflags -DVALGRIND=1 -fno-omit-frame-pointer" + LDFLAGS="$LDFLAGS $sanitizer_ldflags" + sanitizers="${sanitizers% }" + AC_SUBST(SANITIZER_ENV, [ASAN_OPTIONS=detect_leaks=0]) +fi + +AC_SUBST(SANITIZERS, [$sanitizers]) + dnl ------------------------- dnl Vala bindings dnl ------------------------- @@ -1068,7 +1101,6 @@ fi AM_CONDITIONAL(BUILD_SETTING_DOCS, test "$build_setting_docs" = "yes") AM_CONDITIONAL(SETTING_DOCS_AVAILABLE, test "$build_setting_docs" = "yes" -o "$have_setting_docs" = "yes") - AC_CONFIG_FILES([ Makefile shared/Makefile @@ -1233,4 +1265,5 @@ echo " code coverage: $enable_code_coverage" echo " LTO: $enable_lto" echo " linker garbage collection: $enable_ld_gc" echo " JSON validation: $enable_json_validation" +echo " sanitizers: $sanitizers" echo |