diff mbox series

[RFC] x86/IOMMU: permit use of -save-temps

Message ID ae0b4331-638e-4193-9536-6bfccc777e27@suse.com (mailing list archive)
State New
Headers show
Series [RFC] x86/IOMMU: permit use of -save-temps | expand

Commit Message

Jan Beulich July 23, 2024, 10:43 a.m. UTC
Rather than invoking make for individual .i and/or .i targets, it may be
desirable to simply add -save-temps to $(CFLAGS) for some (or all)
source files. That, however, triggers a tautological compare warning
with at least gcc13 / gcc14. Apparently such warnings are suppressed
when the compiler knows they originate from macro context; use of
-save-temps, however, splits translation steps, and compiling the output
of pre-processing does not have that contextual information anymore.

Hack around this by making both sides of the comparison just different
enough for the compiler to no longer spot the tautology, without
sacrificing the dual purpose of the assertion (type match at build time,
value match at runtime). Of course as the compiler gets smarter, further
obfuscation may be needed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
RFC: Of course this escalation spiral isn't a good game to play. Are
     there alternatives I'm overlooking? I don't think we want to use
     -Wno-tautological-compare.
diff mbox series

Patch

--- a/xen/arch/x86/include/asm/iommu.h
+++ b/xen/arch/x86/include/asm/iommu.h
@@ -60,12 +60,12 @@  extern struct iommu_ops iommu_ops;
 
 # include <asm/alternative.h>
 # define iommu_call(ops, fn, args...) ({      \
-    ASSERT((ops) == &iommu_ops);              \
+    ASSERT((ops) == (1 ? &iommu_ops : NULL)); \
     alternative_call(iommu_ops.fn, ## args);  \
 })
 
 # define iommu_vcall(ops, fn, args...) ({     \
-    ASSERT((ops) == &iommu_ops);              \
+    ASSERT((ops) == (1 ? &iommu_ops : NULL)); \
     alternative_vcall(iommu_ops.fn, ## args); \
 })