[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] configure: Conditionally disable clang-12 -Watomic-alignment
From: |
Richard Henderson |
Subject: |
[PATCH 3/3] configure: Conditionally disable clang-12 -Watomic-alignment |
Date: |
Mon, 12 Jul 2021 08:59:18 -0700 |
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