aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-09-05 13:59:49 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-09-05 14:46:03 +0300
commit169cd95f9e2a1a25c0ce7d4cdd7a19030fb63eab (patch)
tree225363d8cbeabe79f74cfd48f5eeab60a3459e3e
parent75dc9e03126c2086651eff2e67051ac296dbb782 (diff)
downloadlibmicrohttpd-169cd95f9e2a1a25c0ce7d4cdd7a19030fb63eab.tar.gz
libmicrohttpd-169cd95f9e2a1a25c0ce7d4cdd7a19030fb63eab.zip
Added more options for undefined behavior sanitizer
* Added ability to use sanitizer on systems without run-time UBSan library
-rw-r--r--configure.ac43
1 files changed, 43 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index e832afd6..2a8e4e39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2596,6 +2596,49 @@ AS_VAR_IF([enable_sanitizers], ["yes"],
2596 [ 2596 [
2597 new_CFLAGS="${new_CFLAGS} -fsanitize=undefined" 2597 new_CFLAGS="${new_CFLAGS} -fsanitize=undefined"
2598 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" 2598 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
2599 ],
2600 [
2601 AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap],
2602 [
2603 CFLAGS="${new_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error"
2604 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2605 [mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no])
2606 ]
2607 )
2608 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"],
2609 [
2610 new_CFLAGS="${new_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error"
2611 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
2612 AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
2613 ],
2614 [
2615 AS_IF([test -z "${enabled_sanitizers}"],
2616 [
2617 # Last resort
2618 AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all],
2619 [
2620 CFLAGS="${new_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error"
2621 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2622 [mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no])
2623 ]
2624 )
2625 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"],
2626 [
2627 new_CFLAGS="${new_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error"
2628 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
2629 AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
2630 ]
2631 )
2632 ]
2633 )
2634 ]
2635 )
2636 ]
2637 )
2638 AS_CASE(["$enabled_sanitizers"], [*undefined],
2639 [
2640 AX_APPEND_COMPILE_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg],
2641 [new_CFLAGS], [${new_CFLAGS}])
2599 ] 2642 ]
2600 ) 2643 )
2601 AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak], 2644 AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak],