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

Jan Beulich posted 1 patch 1 month, 2 weeks ago
Failed in applying to current master (apply log)
[PATCH RFC] x86/IOMMU: permit use of -save-temps
Posted by Jan Beulich 1 month, 2 weeks ago
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.

--- 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); \
 })