All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2] configure: Use clang for sanitizer builds or disable Werror
@ 2026-03-03  1:20 Yodel Eldar
  2026-03-03  8:41 ` Daniel P. Berrangé
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Yodel Eldar @ 2026-03-03  1:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Alex Bennée, Thomas Huth, Yodel Eldar,
	Peter Maydell

From: Yodel Eldar <yodel.eldar@yodel.dev>

Builds with --enable-{asan,tsan,safe-stack} 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 <peter.maydell@linaro.org>
Signed-off-by: Yodel Eldar <yodel.eldar@yodel.dev>
---
Hi,

The previous version only disabled Werror whenever `--skip-meson` wasn't
used and the build occurred in a git repo, but this change should
probably apply to all types of builds. So, let's use meson_option_add
to globally disable Werror instead; IIUC (and according to my testing),
this will override the value in config-meson.cross.new.

I'm still not sure if we should be disabling Werror for ubsan, even
though it's not currently breaking builds with GCC; please let me know
what you think.

Special thanks to Peter for looking into the cause of the reports around
this, for sharing the findings, and suggesting approaches to resolve it.
I couldn't pick one over the other, so I went with using clang when
available with Werror disable as a fallback; please let me know if you
think this is an XOR kind of policy decision.

Link to RFCv1:
https://lore.kernel.org/qemu-devel/20260302210039.261325-1-yodel.eldar@yodel.dev/

Link to mentioned discussion:
https://lore.kernel.org/qemu-devel/CAFEAcA88hc4UsgpuPXBWpbeN0tW26159kPn7jx2J9erBA5DLBw@mail.gmail.com/

v2:
- Fix misnomer in commit message
- Simplify condition by using the same variable for all sanitizers
- Use meson_option_add to disable Werror

Thanks,
Yodel
---
 configure | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/configure b/configure
index 5e114acea2..e457e8a17d 100755
--- a/configure
+++ b/configure
@@ -762,6 +762,12 @@ for opt do
   ;;
   --wasm64-32bit-address-limit)
   ;;
+  --enable-asan) use_sanitizer="yes"
+  ;;
+  --enable-tsan) use_sanitizer="yes"
+  ;;
+  --enable-safe-stack) use_sanitizer="yes"
+  ;;
   # everything else has the same name in configure and meson
   --*) meson_option_parse "$opt" "$optarg"
   ;;
@@ -771,6 +777,18 @@ for opt do
   esac
 done
 
+if test "$use_sanitizer" = "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"
+        meson_option_add -Dwerror=false
+    fi
+fi
+
 if ! test -e "$source_path/.git"
 then
     git_submodules_action="validate"
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-05 10:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03  1:20 [RFC PATCH v2] configure: Use clang for sanitizer builds or disable Werror Yodel Eldar
2026-03-03  8:41 ` Daniel P. Berrangé
2026-03-03  9:36   ` Peter Maydell
2026-03-03 10:01     ` Daniel P. Berrangé
2026-03-03 10:05       ` Peter Maydell
2026-03-03  8:49 ` Thomas Huth
2026-03-04  1:08 ` Yodel Eldar
2026-03-04  7:38   ` Thomas Huth
2026-03-04 23:14     ` Yodel Eldar
2026-03-05 10:18       ` Daniel P. Berrangé
2026-03-05 10:47         ` Peter Maydell
2026-03-04 10:09   ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.