Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/ |
| 2 | /* */ |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | /* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ |
| 4 | /* Exceptions. */ |
| 5 | /* See https://llvm.org/LICENSE.txt for license information. */ |
| 6 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 7 | /* */ |
| 8 | /*===----------------------------------------------------------------------===*/ |
| 9 | |
| 10 | /* This file controls the C++ ABI break introduced in LLVM public header. */ |
| 11 | |
| 12 | #ifndef LLVM_ABI_BREAKING_CHECKS_H |
| 13 | #define LLVM_ABI_BREAKING_CHECKS_H |
| 14 | |
| 15 | /* Define to enable checks that alter the LLVM C++ ABI */ |
| 16 | #define LLVM_ENABLE_ABI_BREAKING_CHECKS 0 |
| 17 | |
| 18 | /* Define to enable reverse iteration of unordered llvm containers */ |
| 19 | #define LLVM_ENABLE_REVERSE_ITERATION 0 |
| 20 | |
| 21 | /* Allow selectively disabling link-time mismatch checking so that header-only |
| 22 | ADT content from LLVM can be used without linking libSupport. */ |
| 23 | #if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING |
| 24 | |
| 25 | // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build |
| 26 | // mismatch with LLVM |
| 27 | #if defined(_MSC_VER) |
| 28 | // Use pragma with MSVC |
| 29 | #define LLVM_XSTR(s) LLVM_STR(s) |
| 30 | #define LLVM_STR(s) #s |
| 31 | #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) |
| 32 | #undef LLVM_XSTR |
| 33 | #undef LLVM_STR |
| 34 | #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch |
| 35 | // FIXME: Implement checks without weak. |
| 36 | #elif defined(__cplusplus) |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 37 | #if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__)) |
| 38 | #define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden"))) |
| 39 | #else |
| 40 | // GCC on AIX does not support visibility attributes. Symbols are not |
| 41 | // exported by default on AIX. |
| 42 | #define LLVM_HIDDEN_VISIBILITY |
| 43 | #endif |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 44 | namespace llvm { |
| 45 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS |
| 46 | extern int EnableABIBreakingChecks; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 47 | LLVM_HIDDEN_VISIBILITY |
| 48 | __attribute__((weak)) int *VerifyEnableABIBreakingChecks = |
| 49 | &EnableABIBreakingChecks; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 50 | #else |
| 51 | extern int DisableABIBreakingChecks; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 52 | LLVM_HIDDEN_VISIBILITY |
| 53 | __attribute__((weak)) int *VerifyDisableABIBreakingChecks = |
| 54 | &DisableABIBreakingChecks; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 55 | #endif |
| 56 | } |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 57 | #undef LLVM_HIDDEN_VISIBILITY |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 58 | #endif // _MSC_VER |
| 59 | |
| 60 | #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING |
| 61 | |
| 62 | #endif |