From bd20a3ace45ca7db952ebf4078cf6cbcbe4886b9 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 7 Jan 2022 14:51:56 +0100 Subject: [PATCH] BUILD: makefile: add -Wno-atomic-alignment to work around clang abusive warning As reported in github issue #1502, clang, when building for i386, will try to use CMPXCHG8B-based loops for 64-bit atomic operations, and emits warnings for all 64-bit operands that are not 64-bit aligned, an alignment that is *not* required by the ABI, that the compiler itself does not enforce, and that the intel SDM clearly says is not required on this 32-bit platform for this operation. But this is likely an excessive outcome of the same code being used in 64-bit for CMPXCHG16B which does require proper alignment. Firefox already gave up on this one 3 years ago, let's not waste our time arguing and just shut up the warning instead. It might hide some real bugs in the future but till now experience showed that overall it's unlikely. This should be backported to all maintained branches that use 64-bit atomic ops (e.g. for counters). Thanks to Brad Smith for reporting it and confirming that shutting the warning addresses it. (cherry picked from commit 790169fe69c139e4fb6fc3046985696aa78c0569) Signed-off-by: Willy Tarreau --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 380effc..58c740a 100644 --- a/Makefile +++ b/Makefile @@ -203,6 +203,7 @@ SPEC_CFLAGS += $(call cc-nowarn,clobbered) SPEC_CFLAGS += $(call cc-nowarn,missing-field-initializers) SPEC_CFLAGS += $(call cc-nowarn,cast-function-type) SPEC_CFLAGS += $(call cc-nowarn,string-plus-int) +SPEC_CFLAGS += $(call cc-nowarn,atomic-alignment) SPEC_CFLAGS += $(call cc-opt,-Wtype-limits) SPEC_CFLAGS += $(call cc-opt,-Wshift-negative-value) SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2) -- 1.7.10.4