|
|
|||
File indexing completed on 2026-05-03 08:13:17
0001 // -*- C++ -*- 0002 //===----------------------------------------------------------------------===// 0003 // 0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0005 // See https://llvm.org/LICENSE.txt for license information. 0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0007 // 0008 //===----------------------------------------------------------------------===// 0009 0010 #ifndef _LIBCPP___CONFIGURATION_ABI_H 0011 #define _LIBCPP___CONFIGURATION_ABI_H 0012 0013 #include <__config_site> 0014 #include <__configuration/compiler.h> 0015 #include <__configuration/platform.h> 0016 0017 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 0018 # pragma GCC system_header 0019 #endif 0020 0021 // FIXME: ABI detection should be done via compiler builtin macros. This 0022 // is just a placeholder until Clang implements such macros. For now assume 0023 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI, 0024 // and allow the user to explicitly specify the ABI to handle cases where this 0025 // heuristic falls short. 0026 #if _LIBCPP_ABI_FORCE_ITANIUM && _LIBCPP_ABI_FORCE_MICROSOFT 0027 # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be true" 0028 #elif _LIBCPP_ABI_FORCE_ITANIUM 0029 # define _LIBCPP_ABI_ITANIUM 0030 #elif _LIBCPP_ABI_FORCE_MICROSOFT 0031 # define _LIBCPP_ABI_MICROSOFT 0032 #else 0033 # if defined(_WIN32) && defined(_MSC_VER) 0034 # define _LIBCPP_ABI_MICROSOFT 0035 # else 0036 # define _LIBCPP_ABI_ITANIUM 0037 # endif 0038 #endif 0039 0040 #if _LIBCPP_ABI_VERSION >= 2 0041 // Change short string representation so that string data starts at offset 0, 0042 // improving its alignment in some cases. 0043 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 0044 // Fix deque iterator type in order to support incomplete types. 0045 # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE 0046 // Fix undefined behavior in how std::list stores its linked nodes. 0047 # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB 0048 // Fix undefined behavior in how __tree stores its end and parent nodes. 0049 # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB 0050 // Fix undefined behavior in how __hash_table stores its pointer types. 0051 # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB 0052 # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB 0053 # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE 0054 // Override the default return value of exception::what() for bad_function_call::what() 0055 // with a string that is specific to bad_function_call (see http://wg21.link/LWG2233). 0056 // This is an ABI break on platforms that sign and authenticate vtable function pointers 0057 // because it changes the mangling of the virtual function located in the vtable, which 0058 // changes how it gets signed. 0059 # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE 0060 // Enable optimized version of __do_get_(un)signed which avoids redundant copies. 0061 # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET 0062 // Give reverse_iterator<T> one data member of type T, not two. 0063 // Also, in C++17 and later, don't derive iterator types from std::iterator. 0064 # define _LIBCPP_ABI_NO_ITERATOR_BASES 0065 // Use the smallest possible integer type to represent the index of the variant. 0066 // Previously libc++ used "unsigned int" exclusively. 0067 # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION 0068 // Unstable attempt to provide a more optimized std::function 0069 # define _LIBCPP_ABI_OPTIMIZED_FUNCTION 0070 // All the regex constants must be distinct and nonzero. 0071 # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO 0072 // Re-worked external template instantiations for std::string with a focus on 0073 // performance and fast-path inlining. 0074 # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION 0075 // Enable clang::trivial_abi on std::unique_ptr. 0076 # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI 0077 // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr 0078 # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI 0079 // std::random_device holds some state when it uses an implementation that gets 0080 // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this 0081 // implementation to another one on a platform that has already shipped 0082 // std::random_device, one needs to retain the same object layout to remain ABI 0083 // compatible. This switch removes these workarounds for platforms that don't care 0084 // about ABI compatibility. 0085 # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT 0086 // Don't export the legacy __basic_string_common class and its methods from the built library. 0087 # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON 0088 // Don't export the legacy __vector_base_common class and its methods from the built library. 0089 # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON 0090 // According to the Standard, `bitset::operator[] const` returns bool 0091 # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 0092 // Fix the implementation of CityHash used for std::hash<fundamental-type>. 0093 // This is an ABI break because `std::hash` will return a different result, 0094 // which means that hashing the same object in translation units built against 0095 // different versions of libc++ can return inconsistent results. This is especially 0096 // tricky since std::hash is used in the implementation of unordered containers. 0097 // 0098 // The incorrect implementation of CityHash has the problem that it drops some 0099 // bits on the floor. 0100 # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION 0101 // Remove the base 10 implementation of std::to_chars from the dylib. 0102 // The implementation moved to the header, but we still export the symbols from 0103 // the dylib for backwards compatibility. 0104 # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 0105 // Define std::array/std::string_view iterators to be __wrap_iters instead of raw 0106 // pointers, which prevents people from relying on a non-portable implementation 0107 // detail. This is especially useful because enabling bounded iterators hardening 0108 // requires code not to make these assumptions. 0109 # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY 0110 # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW 0111 // Dont' add an inline namespace for `std::filesystem` 0112 # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE 0113 // std::basic_ios uses WEOF to indicate that the fill value is 0114 // uninitialized. However, on platforms where the size of char_type is 0115 // equal to or greater than the size of int_type and char_type is unsigned, 0116 // std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF 0117 // and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill 0118 // value has been initialized using a separate boolean, which changes the ABI. 0119 # define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE 0120 // Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an 0121 // empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons 0122 // we had to add artificial padding in a few places. 0123 // 0124 // This setting disables the addition of such artificial padding, leading to a more optimal 0125 // representation for several types. 0126 # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING 0127 #elif _LIBCPP_ABI_VERSION == 1 0128 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) 0129 // Enable compiling copies of now inline methods into the dylib to support 0130 // applications compiled against older libraries. This is unnecessary with 0131 // COFF dllexport semantics, since dllexport forces a non-inline definition 0132 // of inline functions to be emitted anyway. Our own non-inline copy would 0133 // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, 0134 // the linker will take issue with the symbols in the shared object if the 0135 // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), 0136 // so disable it. 0137 # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS 0138 # endif 0139 // Feature macros for disabling pre ABI v1 features. All of these options 0140 // are deprecated. 0141 # if defined(__FreeBSD__) && __FreeBSD__ < 14 0142 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR 0143 # endif 0144 #endif 0145 0146 // We had some bugs where we use [[no_unique_address]] together with construct_at, 0147 // which causes UB as the call on construct_at could write to overlapping subobjects 0148 // 0149 // https://github.com/llvm/llvm-project/issues/70506 0150 // https://github.com/llvm/llvm-project/issues/70494 0151 // 0152 // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. 0153 // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. 0154 #define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) 0155 0156 // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's 0157 // within the bounds of the original container and asserts it on every dereference. 0158 // 0159 // ABI impact: changes the iterator type of the relevant containers. 0160 // 0161 // Supported containers: 0162 // - `span`; 0163 // - `string_view`. 0164 // #define _LIBCPP_ABI_BOUNDED_ITERATORS 0165 0166 // Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds 0167 // of the original container and asserts it on every dereference and when performing iterator arithmetics. 0168 // 0169 // ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`. 0170 // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING 0171 0172 // Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the 0173 // original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't 0174 // yet affect `vector<bool>`. 0175 // 0176 // ABI impact: changes the iterator type of `vector` (except `vector<bool>`). 0177 // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR 0178 0179 // Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the 0180 // container and asserts it on every dereference and when performing iterator arithmetic. 0181 // 0182 // ABI impact: changes the iterator type of `array`, its size and its layout. 0183 // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY 0184 0185 // [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work. 0186 #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING) 0187 # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING 0188 #endif 0189 0190 // Tracks the bounds of the array owned by std::unique_ptr<T[]>, allowing it to trap when accessed out-of-bounds. 0191 // Note that limited bounds checking is also available outside of this ABI configuration, but only some categories 0192 // of types can be checked. 0193 // 0194 // ABI impact: This causes the layout of std::unique_ptr<T[]> to change and its size to increase. 0195 // This also affects the representation of a few library types that use std::unique_ptr 0196 // internally, such as the unordered containers. 0197 // #define _LIBCPP_ABI_BOUNDED_UNIQUE_PTR 0198 0199 #if defined(_LIBCPP_COMPILER_CLANG_BASED) 0200 # if defined(__APPLE__) 0201 # if defined(__i386__) || defined(__x86_64__) 0202 // use old string layout on x86_64 and i386 0203 # elif defined(__arm__) 0204 // use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs 0205 # if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2 0206 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 0207 # endif 0208 # else 0209 # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 0210 # endif 0211 # endif 0212 #endif 0213 0214 #endif // _LIBCPP___CONFIGURATION_ABI_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|