]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: add -Wno-atomic-alignment to work around clang abusive warning
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Jan 2022 13:51:56 +0000 (14:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Jan 2022 13:58:48 +0000 (14:58 +0100)
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.

Makefile

index 380effc539e12e28410b3184661e5e82efd0d5b1..58c740a42a3b607da55007201926464d797e3ba2 100644 (file)
--- 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)