From: Kevin Wolf <kwolf@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [PATCH] configure: Disable thread-safety warnings on macOS
Date: Wed, 1 Mar 2023 14:31:45 +0100 [thread overview]
Message-ID: <Y/9TwfYFEsVeZKTr@redhat.com> (raw)
In-Reply-To: <20230301113425.286946-1-thuth@redhat.com>
Am 01.03.2023 um 12:34 hat Thomas Huth geschrieben:
> The enablement of -Wthread-safety broke compilation on macOS (if
> -Werror is enabled, like in our CI). Disable it there by default
> until the problems are resolved.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
This is simpler than what I attempted (test compiling something using
the same TSA features as the failing code), but didn't actually work.
Since I don't have access to macOS, it's hard for me to improve the
configure test. So I'm fine with just doing this instead.
Acked-by: Kevin Wolf <kwolf@redhat.com>
For reference, below my failed alternative attempt at a configure patch,
which somehow still enabled TSA on macOS and therefore still fails to
build.
Kevin
diff --git a/configure b/configure
index 2a8a9be8a1..970ee31889 100755
--- a/configure
+++ b/configure
@@ -228,6 +228,7 @@ cross_prefix=""
host_cc="cc"
stack_protector=""
safe_stack=""
+tsa=""
use_containers="yes"
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
@@ -854,6 +855,10 @@ for opt do
;;
--disable-safe-stack) safe_stack="no"
;;
+ --enable-tsa) tsa="yes"
+ ;;
+ --disable-tsa) tsa="no"
+ ;;
--enable-cfi)
cfi="true";
meson_option_add -Db_lto=true
@@ -1023,6 +1028,7 @@ Advanced options (experts only):
--with-devices-ARCH=NAME override default configs/devices
--enable-debug enable common debug build options
--enable-sanitizers enable default sanitizers
+ --enable-tsa enable TSA (Thread Safety Analysis)
--enable-tsan enable thread sanitizer
--disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection
@@ -1230,7 +1236,6 @@ add_to warn_flags -Wendif-labels
add_to warn_flags -Wexpansion-to-defined
add_to warn_flags -Wimplicit-fallthrough=2
add_to warn_flags -Wmissing-format-attribute
-add_to warn_flags -Wthread-safety
nowarn_flags=
add_to nowarn_flags -Wno-initializer-overrides
@@ -1308,6 +1313,28 @@ EOF
fi
fi
+if test "$tsa" != "no"; then
+ cat > $TMPC << EOF
+typedef int __attribute__((capability("mutex"))) Lock;
+Lock lock;
+static void __attribute__((assert_capability(lock))) assert_lock(void) {}
+static void __attribute__((requires_capability(lock))) require_lock(void) {}
+int main(void)
+{
+ assert_lock();
+ require_lock();
+ return 0;
+}
+EOF
+ flag="-Wthread-safety"
+ if compile_object "-Werror $flag"; then
+ QEMU_CFLAGS="$QEMU_CFLAGS $flag"
+ tsa="yes"
+ elif test "$tsa" = yes; then
+ error_exit "Thread Safety Analysis not supported"
+ fi
+fi
+
# Our module code doesn't support Windows
if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
error_exit "Modules are not available for Windows"
@@ -2378,6 +2405,9 @@ if test "$have_asan_iface_fiber" = "yes" ; then
echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
fi
+if test "$tsa" = "yes"; then
+ echo "CONFIG_TSA=y" >> $config_host_mak
+fi
if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
echo "CONFIG_TSAN=y" >> $config_host_mak
fi
diff --git a/meson.build b/meson.build
index 77d2ae87e4..a793eaacc5 100644
--- a/meson.build
+++ b/meson.build
@@ -3842,6 +3842,7 @@ else
endif
summary_info += {'gprof': gprof_info}
summary_info += {'gcov': get_option('b_coverage')}
+summary_info += {'thread safety analysis (TSA)': config_host.has_key('CONFIG_TSA')}
summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
summary_info += {'CFI support': get_option('cfi')}
if get_option('cfi')
next prev parent reply other threads:[~2023-03-01 13:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 11:34 [PATCH] configure: Disable thread-safety warnings on macOS Thomas Huth
2023-03-01 13:31 ` Kevin Wolf [this message]
2023-03-04 15:42 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/9TwfYFEsVeZKTr@redhat.com \
--to=kwolf@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=eesposit@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.