commit c9fe6e476df25a3302c3f839d422c86d7d7f6a2a
parent bb050b12fc4cfc159417678df39e6f1d51c6ccdc
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 14 Aug 2026 16:44:38 +0200
configure: improved flags detections for clang with ASAN
Diffstat:
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -186,13 +186,16 @@ AC_PROG_CC_STDC
]
)
+# User-specified flags
user_CFLAGS="$CFLAGS"
user_LDFLAGS="$LDFLAGS"
user_CPPFLAGS="$CPPFLAGS"
-
+# Automatically added flags
CFLAGS_ac=""
LDFLAGS_ac=""
CPPFLAGS_ac=""
+# Autoamtically added flags, used only in Makefiles as they may interfere with configure detection
+CFLAGS_last=""
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
@@ -632,9 +635,7 @@ AS_VAR_IF([enable_build_type],["neutral"],[],
MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines -Wunsafe-loop-optimizations], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
- LDFLAGS="${user_LDFLAGS}"
- MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
- LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+ # Additional flags are checked at the end of the configure script
]
)
AS_CASE([${enable_build_type}],[debug|debugger|trace],
@@ -795,6 +796,8 @@ int main(void)
# -Wdisabled-macro-expansion - warns about macros from system headers
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+ MHD_CHECK_ADD_CC_CFLAGS([-Wextra-semi -Wextra-semi-stmt], [CFLAGS_last])
+ MHD_FIND_ADD_CC_CFLAG([CFLAGS_last], [-Wleading-whitespace=spaces], [-Wleading-whitespace])
LDFLAGS="${user_LDFLAGS}"
MHD_CHECK_ADD_CC_LDFLAG([-Wl,--enable-long-section-names], [LDFLAGS_ac])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
@@ -9733,14 +9736,15 @@ AM_CONDITIONAL([RUN_ZZUF_TESTS],[test "x$run_zzuf_tests" = "xyes"])
AM_CONDITIONAL([FORCE_USE_ZZUF_SOCAT],[test "x$zzuf_socat_mandatory" = "xyes"])
# Final flags that may interfere with autoconf detections
-AS_CASE([${enable_build_type}],[debug|debugger|trace],
- [ # Debug build, build for walking with debugger or debug printing build
- CFLAGS="${user_CFLAGS}"
- MHD_CHECK_ADD_CC_CFLAGS([-Wextra-semi -Wextra-semi-stmt], [CFLAGS_ac])
- MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wleading-whitespace=spaces], [-Wleading-whitespace])
+AS_VAR_IF([enable_build_type],["neutral"],[],
+ [ # Any non-neutral build types
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+ LDFLAGS="${user_LDFLAGS}"
+ MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
+ LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
+MHD_APPEND_FLAG_TO_VAR([CFLAGS_ac],[$CFLAGS_last])
AM_CONDITIONAL([USE_SANITIZERS],
[test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"])