blob: 850d0c61f9e5d16a85643ec1bc6f4c00782b192d [file] [log] [blame]
Alexis Hetudd662d22018-08-09 17:24:51 -04001/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
2/* */
3/* The LLVM Compiler Infrastructure */
4/* */
5/* This file is distributed under the University of Illinois Open Source */
6/* License. See LICENSE.TXT for details. */
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 */
Nicolas Capens59eb5dd2020-11-03 14:20:12 -050016#if defined(NDEBUG)
17#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0
18#else
Alexis Hetudd662d22018-08-09 17:24:51 -040019#define LLVM_ENABLE_ABI_BREAKING_CHECKS 1
Nicolas Capens59eb5dd2020-11-03 14:20:12 -050020#endif
Alexis Hetudd662d22018-08-09 17:24:51 -040021
22/* Define to disable the link-time checking of mismatch for
23 LLVM_ENABLE_ABI_BREAKING_CHECKS */
24#define LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 1
25#if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
26
27// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
28// mismatch with LLVM
29#if defined(_MSC_VER)
30// Use pragma with MSVC
31#define LLVM_XSTR(s) LLVM_STR(s)
32#define LLVM_STR(s) #s
33#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
34#undef LLVM_XSTR
35#undef LLVM_STR
36#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
37// FIXME: Implement checks without weak.
38#elif defined(__cplusplus)
39namespace llvm {
40#if LLVM_ENABLE_ABI_BREAKING_CHECKS
41extern int EnableABIBreakingChecks;
42__attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks;
43#else
44extern int DisableABIBreakingChecks;
45__attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks;
46#endif
47}
48#endif // _MSC_VER
49
50#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
51
52#endif