[llvm] [llvm] revisions to export annotation macros to avoid compiler warnings (PR #135995)

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 15:13:54 PDT 2025


================
@@ -197,17 +197,32 @@
 #define LLVM_EXPORT_TEMPLATE
 #endif
 #define LLVM_ABI_EXPORT __declspec(dllexport)
-#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) ||             \
-    defined(__MVS__)
-#define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
-#define LLVM_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#elif (defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) ||            \
+       defined(__MVS__)) &&                                                    \
+    __has_attribute(visibililty)
+// Use __attribute__((visibility(""))) syntax for visibility rather than
+// [[gnu::visibility("")]] because compilers are more permissive with its
+// placement.
+#define LLVM_ABI __attribute__((visibility("default")))
+#if defined(__GNUC__) && !defined(__clang__)
+// GCC produces warnings on visibility attributes applied to some templates.
----------------
compnerd wrote:

Ouch! Is this really limited to just GCC? What about QCC? What about ICC (or I suppose the now deprecated ICC)? What about xLC? That is, is this potentially a clang extension?

https://github.com/llvm/llvm-project/pull/135995


More information about the llvm-commits mailing list