brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · 38b85c6 Raw
155 lines · c
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CONFIGURATION_ABI_H11#define _LIBCPP___CONFIGURATION_ABI_H12 13#include <__config_site>14#include <__configuration/compiler.h>15#include <__configuration/platform.h>16 17#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER18#  pragma GCC system_header19#endif20 21// FIXME: ABI detection should be done via compiler builtin macros. This22// is just a placeholder until Clang implements such macros. For now assume23// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,24// and allow the user to explicitly specify the ABI to handle cases where this25// heuristic falls short.26#if _LIBCPP_ABI_FORCE_ITANIUM && _LIBCPP_ABI_FORCE_MICROSOFT27#  error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be true"28#elif _LIBCPP_ABI_FORCE_ITANIUM29#  define _LIBCPP_ABI_ITANIUM30#elif _LIBCPP_ABI_FORCE_MICROSOFT31#  define _LIBCPP_ABI_MICROSOFT32#else33// Windows uses the Microsoft ABI34#  if defined(_WIN32) && defined(_MSC_VER)35#    define _LIBCPP_ABI_MICROSOFT36 37// 32-bit ARM uses the Itanium ABI with a few differences (array cookies, etc),38// and so does 64-bit ARM on Apple platforms.39#  elif defined(__arm__) || (defined(__APPLE__) && defined(__aarch64__))40#    define _LIBCPP_ABI_ITANIUM_WITH_ARM_DIFFERENCES41 42// Non-Apple 64-bit ARM uses the vanilla Itanium ABI43#  elif defined(__aarch64__)44#    define _LIBCPP_ABI_ITANIUM45 46// We assume that other architectures also use the vanilla Itanium ABI too47#  else48#    define _LIBCPP_ABI_ITANIUM49#  endif50#endif51 52#if _LIBCPP_ABI_VERSION >= 253// TODO: Move the description of the remaining ABI flags to ABIGuarantees.rst or remove them.54 55// Override the default return value of exception::what() for bad_function_call::what()56// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).57// This is an ABI break on platforms that sign and authenticate vtable function pointers58// because it changes the mangling of the virtual function located in the vtable, which59// changes how it gets signed.60#  define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE61// According to the Standard, `bitset::operator[] const` returns bool62#  define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL63 64// These flags are documented in ABIGuarantees.rst65#  define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT66#  define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON67#  define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON68#  define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_1069#  define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI70#  define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI71#  define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION72#  define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE73#  define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE74#  define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE75#  define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING76#  define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE77#  define _LIBCPP_ABI_NO_ITERATOR_BASES78#  define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT79#  define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER80#  define _LIBCPP_ABI_OPTIMIZED_FUNCTION81#  define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO82#  define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION83#  define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY84#  define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW85#  define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION86 87#elif _LIBCPP_ABI_VERSION == 188#  if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))89// Enable compiling copies of now inline methods into the dylib to support90// applications compiled against older libraries. This is unnecessary with91// COFF dllexport semantics, since dllexport forces a non-inline definition92// of inline functions to be emitted anyway. Our own non-inline copy would93// conflict with the dllexport-emitted copy, so we disable it. For XCOFF,94// the linker will take issue with the symbols in the shared object if the95// weak inline methods get visibility (such as from -fvisibility-inlines-hidden),96// so disable it.97#    define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS98#  endif99// Feature macros for disabling pre ABI v1 features. All of these options100// are deprecated.101#  if defined(__FreeBSD__)102#    define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR103#  endif104#endif105 106// TODO(LLVM 22): Remove this check107#if defined(_LIBCPP_ABI_NO_ITERATOR_BASES) && !defined(_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER)108#  ifndef _LIBCPP_ONLY_NO_ITERATOR_BASES109#    error "You probably want to define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER. This has been split out from"   \110 " _LIBCPP_ABI_NO_ITERATOR_BASES to allow only removing the second iterator member, since they aren't really related." \111 "If you actually want this ABI configuration, please define _LIBCPP_ONLY_NO_ITERATOR_BASES instead."112#  endif113#endif114 115// We had some bugs where we use [[no_unique_address]] together with construct_at,116// which causes UB as the call on construct_at could write to overlapping subobjects117//118// https://llvm.org/PR70506119// https://llvm.org/PR70494120//121// To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions.122// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.123#define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))124 125// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work.126#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING)127#  define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING128#endif129 130// Tracks the bounds of the array owned by std::unique_ptr<T[]>, allowing it to trap when accessed out-of-bounds.131// Note that limited bounds checking is also available outside of this ABI configuration, but only some categories132// of types can be checked.133//134// ABI impact: This causes the layout of std::unique_ptr<T[]> to change and its size to increase.135//             This also affects the representation of a few library types that use std::unique_ptr136//             internally, such as the unordered containers.137// #define _LIBCPP_ABI_BOUNDED_UNIQUE_PTR138 139#if defined(_LIBCPP_COMPILER_CLANG_BASED)140#  if defined(__APPLE__)141#    if defined(__i386__) || defined(__x86_64__)142// use old string layout on x86_64 and i386143#    elif defined(__arm__)144// use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs145#      if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2146#        define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT147#      endif148#    else149#      define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT150#    endif151#  endif152#endif153 154#endif // _LIBCPP___CONFIGURATION_ABI_H155