[PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 15 09:25:10 PDT 2018
dexonsmith added inline comments.
================
Comment at: libcxx/include/__config:798-804
#ifndef _LIBCPP_HIDE_FROM_ABI
-# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+# ifdef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+# else
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
+# endif
#endif
----------------
This doesn't leave a user-friendly way of opting out of internal linkage if a vendor decides to turn it on by default. I suggest adding a layer of indirection:
```
// Elsewhere.
#cmakedefine _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE_BY_DEFAULT
// Here.
#ifndef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
# ifdef _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE_BY_DEFAULT
# define _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE 1
# else
# define _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE 0
# endif
#endif
#ifndef _LIBCPP_HIDE_FROM_ABI
# if _LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
# else
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE
# endif
#endif
```
Then users can set the behaviour with `-D_LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE=1` or `-D_LIBCPP_ABI_HIDDEN_USE_INTERNAL_LINKAGE=0`, overriding the vendor default.
Repository:
rCXX libc++
https://reviews.llvm.org/D50652
More information about the cfe-commits
mailing list