aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Scholz <epirat07@gmail.com>2024-09-12 23:41:33 +0200
committerMarvin Scholz <epirat07@gmail.com>2024-09-18 15:24:12 +0200
commit7091da7129431ad7ede403799477086ed9a094a9 (patch)
treea43e29d163d5c3a3a5999d8e534dd1a7d85a9830
parent910bf33879ecdf654cdc6342564f7791e34a27bc (diff)
downloadffmpeg-7091da7129431ad7ede403799477086ed9a094a9.tar.gz
configure: correctly set sanitizer toolchain compilers
Previously only the C compiler was set, which would lead to confusing situations where even though clang-asan was selected, it would still use g++ for C++ code, failing because configure does not support mixing compilers in this way (which is a separate issue not addressed by this commit).
-rwxr-xr-xconfigure70
1 files changed, 41 insertions, 29 deletions
diff --git a/configure b/configure
index 2c4b5273b2..f5e675f76f 100755
--- a/configure
+++ b/configure
@@ -4553,37 +4553,49 @@ enabled ossfuzz && ! echo $CFLAGS | grep -q -- "-fsanitize=" && ! echo $CFLAGS
add_ldflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp
}
+add_sanitizer_flags(){
+ case "$1" in
+ asan)
+ add_cflags -fsanitize=address
+ add_ldflags -fsanitize=address
+ ;;
+ lsan)
+ add_cflags -fsanitize=leak
+ add_ldflags -fsanitize=leak
+ ;;
+ msan)
+ add_cflags -fsanitize=memory -fsanitize-memory-track-origins
+ add_ldflags -fsanitize=memory
+ ;;
+ tsan)
+ add_cflags -fsanitize=thread
+ add_ldflags -fsanitize=thread
+ ;;
+ usan)
+ add_cflags -fsanitize=undefined
+ add_ldflags -fsanitize=undefined
+ ;;
+ ?*)
+ die "Unknown sanitizer $1"
+ ;;
+ esac
+}
+
case "$toolchain" in
- *-asan)
- cc_default="${toolchain%-asan}"
- add_cflags -fsanitize=address
- add_ldflags -fsanitize=address
- ;;
- *-lsan)
- cc_default="${toolchain%-lsan}"
- add_cflags -fsanitize=leak
- add_ldflags -fsanitize=leak
- ;;
- *-msan)
- cc_default="${toolchain%-msan}"
- add_cflags -fsanitize=memory -fsanitize-memory-track-origins
- add_ldflags -fsanitize=memory
- ;;
- *-tsan)
- cc_default="${toolchain%-tsan}"
- add_cflags -fsanitize=thread
- add_ldflags -fsanitize=thread
- case "$toolchain" in
- gcc-tsan)
- add_cflags -fPIC
- add_ldflags -fPIC
- ;;
- esac
+ clang-*)
+ add_sanitizer_flags "${toolchain#clang-}"
+ cc_default="clang"
+ cxx_default="clang++"
;;
- *-usan)
- cc_default="${toolchain%-usan}"
- add_cflags -fsanitize=undefined
- add_ldflags -fsanitize=undefined
+ gcc-*)
+ add_sanitizer_flags "${toolchain#gcc-}"
+ cc_default="gcc"
+ cxx_default="g++"
+ # In case of tsan with gcc, PIC has to be enabled
+ if [ "${toolchain#gcc-}" = "tsan" ]; then
+ add_cflags -fPIC
+ add_ldflags -fPIC
+ fi
;;
valgrind-*)
target_exec_default="valgrind"