From: Yodel Eldar <[email protected]>

Builds with --enable-{asan,tsan,stack-trace} fail under GCC, so use
clang if available, otherwise disable the treatment of warnings as
errors.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3006
Suggested-by: Peter Maydell <[email protected]>
Signed-off-by: Yodel Eldar <[email protected]>
---
I didn't see ubsan break builds with GCC, so I excluded it from the
check, but maybe we want to preemptively include it, too?

Please review.

Link:
https://lore.kernel.org/qemu-devel/cafeaca88hc4usgpupxbwpben0tw26159kpn7jx2j9erba5d...@mail.gmail.com/

Thanks,
Yodel
---
 configure | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 5e114acea2..0b75b8bb93 100755
--- a/configure
+++ b/configure
@@ -762,6 +762,12 @@ for opt do
   ;;
   --wasm64-32bit-address-limit)
   ;;
+  --enable-asan) asan="yes"
+  ;;
+  --enable-tsan) tsan="yes"
+  ;;
+  --enable-safe-stack) safe_stack="yes"
+  ;;
   # everything else has the same name in configure and meson
   --*) meson_option_parse "$opt" "$optarg"
   ;;
@@ -771,6 +777,20 @@ for opt do
   esac
 done
 
+if test "$asan" = "yes" || test "$tsan" = "yes" || \
+    test "$safe_stack" = "yes"
+then
+    if has clang; then
+        echo "Sanitizer requested: setting compiler suite to clang"
+        cc=clang
+        cxx=clang++
+        host_cc=clang
+    else
+        echo "Sanitizer requested: disabling Werror for non-clang compilers"
+        force_disable_werror="yes"
+    fi
+fi
+
 if ! test -e "$source_path/.git"
 then
     git_submodules_action="validate"
@@ -1890,7 +1910,8 @@ if test "$skip_meson" = no; then
   echo "# environment defaults, can still be overridden on " >> $cross
   echo "# the command line" >> $cross
   if test -e "$source_path/.git" && \
-      { test "$host_os" = linux || test "$host_os" = "windows"; }; then
+      { test "$host_os" = linux || test "$host_os" = "windows"; } && \
+       test "$force_disable_werror" != "yes"; then
       echo 'werror = true' >> $cross
   fi
   echo "[project options]" >> $cross
-- 
2.53.0


Reply via email to