[llvm] [llvm] revisions to `LLVM_ABI` export macro definitions (PR #144598)
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 16:46:31 PDT 2025
================
@@ -184,19 +179,8 @@
// Marker to add to classes or functions in public headers that should not have
// export macros added to them by the clang tool
#define LLVM_ABI_NOT_EXPORTED
-#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) || \
- defined(LLVM_ENABLE_PLUGINS)
-// Some libraries like those for tablegen are linked in to tools that used
-// 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(LLVM_BUILD_STATIC)
-#define LLVM_ABI
-#define LLVM_ABI_FRIEND
-#define LLVM_TEMPLATE_ABI
-#define LLVM_EXPORT_TEMPLATE
-#define LLVM_ABI_EXPORT
-#elif defined(_WIN32) && !defined(__MINGW32__)
+#if defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) && !defined(LLVM_BUILD_STATIC)
----------------
compnerd wrote:
The headers are associated with a build, that build can only be used one way (static or dynamic). We should record that into `llvm-config.h` via the `#cmakedefine LLVM_BUILD_STATIC`. Then when ready to enable the attributes by default:
```c
#if defined(LLVM_BUILD_STATIC)
#define LLVM_ABI /**/
#else
#if defined(LLVM_EXPORTS)
#define LLVM_ABI __declspec(dllexport)
#else
#define LLVM_ABI __declspec(dllimport)
#endif
#endif
```
`LLVM_EXPORTS` would be defined by the build system (normally, CMake would define this for you if `BUILD_SHARED_LIBS` is set and you are building the `LLVM` library).
https://github.com/llvm/llvm-project/pull/144598
More information about the llvm-commits
mailing list