Skip to contentSkip to conversation

x86/IOMMU: permit use of -save-temps

RFC PATCH New Jan Beulich 1 participant 1 message Jul 23, 2024

lore
Share & tools
lore
#0 lore raw

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

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.

---
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.

xen/arch/x86/include/asm/iommu.h +2 -2
@@ -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); \
 })