[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:25:51 PDT 2018


ldionne created this revision.
ldionne added reviewers: EricWF, mclow.lists, dexonsmith, hans, rnk.
Herald added subscribers: cfe-commits, christof.

This led to symbol size problems in Chromium, and we expect this may be
the case in other projects built in debug mode too. Instead, unless users
explicitly ask for internal_linkage, we use always_inline like we used to.

In the future, when we have a solution that allows us to drop always_inline
without falling back on internal_linkage, we can replace always_inline by
that.

Note that this commit introduces a change in contract for existing libc++
users: by default, libc++ used to guarantee that TUs built with different
versions of libc++ could be linked together. With the introduction of the
_LIBCPP_HIDE_FROM_ABI_PER_TU macro, the default behavior is that TUs built
with different libc++ versions are not guaranteed to link. This is a change
in contract but not a change in behavior, since the current implementation
still allows linking TUs built with different libc++ versions together.


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
@@ -61,6 +61,18 @@
   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 are local to each
+  translation unit. 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.
+
+  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.160407.patch
Type: text/x-patch
Size: 1801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180813/f63b5bb2/attachment-0001.bin>


More information about the cfe-commits mailing list