EricWF created this revision.
EricWF added reviewers: mclow.lists, emaste, dexonsmith, joker-eph, compnerd, 
jroelofs, danalbert, dim.
EricWF added a subscriber: cfe-commits.
Herald added subscribers: modocache, mgorny, beanz.

This patch turns on `-fvisibility-inlines-hidden` when building  the dylib. 
This is important so that libc++.dylib doesn't accidentally export 
inline-functions which are ODR used somewhere in the dylib.

On OS X this change has no effect on the current ABI of the dylib. 
Unfortunately on Linux there are already ~20 inline functions which are 
unintentionally exported by the dylib. Almost all of these are implicitly 
generated destructors. I believe removing these function definitions is safe 
because every "linkage unit" which uses these functions has its own definition, 
and therefore shouldn't be dependent on libc++.dylib to provide them.

Also could a FreeBSD maintainer comment on the ABI compatibility of this patch?


https://reviews.llvm.org/D25593

Files:
  CMakeLists.txt
  lib/abi/CHANGELOG.TXT
  lib/abi/x86_64-linux-gnu.abilist

Index: lib/abi/x86_64-linux-gnu.abilist
===================================================================
--- lib/abi/x86_64-linux-gnu.abilist
+++ lib/abi/x86_64-linux-gnu.abilist
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD2Ev'}
@@ -893,9 +891,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvEaSERKS1_'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__get_const_dbEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE'}
 {'type': 'OBJECT', 'name': '_ZNSt3__114__num_get_base5__srcE', 'size': 33}
@@ -943,12 +938,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb1EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__get_classnameEPKcb'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIdEET_PKcS3_Rj'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIeEET_PKcS3_Rj'}
@@ -1080,9 +1069,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state4waitEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9__executeEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9set_valueEv'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED2Ev'}
@@ -1122,8 +1108,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutex8try_lockEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base11lock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base13unlock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base15try_lock_sharedEv'}
@@ -1144,9 +1128,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__119__thread_local_dataEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119declare_no_pointersEPcm'}
 {'type': 'OBJECT', 'name': '_ZNSt3__119piecewise_constructE', 'size': 1}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__get_collation_nameEPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__throw_system_errorEiPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE16__at_thread_exitEPv'}
Index: lib/abi/CHANGELOG.TXT
===================================================================
--- lib/abi/CHANGELOG.TXT
+++ lib/abi/CHANGELOG.TXT
@@ -16,6 +16,37 @@
 Version 4.0
 -----------
 
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions.
+
+  x86_64-linux-gnu
+  ----------------
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IwED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD2Ev
+  SYMBOL REMOVED: _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+
+  x86_64-apple-darwin16.0
+  -----------------------
+  No Changes - inline symbols are already hidden
+
 * r283980 - Implement C++17 <optional>
 
   x86_64-linux-gnu
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -337,6 +337,11 @@
 # headers
 add_compile_flags_if_supported(-nostdinc++)
 
+# Hide all inline function definitions which have not explicitly been marked
+# visible. This prevents new definitions for inline functions from appearing in
+# the dylib when get ODR used by another function.
+add_compile_flags_if_supported(-fvisibility-inlines-hidden)
+
 # Let the library headers know they are currently being used to build the
 # library.
 add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to