abi-breaking.h.cmake 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
  2. /* */
  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 */
  7. /* */
  8. /*===----------------------------------------------------------------------===*/
  9. /* This file controls the C++ ABI break introduced in LLVM public header. */
  10. #ifndef LLVM_ABI_BREAKING_CHECKS_H
  11. #define LLVM_ABI_BREAKING_CHECKS_H
  12. /* Define to enable checks that alter the LLVM C++ ABI */
  13. #cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS
  14. /* Define to enable reverse iteration of unordered llvm containers */
  15. #cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION
  16. /* Allow selectively disabling link-time mismatch checking so that header-only
  17. ADT content from LLVM can be used without linking libSupport. */
  18. #if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
  19. // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build
  20. // mismatch with LLVM
  21. #if defined(_MSC_VER)
  22. // Use pragma with MSVC
  23. #define LLVM_XSTR(s) LLVM_STR(s)
  24. #define LLVM_STR(s) #s
  25. #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
  26. #undef LLVM_XSTR
  27. #undef LLVM_STR
  28. #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
  29. // FIXME: Implement checks without weak.
  30. #elif defined(__cplusplus)
  31. #if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__))
  32. #define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden")))
  33. #else
  34. // GCC on AIX does not support visibility attributes. Symbols are not
  35. // exported by default on AIX.
  36. #define LLVM_HIDDEN_VISIBILITY
  37. #endif
  38. namespace llvm {
  39. #if LLVM_ENABLE_ABI_BREAKING_CHECKS
  40. extern int EnableABIBreakingChecks;
  41. LLVM_HIDDEN_VISIBILITY
  42. __attribute__((weak)) int *VerifyEnableABIBreakingChecks =
  43. &EnableABIBreakingChecks;
  44. #else
  45. extern int DisableABIBreakingChecks;
  46. LLVM_HIDDEN_VISIBILITY
  47. __attribute__((weak)) int *VerifyDisableABIBreakingChecks =
  48. &DisableABIBreakingChecks;
  49. #endif
  50. }
  51. #undef LLVM_HIDDEN_VISIBILITY
  52. #endif // _MSC_VER
  53. #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
  54. #endif