1*0fca6ea1SDimitry Andric // -*- C++ -*- 2*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===// 3*0fca6ea1SDimitry Andric // 4*0fca6ea1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*0fca6ea1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6*0fca6ea1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*0fca6ea1SDimitry Andric // 8*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===// 9*0fca6ea1SDimitry Andric 10*0fca6ea1SDimitry Andric #ifndef _LIBCPP___CONFIGURATION_ABI_H 11*0fca6ea1SDimitry Andric #define _LIBCPP___CONFIGURATION_ABI_H 12*0fca6ea1SDimitry Andric 13*0fca6ea1SDimitry Andric #include <__config_site> 14*0fca6ea1SDimitry Andric #include <__configuration/compiler.h> 15*0fca6ea1SDimitry Andric #include <__configuration/platform.h> 16*0fca6ea1SDimitry Andric 17*0fca6ea1SDimitry Andric #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 18*0fca6ea1SDimitry Andric # pragma GCC system_header 19*0fca6ea1SDimitry Andric #endif 20*0fca6ea1SDimitry Andric 21*0fca6ea1SDimitry Andric #if _LIBCPP_ABI_VERSION >= 2 22*0fca6ea1SDimitry Andric // Change short string representation so that string data starts at offset 0, 23*0fca6ea1SDimitry Andric // improving its alignment in some cases. 24*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 25*0fca6ea1SDimitry Andric // Fix deque iterator type in order to support incomplete types. 26*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 27*0fca6ea1SDimitry Andric // Fix undefined behavior in how std::list stores its linked nodes. 28*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 29*0fca6ea1SDimitry Andric // Fix undefined behavior in how __tree stores its end and parent nodes. 30*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 31*0fca6ea1SDimitry Andric // Fix undefined behavior in how __hash_table stores its pointer types. 32*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 33*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 34*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 35*0fca6ea1SDimitry Andric // Override the default return value of exception::what() for bad_function_call::what() 36*0fca6ea1SDimitry Andric // with a string that is specific to bad_function_call (see http://wg21.link/LWG2233). 37*0fca6ea1SDimitry Andric // This is an ABI break on platforms that sign and authenticate vtable function pointers 38*0fca6ea1SDimitry Andric // because it changes the mangling of the virtual function located in the vtable, which 39*0fca6ea1SDimitry Andric // changes how it gets signed. 40*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 41*0fca6ea1SDimitry Andric // Enable optimized version of __do_get_(un)signed which avoids redundant copies. 42*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 43*0fca6ea1SDimitry Andric // Give reverse_iterator<T> one data member of type T, not two. 44*0fca6ea1SDimitry Andric // Also, in C++17 and later, don't derive iterator types from std::iterator. 45*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_NO_ITERATOR_BASES 46*0fca6ea1SDimitry Andric // Use the smallest possible integer type to represent the index of the variant. 47*0fca6ea1SDimitry Andric // Previously libc++ used "unsigned int" exclusively. 48*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 49*0fca6ea1SDimitry Andric // Unstable attempt to provide a more optimized std::function 50*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_OPTIMIZED_FUNCTION 51*0fca6ea1SDimitry Andric // All the regex constants must be distinct and nonzero. 52*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 53*0fca6ea1SDimitry Andric // Re-worked external template instantiations for std::string with a focus on 54*0fca6ea1SDimitry Andric // performance and fast-path inlining. 55*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 56*0fca6ea1SDimitry Andric // Enable clang::trivial_abi on std::unique_ptr. 57*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 58*0fca6ea1SDimitry Andric // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 59*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 60*0fca6ea1SDimitry Andric // std::random_device holds some state when it uses an implementation that gets 61*0fca6ea1SDimitry Andric // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 62*0fca6ea1SDimitry Andric // implementation to another one on a platform that has already shipped 63*0fca6ea1SDimitry Andric // std::random_device, one needs to retain the same object layout to remain ABI 64*0fca6ea1SDimitry Andric // compatible. This switch removes these workarounds for platforms that don't care 65*0fca6ea1SDimitry Andric // about ABI compatibility. 66*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 67*0fca6ea1SDimitry Andric // Don't export the legacy __basic_string_common class and its methods from the built library. 68*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 69*0fca6ea1SDimitry Andric // Don't export the legacy __vector_base_common class and its methods from the built library. 70*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 71*0fca6ea1SDimitry Andric // According to the Standard, `bitset::operator[] const` returns bool 72*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 73*0fca6ea1SDimitry Andric // Fix the implementation of CityHash used for std::hash<fundamental-type>. 74*0fca6ea1SDimitry Andric // This is an ABI break because `std::hash` will return a different result, 75*0fca6ea1SDimitry Andric // which means that hashing the same object in translation units built against 76*0fca6ea1SDimitry Andric // different versions of libc++ can return inconsistent results. This is especially 77*0fca6ea1SDimitry Andric // tricky since std::hash is used in the implementation of unordered containers. 78*0fca6ea1SDimitry Andric // 79*0fca6ea1SDimitry Andric // The incorrect implementation of CityHash has the problem that it drops some 80*0fca6ea1SDimitry Andric // bits on the floor. 81*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION 82*0fca6ea1SDimitry Andric // Remove the base 10 implementation of std::to_chars from the dylib. 83*0fca6ea1SDimitry Andric // The implementation moved to the header, but we still export the symbols from 84*0fca6ea1SDimitry Andric // the dylib for backwards compatibility. 85*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 86*0fca6ea1SDimitry Andric // Define std::array/std::string_view iterators to be __wrap_iters instead of raw 87*0fca6ea1SDimitry Andric // pointers, which prevents people from relying on a non-portable implementation 88*0fca6ea1SDimitry Andric // detail. This is especially useful because enabling bounded iterators hardening 89*0fca6ea1SDimitry Andric // requires code not to make these assumptions. 90*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY 91*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW 92*0fca6ea1SDimitry Andric // Dont' add an inline namespace for `std::filesystem` 93*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE 94*0fca6ea1SDimitry Andric // std::basic_ios uses WEOF to indicate that the fill value is 95*0fca6ea1SDimitry Andric // uninitialized. However, on platforms where the size of char_type is 96*0fca6ea1SDimitry Andric // equal to or greater than the size of int_type and char_type is unsigned, 97*0fca6ea1SDimitry Andric // std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF 98*0fca6ea1SDimitry Andric // and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill 99*0fca6ea1SDimitry Andric // value has been initialized using a separate boolean, which changes the ABI. 100*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE 101*0fca6ea1SDimitry Andric // Make a std::pair of trivially copyable types trivially copyable. 102*0fca6ea1SDimitry Andric // While this technically doesn't change the layout of pair itself, other types may decide to programatically change 103*0fca6ea1SDimitry Andric // their representation based on whether something is trivially copyable. 104*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR 105*0fca6ea1SDimitry Andric #elif _LIBCPP_ABI_VERSION == 1 106*0fca6ea1SDimitry Andric # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 107*0fca6ea1SDimitry Andric // Enable compiling copies of now inline methods into the dylib to support 108*0fca6ea1SDimitry Andric // applications compiled against older libraries. This is unnecessary with 109*0fca6ea1SDimitry Andric // COFF dllexport semantics, since dllexport forces a non-inline definition 110*0fca6ea1SDimitry Andric // of inline functions to be emitted anyway. Our own non-inline copy would 111*0fca6ea1SDimitry Andric // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 112*0fca6ea1SDimitry Andric // the linker will take issue with the symbols in the shared object if the 113*0fca6ea1SDimitry Andric // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 114*0fca6ea1SDimitry Andric // so disable it. 115*0fca6ea1SDimitry Andric # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 116*0fca6ea1SDimitry Andric # endif 117*0fca6ea1SDimitry Andric // Feature macros for disabling pre ABI v1 features. All of these options 118*0fca6ea1SDimitry Andric // are deprecated. 119*0fca6ea1SDimitry Andric # if defined(__FreeBSD__) 120*0fca6ea1SDimitry Andric # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 121*0fca6ea1SDimitry Andric # endif 122*0fca6ea1SDimitry Andric #endif 123*0fca6ea1SDimitry Andric 124*0fca6ea1SDimitry Andric // We had some bugs where we use [[no_unique_address]] together with construct_at, 125*0fca6ea1SDimitry Andric // which causes UB as the call on construct_at could write to overlapping subobjects 126*0fca6ea1SDimitry Andric // 127*0fca6ea1SDimitry Andric // https://github.com/llvm/llvm-project/issues/70506 128*0fca6ea1SDimitry Andric // https://github.com/llvm/llvm-project/issues/70494 129*0fca6ea1SDimitry Andric // 130*0fca6ea1SDimitry Andric // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. 131*0fca6ea1SDimitry Andric // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. 132*0fca6ea1SDimitry Andric #define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) 133*0fca6ea1SDimitry Andric 134*0fca6ea1SDimitry Andric // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's 135*0fca6ea1SDimitry Andric // within the bounds of the original container and asserts it on every dereference. 136*0fca6ea1SDimitry Andric // 137*0fca6ea1SDimitry Andric // ABI impact: changes the iterator type of the relevant containers. 138*0fca6ea1SDimitry Andric // 139*0fca6ea1SDimitry Andric // Supported containers: 140*0fca6ea1SDimitry Andric // - `span`; 141*0fca6ea1SDimitry Andric // - `string_view`. 142*0fca6ea1SDimitry Andric // #define _LIBCPP_ABI_BOUNDED_ITERATORS 143*0fca6ea1SDimitry Andric 144*0fca6ea1SDimitry Andric // Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds 145*0fca6ea1SDimitry Andric // of the original container and asserts it on every dereference and when performing iterator arithmetics. 146*0fca6ea1SDimitry Andric // 147*0fca6ea1SDimitry Andric // ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`. 148*0fca6ea1SDimitry Andric // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING 149*0fca6ea1SDimitry Andric 150*0fca6ea1SDimitry Andric // Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the 151*0fca6ea1SDimitry Andric // original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't 152*0fca6ea1SDimitry Andric // yet affect `vector<bool>`. 153*0fca6ea1SDimitry Andric // 154*0fca6ea1SDimitry Andric // ABI impact: changes the iterator type of `vector` (except `vector<bool>`). 155*0fca6ea1SDimitry Andric // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR 156*0fca6ea1SDimitry Andric 157*0fca6ea1SDimitry Andric #if defined(_LIBCPP_COMPILER_CLANG_BASED) 158*0fca6ea1SDimitry Andric # if defined(__APPLE__) 159*0fca6ea1SDimitry Andric # if defined(__i386__) || defined(__x86_64__) 160*0fca6ea1SDimitry Andric // use old string layout on x86_64 and i386 161*0fca6ea1SDimitry Andric # elif defined(__arm__) 162*0fca6ea1SDimitry Andric // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs 163*0fca6ea1SDimitry Andric # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2 164*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 165*0fca6ea1SDimitry Andric # endif 166*0fca6ea1SDimitry Andric # else 167*0fca6ea1SDimitry Andric # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 168*0fca6ea1SDimitry Andric # endif 169*0fca6ea1SDimitry Andric # endif 170*0fca6ea1SDimitry Andric #endif 171*0fca6ea1SDimitry Andric 172*0fca6ea1SDimitry Andric #endif // _LIBCPP___CONFIGURATION_ABI_H 173