commit cf26c7b44377070de6253f99cb44546cca458fbe
parent d36dfd47c1ff3b6d83ccf4377bf7b3b8698059d0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 29 May 2022 15:37:05 +0300
configure: do not use -Og with Clang when ASAN enabled
Diffstat:
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
@@ -159,7 +159,32 @@ AS_CASE([${enable_build_type}],[debug|debugger],
[ # Debug build or build for walking with debugger
CFLAGS="${user_CFLAGS}"
AS_VAR_IF([enable_build_type],["debug"],
- [MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])],
+ [
+ AS_IF([test "x${enable_sanitizers}" != "xno"],
+ [
+ AC_CACHE_CHECK([whether workarounds for clang are required],
+ [mhd_cv_cc_clang_based],
+ [
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#if ! defined(__clang__) && ! defined(__llvm__)
+#error Compiler is not clang-based
+choke me now
+#endif
+ ]]
+ )
+ ],
+ [mhd_cv_cc_clang_based="yes"],[mhd_cv_cc_clang_based="no"]
+ )
+ ]
+ )
+ ]
+ )
+ # Clang has ASAN (pointer compare) broken when '-Og' optimisations are used
+ AS_IF([test "x${enable_sanitizers}" != "xno" && test "x${mhd_cv_cc_clang_based}" = "xyes"],
+ [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])],
+ [MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])]
+ )
+ ],
[MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])]
)
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])