[PATCH v2 3/3] eal: enforce internal API check with Clang 14

David Marchand david.marchand at redhat.com
Thu Oct 15 13:29:16 CEST 2026


From: Thomas Monjalon <thomas at monjalon.net>

The __rte_internal macro is intended to prevent calls
to internal API functions unless ALLOW_INTERNAL_API is defined.
Unfortunately the check misses some calls to internal API
when built with GCC or Clang.
Clang can be better to diagnose such cases.

Clang 14 and later support the error attribute
and therefore select it instead of diagnose_if for __rte_internal.
Unlike diagnose_if, the error attribute only rejects
internal API calls that remain after optimization.
Internal API calls can therefore go easily unnoticed,
making internal API checks less strict with recent Clang.

Prefer diagnose_if when available to keep strong Clang diagnostics.
Retain the error attribute as a fallback for GCC.

Fixes: 4ab63cd60ceb ("eal: fix internal ABI tag with clang")
Cc: stable at dpdk.org

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 lib/eal/include/rte_compat.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index cb7836a190..89c3465245 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -33,13 +33,7 @@ __attribute__((section(".text.experimental")))
 #define __has_attribute(x) 0
 #endif
 
-#if __has_attribute(error) /* For GCC */
-
-#define __rte_internal \
-__attribute__((error("Symbol is not public ABI"), \
-section(".text.internal")))
-
-#elif __has_attribute(diagnose_if) /* For clang */
+#if __has_attribute(diagnose_if) /* For Clang */
 
 #define __rte_internal \
 _Pragma("GCC diagnostic push") \
@@ -48,6 +42,12 @@ __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \
 section(".text.internal"))) \
 _Pragma("GCC diagnostic pop")
 
+#elif __has_attribute(error) /* For GCC */
+
+#define __rte_internal \
+__attribute__((error("Symbol is not public ABI"), \
+section(".text.internal")))
+
 #endif
 
 #endif /* !ALLOW_INTERNAL_API */
-- 
2.54.0



More information about the dev mailing list