DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eal: enforce internal API check with Clang
@ 2026-10-14 20:16 Thomas Monjalon
  2026-10-15  8:54 ` Burakov, Anatoly
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Thomas Monjalon @ 2026-10-14 20:16 UTC (permalink / raw)
  To: dev; +Cc: stable, Bruce Richardson

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@dpdk.org

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

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index 97c1540bd0..b62e49d676 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -32,17 +32,7 @@ __attribute__((section(".text.experimental")))
 #define __has_attribute(x) 0
 #endif
 
-#if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */
-
-#ifdef RTE_TOOLCHAIN_MSVC
-#define __rte_internal
-#else
-#define __rte_internal \
-__attribute__((error("Symbol is not public ABI"), \
-section(".text.internal")))
-#endif
-
-#elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */
+#if !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For Clang */
 
 #ifdef RTE_TOOLCHAIN_MSVC
 #define __rte_internal
@@ -55,6 +45,16 @@ section(".text.internal"))) \
 _Pragma("GCC diagnostic pop")
 #endif
 
+#elif !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */
+
+#ifdef RTE_TOOLCHAIN_MSVC
+#define __rte_internal
+#else
+#define __rte_internal \
+__attribute__((error("Symbol is not public ABI"), \
+section(".text.internal")))
+#endif
+
 #else
 
 #ifdef RTE_TOOLCHAIN_MSVC
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-15 11:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 20:16 [PATCH] eal: enforce internal API check with Clang Thomas Monjalon
2026-10-15  8:54 ` Burakov, Anatoly
2026-10-15 10:57 ` David Marchand
2026-10-15 11:29 ` [PATCH v2 1/3] buildtools/chkincs: relax checks on driver headers David Marchand
2026-10-15 11:29   ` [PATCH v2 2/3] eal: simplify internal/experimental tags definitions David Marchand
2026-10-15 11:29   ` [PATCH v2 3/3] eal: enforce internal API check with Clang 14 David Marchand
2026-10-15 11:31     ` Burakov, Anatoly
2026-10-15 11:38       ` David Marchand
2026-10-15 11:40     ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox