[llvm] [llvm] annotate ABIBreakingChecks symobls for DLL export (PR #145575)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 09:24:46 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:
> Is there anything that we can do to ensure that the code is impossible to drift? I'd rather have the layering violation than that.
We could move the `LLVM_ABI` macro definitions to Config, which wouldn't necessarily be wrong, but is probably overkill. I think the layering violation is the best option to avoid potentially drifting definitions.
> The constant here is to be homed within LLVM itself right?
Right, the symbols are defined in `llvm/lib/Support/ABIBreak.cpp`. I think the only reason the header is under Config is because it uses `#cmakedefine`.
https://github.com/llvm/llvm-project/pull/145575
More information about the llvm-commits
mailing list