[llvm] [llvm] annotate ABIBreakingChecks symobls for DLL export (PR #145575)

Andrew Rogers via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 7 08:58:49 PDT 2025


================
@@ -12,12 +12,36 @@
 #ifndef LLVM_ABI_BREAKING_CHECKS_H
 #define LLVM_ABI_BREAKING_CHECKS_H
 
+// llvm-config.h is required for LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS
+#include "llvm/Config/llvm-config.h"
+
 /* Define to enable checks that alter the LLVM C++ ABI */
 #cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS
 
 /* Define to enable reverse iteration of unordered llvm containers */
 #cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION
 
+// Properly annotate EnableABIBreakingChecks or DisableABIBreakingChecks for
+// export from shared library.
+#if !defined(LLVM_ABI_GENERATING_ANNOTATIONS)
+// TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for
+// two preprocessor definitions to gate LLVM_ABI macro definitions.
+#if defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) && !defined(LLVM_BUILD_STATIC)
+#if defined(_WIN32) && !defined(__MINGW32__)
+#if defined(LLVM_EXPORTS)
+#define ABI_BREAKING_EXPORT_ABI __declspec(dllexport)
----------------
andrurogerz wrote:

@compnerd it does build correctly if I insteqad `#include "llvm/Support/Compiler.h"` and use `LLVM_ABI` here, but it didn't seem correct  to have Config depend on a Support header in this way. This change effectively just replicates the `LLVM_ABI` definition logic here with a different name, `ABI_BREAKING_EXPORT_ABI`.

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


More information about the llvm-commits mailing list