All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, pbonzini@redhat.com, crobinso@redhat.com
Subject: [PATCH 3/3] configure: Conditionally disable clang-12 -Watomic-alignment
Date: Mon, 12 Jul 2021 08:59:18 -0700	[thread overview]
Message-ID: <20210712155918.1422519-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20210712155918.1422519-1-richard.henderson@linaro.org>

The i386 abi does not align uint64_t (or double) in structures to 8
bytes, only to 4 bytes.  Furthermore, the hardware does not require
8 byte alignent for cmpxchg8b, so the warning is confusing and useless.

Retain the warning for hosts (notably x86_64) where the ABI is sane,
and one has to do something extraordinary to remove alignment.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 configure | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/configure b/configure
index 95e0a08938..163b4edee2 100755
--- a/configure
+++ b/configure
@@ -3927,6 +3927,22 @@ if compile_prog "" "" ; then
   atomic64=yes
 fi
 
+# Test for clang atomic misalignment warning vs ABI structure misalignment.
+# E.g. i386 only aligns structures to 4 bytes by default.
+if test "$atomic64" = "yes" ; then
+cat > $TMPC << EOF
+#include <stdint.h>
+struct X { uint64_t x; };
+uint64_t foo(struct X *p) { return __atomic_exchange_n(&p->x, 0, 0); }
+EOF
+  if ! compile_prog "-Werror" "" ; then
+    if cc_has_warning_flag "-Wno-atomic-alignment" ; then
+      glib_cflags="-Wno-atomic-alignment $glib_cflags"
+      CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-atomic-alignment"
+    fi
+  fi
+fi
+
 #########################################
 # See if --dynamic-list is supported by the linker
 ld_dynamic_list="no"
-- 
2.25.1



  parent reply	other threads:[~2021-07-12 16:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 15:59 [PATCH 0/3] Atomic cleanup + clang-12 build fix Richard Henderson
2021-07-12 15:59 ` [PATCH 1/3] qemu/atomic: Remove pre-C11 atomic fallbacks Richard Henderson
2021-07-12 15:59 ` [PATCH 2/3] qemu/atomic: Use macros for CONFIG_ATOMIC64 Richard Henderson
2021-07-12 16:29   ` Philippe Mathieu-Daudé
2021-07-12 15:59 ` Richard Henderson [this message]
2021-07-12 21:30 ` [PATCH 0/3] Atomic cleanup + clang-12 build fix Cole Robinson
2021-07-13  0:37   ` Richard Henderson
2021-07-13 14:43     ` Richard Henderson
2021-07-13 15:18       ` Cole Robinson
2021-07-13 16:56         ` Richard Henderson
2021-07-15 15:11           ` Cole Robinson

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=20210712155918.1422519-4-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=crobinso@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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.