[clang] [llvm] [clang] Clean up the Clang export annotations (PR #239750)

Fabrice de Gans via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 03:21:11 PST 2026


================
@@ -40,12 +41,9 @@
 // in the build so can't depend on the llvm shared library. If export macros
 // were left enabled when building these we would get duplicate or
 // missing symbol linker errors on windows.
-#if defined(CLANG_BUILD_STATIC)
-#define CLANG_ABI
-#define CLANG_ABI_EXPORT
-#define CLANG_TEMPLATE_ABI
-#define CLANG_EXPORT_TEMPLATE
-#elif defined(_WIN32) && !defined(__MINGW32__)
+#if defined(CLANG_ENABLE_CLANG_EXPORT_ANNOTATIONS) &&                          \
+    !defined(CLANG_BUILD_STATIC)
----------------
Steelskin wrote:

I am flipping your logic around a bit, by removing `CLANG_BUILD_STATIC` instead. The reason why is that I would rather keep the shape of the macro definitions closer to the one we use in LLVM, and it will make it easier to iterate over the annotated `libclang-cpp` build when I get to it. We should not have the per-target static override in the first place and it functionally does nothing right now anyway as the annotated build is not functional.

The main reason why we need the override in LLVM is for LLVM tablegen tools, and that is because they depend on the same target that the LLVM dylib depends on. This is not the case in Clang, which has a small library called `clangSupport_tablegen` that tablegens depend on and we can make use of that. Longer term, I want to have an equivalent in LLVM, but there is more work involved there.

I'm tabling the `protected` part for Linux for now. We can revisit later and that's a difference with how LLVM does it.

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


More information about the cfe-commits mailing list