brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 330f360 Raw
92 lines · plain
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 10/* This file controls the C++ ABI break introduced in LLVM public header. */11 12#ifndef LLVM_ABI_BREAKING_CHECKS_H13#define LLVM_ABI_BREAKING_CHECKS_H14 15// llvm-config.h is required for LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS16#include "llvm/Config/llvm-config.h"17 18/* Define to enable checks that alter the LLVM C++ ABI */19#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS20 21/* Define to enable reverse iteration of unordered llvm containers */22#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION23 24#if !defined(__has_attribute)25#define __has_attribute(attribute) 026#endif27 28// Properly annotate EnableABIBreakingChecks or DisableABIBreakingChecks for29// export from shared library.30// TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for31// 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_ABI34#else35#if defined(_WIN32)36#if defined(LLVM_EXPORTS)37#define ABI_BREAKING_EXPORT_ABI __declspec(dllexport)38#else39#define ABI_BREAKING_EXPORT_ABI __declspec(dllimport)40#endif41#else42#if __has_attribute(visibility)43#define ABI_BREAKING_EXPORT_ABI __attribute__((__visibility__("default")))44#else45#define ABI_BREAKING_EXPORT_ABI46#endif47#endif48#endif49 50/* Allow selectively disabling link-time mismatch checking so that header-only51   ADT content from LLVM can be used without linking libSupport. */52#if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING53 54// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build55// mismatch with LLVM56#if defined(_MSC_VER)57// Use pragma with MSVC58#define LLVM_XSTR(s) LLVM_STR(s)59#define LLVM_STR(s) #s60#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))61#undef LLVM_XSTR62#undef LLVM_STR63#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch64// FIXME: Implement checks without weak.65#elif defined(__cplusplus)66#if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__))67#define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden")))68#else69// GCC on AIX does not support visibility attributes. Symbols are not70// exported by default on AIX.71#define LLVM_HIDDEN_VISIBILITY72#endif73namespace llvm {74#if LLVM_ENABLE_ABI_BREAKING_CHECKS75ABI_BREAKING_EXPORT_ABI extern int EnableABIBreakingChecks;76LLVM_HIDDEN_VISIBILITY77__attribute__((weak)) int *VerifyEnableABIBreakingChecks =78    &EnableABIBreakingChecks;79#else80ABI_BREAKING_EXPORT_ABI extern int DisableABIBreakingChecks;81LLVM_HIDDEN_VISIBILITY82__attribute__((weak)) int *VerifyDisableABIBreakingChecks =83    &DisableABIBreakingChecks;84#endif85}86#undef LLVM_HIDDEN_VISIBILITY87#endif // _MSC_VER88 89#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING90 91#endif92