diff mbox series

[3/3] configure: Conditionally disable clang-12 -Watomic-alignment

Message ID 20210712155918.1422519-4-richard.henderson@linaro.org
State New
Headers show
Series Atomic cleanup + clang-12 build fix | expand

Commit Message

Richard Henderson July 12, 2021, 3:59 p.m. UTC
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(+)

-- 
2.25.1
diff mbox series

Patch

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"