[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 13 11:35:34 PDT 2018


ldionne updated this revision to Diff 160414.
ldionne added a comment.

Update documentation for _LIBCPP_HIDE_FROM_ABI


Repository:
  rCXX libc++

https://reviews.llvm.org/D50652

Files:
  libcxx/docs/DesignDocs/VisibilityMacros.rst
  libcxx/include/__config


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
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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50652.160414.patch
Type: text/x-patch
Size: 2503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180813/52100283/attachment.bin>


More information about the cfe-commits mailing list