aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac133
1 files changed, 125 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index ec5ba890..e832afd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,14 +115,6 @@ AC_ARG_ENABLE([linker-hardening],
115 [LDFLAGS="$LDFLAGS -z relro -z now"])]) 115 [LDFLAGS="$LDFLAGS -z relro -z now"])])
116 116
117 117
118AC_ARG_ENABLE([sanitizer],
119 [AS_HELP_STRING([--enable-sanitizer], [enable Address Sanitizer and Undefined Behavior Sanitizer])],
120[AS_IF([test x$enableval = xyes],[
121 CFLAGS="$CFLAGS -fsanitize=address,undefined -fno-omit-frame-pointer"
122 ])])
123
124
125
126# Workaround for libgcrypt 118# Workaround for libgcrypt
127AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]]) 119AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
128 120
@@ -2533,6 +2525,130 @@ AS_VAR_IF([[enable_asserts]], [["yes"]],
2533 [AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])] 2525 [AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])]
2534) 2526)
2535 2527
2528AS_UNSET([enabled_sanitizers])
2529AM_TESTS_ENVIRONMENT=""
2530AM_ASAN_OPTIONS=""
2531AM_UBSAN_OPTIONS=""
2532AM_LSAN_OPTIONS=""
2533AC_ARG_ENABLE([sanitizers],
2534 [AS_HELP_STRING([--enable-sanitizers], [enable run-time sanitizers])],
2535 [], [enable_sanitizers=no])
2536AS_VAR_IF([enable_sanitizers], ["yes"],
2537 [
2538 new_CFLAGS="$CFLAGS"
2539 AC_CACHE_CHECK([whether sanitizer parameter works for $CC],
2540 [mhd_cv_cc_sanitizer_works],
2541 [
2542 CFLAGS="${new_CFLAGS} -fsanitize=wrongFeatureName"
2543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
2544 [mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes])
2545 ]
2546 )
2547 AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"],
2548 [
2549 AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address],
2550 [
2551 CFLAGS="${saved_CFLAGS} -fsanitize=address"
2552 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2553 [mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no])
2554 ]
2555 )
2556 AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
2557 [
2558 new_CFLAGS="${new_CFLAGS} -fsanitize=address"
2559 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address"
2560 AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare],
2561 [
2562 CFLAGS="${new_CFLAGS} -fsanitize=pointer-compare"
2563 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2564 [mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no])
2565 ]
2566 )
2567 AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"],
2568 [
2569 new_CFLAGS="${new_CFLAGS} -fsanitize=pointer-compare"
2570 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare"
2571 ]
2572 )
2573 AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract],
2574 [
2575 CFLAGS="${new_CFLAGS} -fsanitize=pointer-subtract"
2576 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2577 [mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no])
2578 ]
2579 )
2580 AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"],
2581 [
2582 new_CFLAGS="${new_CFLAGS} -fsanitize=pointer-subtract"
2583 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract"
2584 ]
2585 )
2586 ]
2587 )
2588 AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined],
2589 [
2590 CFLAGS="${new_CFLAGS} -fsanitize=undefined"
2591 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2592 [mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no])
2593 ]
2594 )
2595 AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"],
2596 [
2597 new_CFLAGS="${new_CFLAGS} -fsanitize=undefined"
2598 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
2599 ]
2600 )
2601 AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak],
2602 [
2603 CFLAGS="${new_CFLAGS} -fsanitize=leak"
2604 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2605 [mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no])
2606 ]
2607 )
2608 AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"],
2609 [
2610 new_CFLAGS="${new_CFLAGS} -fsanitize=leak"
2611 enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak"
2612 ]
2613 )
2614
2615 AS_IF([test -z "${enabled_sanitizers}"],
2616 [AC_MSG_ERROR([cannot find any sanitizer supported by $CC])])
2617 AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
2618 [
2619 new_CFLAGS="${new_CFLAGS} -D_FORTIFY_SOURCE=0"
2620 AX_APPEND_COMPILE_FLAGS([-Wp,-U_FORTIFY_SOURCE], [new_CFLAGS])
2621 ],
2622 [AC_MSG_WARN([$CC does not support address sanitizer])]
2623 )
2624 # Always stop on error
2625 AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [new_CFLAGS])
2626 # Get better output for sanitizers error reporting
2627 AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-common -fno-optimize-sibling-calls],
2628 [new_CFLAGS])
2629 AM_ASAN_OPTIONS="exitcode=88:detect_leaks=1:strict_string_checks=1:detect_stack_use_after_return=1"
2630 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64"
2631 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3"
2632 AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1"
2633 AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"
2634 AM_LSAN_OPTIONS="use_unaligned=1"
2635 AM_TESTS_ENVIRONMENT='\
2636ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \
2637UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \
2638LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;'
2639 ]
2640 )
2641 CFLAGS="$new_CFLAGS"
2642 AS_UNSET([new_CFLAGS])
2643 ]
2644)
2645AM_CONDITIONAL([USE_SANITIZERS],
2646 [test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"])
2647AC_SUBST([AM_ASAN_OPTIONS])
2648AC_SUBST([AM_UBSAN_OPTIONS])
2649AC_SUBST([AM_LSAN_OPTIONS])
2650AC_SUBST([AM_TESTS_ENVIRONMENT])
2651
2536MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined" 2652MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined"
2537 2653
2538AC_SUBST([CPU_COUNT]) 2654AC_SUBST([CPU_COUNT])
@@ -2618,6 +2734,7 @@ AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
2618 Threading lib: ${USE_THREADS} 2734 Threading lib: ${USE_THREADS}
2619 Use thread names: ${enable_thread_names} 2735 Use thread names: ${enable_thread_names}
2620 Use debug asserts: ${enable_asserts} 2736 Use debug asserts: ${enable_asserts}
2737 Use sanitizers: ${enabled_sanitizers:=no}
2621 Messages: ${enable_messages} 2738 Messages: ${enable_messages}
2622 Gettext: ${have_po} 2739 Gettext: ${have_po}
2623 Basic auth.: ${enable_bauth} 2740 Basic auth.: ${enable_bauth}