[libcxx-commits] [libcxx] [libc++] Don't add #pragma clang attribute with GCC (PR #206989)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 1 06:54:05 PDT 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/206989
GCC doesn't support `#pragma clang attribute`, which causes a bunch of diagnostics. Since we have it behind a macro anyways we can simply define the macro as empty with GCC.
>From d13270a9c78f2cecc7a9d30a42bf07a59ad75601 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 1 Jul 2026 15:48:52 +0200
Subject: [PATCH] [libc++] Don't add #pragma clang attribute with GCC
---
libcxx/include/__configuration/namespace.h | 23 +++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/libcxx/include/__configuration/namespace.h b/libcxx/include/__configuration/namespace.h
index 6b733e3076581..1f4b8ce247b13 100644
--- a/libcxx/include/__configuration/namespace.h
+++ b/libcxx/include/__configuration/namespace.h
@@ -46,15 +46,20 @@
# define _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
#endif
-#define _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS \
- _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS \
- _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push( \
- __attribute__((__exclude_from_explicit_instantiation__, \
- __visibility__("hidden"), \
- __abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))), \
- apply_to = function))) _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
-
-#define _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS _Pragma("clang attribute _LibcxxExplicitABIAnnotations.pop")
+#ifdef _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS \
+ _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS \
+ _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push( \
+ __attribute__((__exclude_from_explicit_instantiation__, \
+ __visibility__("hidden"), \
+ __abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))), \
+ apply_to = function))) _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
+
+# define _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS _Pragma("clang attribute _LibcxxExplicitABIAnnotations.pop")
+#else
+# define _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
+# define _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
+#endif
// clang-format off
More information about the libcxx-commits
mailing list