[libcxx-commits] [libcxx] [libc++] Guard explicit ABI annotations for Clang >= 21 (PR #212249)

Milad Fa via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 27 06:37:52 PDT 2026


https://github.com/miladfarca created https://github.com/llvm/llvm-project/pull/212249

Clang < 21 doesn't support `__visibility__` with #pragma clang attribute
(PragmaAttributeSupport was added in afc6c2bb9b43). Since the macro
already has an empty fallback for gcc (added by 6f3328e), gate it on the required version.

>From 02da1b67dbccdacdd5174dc5c0d37bb0a28e41b8 Mon Sep 17 00:00:00 2001
From: Milad Fa <mfarazma at ibm.com>
Date: Mon, 27 Jul 2026 13:29:16 +0000
Subject: [PATCH] Fix

---
 libcxx/include/__configuration/namespace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__configuration/namespace.h b/libcxx/include/__configuration/namespace.h
index 1f4b8ce247b13..032c16e358aa3 100644
--- a/libcxx/include/__configuration/namespace.h
+++ b/libcxx/include/__configuration/namespace.h
@@ -46,7 +46,7 @@
 #  define _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
 #endif
 
-#ifdef _LIBCPP_COMPILER_CLANG_BASED
+#if defined(_LIBCPP_COMPILER_CLANG_BASED) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2101)
 #  define _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS                                                                         \
     _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS                                                                                \
     _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push(                                       \



More information about the libcxx-commits mailing list