Index: libcxx/docs/DesignDocs/VisibilityMacros.rst =================================================================== --- libcxx/docs/DesignDocs/VisibilityMacros.rst +++ libcxx/docs/DesignDocs/VisibilityMacros.rst @@ -42,9 +42,7 @@ **_LIBCPP_HIDE_FROM_ABI** Mark a function as not being part of the ABI of any final linked image that - uses it, and also as being internal to each TU that uses that function. In - other words, the address of a function marked with this attribute is not - guaranteed to be the same across translation units. + uses it. **_LIBCPP_HIDE_FROM_ABI_AFTER_V1** Mark a function as being hidden from the ABI (per `_LIBCPP_HIDE_FROM_ABI`) @@ -61,6 +59,21 @@ ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can use it to start removing symbols from the ABI after that stable version. +**_LIBCPP_HIDE_FROM_ABI_PER_TU** + This macro controls whether symbols hidden from the ABI with `_LIBCPP_HIDE_FROM_ABI` + are local to each translation unit in addition to being local to each final + linked image. When enabled, this means that translation units compiled + with different versions of libc++ can be linked together, since all non + ABI-facing functions are local to each translation unit. This allows static + archives built with different versions of libc++ to be linked together. This + also means that functions marked with `_LIBCPP_HIDE_FROM_ABI` are not guaranteed + to have the same address across translation unit boundaries. + + When the macro is not defined (the default), there is no guarantee that + translation units compiled with different versions of libc++ can interoperate. + However, this leads to code size improvements, since non ABI-facing functions + can be deduplicated across translation unit boundaries. + **_LIBCPP_TYPE_VIS** Mark a type's typeinfo, vtable and members as having default visibility. This attribute cannot be used on class templates. Index: libcxx/include/__config =================================================================== --- libcxx/include/__config +++ libcxx/include/__config @@ -796,7 +796,11 @@ #endif #ifndef _LIBCPP_HIDE_FROM_ABI -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE +# ifdef _LIBCPP_HIDE_FROM_ABI_PER_TU +# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE +# else +# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE +# endif #endif #ifdef _LIBCPP_BUILDING_LIBRARY