|
12 | 12 | #ifndef LLVM_ABI_BREAKING_CHECKS_H
|
13 | 13 | #define LLVM_ABI_BREAKING_CHECKS_H
|
14 | 14 |
|
| 15 | +// llvm-config.h is required for LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS |
| 16 | +#include "llvm/Config/llvm-config.h" |
| 17 | + |
15 | 18 | /* Define to enable checks that alter the LLVM C++ ABI */
|
16 | 19 | #cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS
|
17 | 20 |
|
18 | 21 | /* Define to enable reverse iteration of unordered llvm containers */
|
19 | 22 | #cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION
|
20 | 23 |
|
| 24 | +#if !defined(__has_attribute) |
| 25 | +#define __has_attribute(attribute) 0 |
| 26 | +#endif |
| 27 | + |
| 28 | +// Properly annotate EnableABIBreakingChecks or DisableABIBreakingChecks for |
| 29 | +// export from shared library. |
| 30 | +// TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for |
| 31 | +// two preprocessor definitions to gate LLVM_ABI macro definitions. |
| 32 | +#if defined(LLVM_BUILD_STATIC) || !defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) |
| 33 | +#define ABI_BREAKING_EXPORT_ABI |
| 34 | +#else |
| 35 | +#if defined(_WIN32) |
| 36 | +#if defined(LLVM_EXPORTS) |
| 37 | +#define ABI_BREAKING_EXPORT_ABI __declspec(dllexport) |
| 38 | +#else |
| 39 | +#define ABI_BREAKING_EXPORT_ABI __declspec(dllimport) |
| 40 | +#endif |
| 41 | +#else |
| 42 | +#if __has_attribute(visibility) |
| 43 | +#define ABI_BREAKING_EXPORT_ABI __attribute__((__visibility__("default"))) |
| 44 | +#else |
| 45 | +#define ABI_BREAKING_EXPORT_ABI |
| 46 | +#endif |
| 47 | +#endif |
| 48 | +#endif |
| 49 | + |
21 | 50 | /* Allow selectively disabling link-time mismatch checking so that header-only
|
22 | 51 | ADT content from LLVM can be used without linking libSupport. */
|
23 | 52 | #if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
|
|
43 | 72 | #endif
|
44 | 73 | namespace llvm {
|
45 | 74 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS
|
46 |
| -extern int EnableABIBreakingChecks; |
| 75 | +ABI_BREAKING_EXPORT_ABI extern int EnableABIBreakingChecks; |
47 | 76 | LLVM_HIDDEN_VISIBILITY
|
48 | 77 | __attribute__((weak)) int *VerifyEnableABIBreakingChecks =
|
49 | 78 | &EnableABIBreakingChecks;
|
50 | 79 | #else
|
51 |
| -extern int DisableABIBreakingChecks; |
| 80 | +ABI_BREAKING_EXPORT_ABI extern int DisableABIBreakingChecks; |
52 | 81 | LLVM_HIDDEN_VISIBILITY
|
53 | 82 | __attribute__((weak)) int *VerifyDisableABIBreakingChecks =
|
54 | 83 | &DisableABIBreakingChecks;
|
|
0 commit comments