[libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

Summary:
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?



Reviewers: mclow.lists, emaste, dexonsmith, joker-eph-DISABLED, jroelofs, danalbert, mehdi_amini, compnerd, dim

Subscribers: beanz, mgorny, cfe-commits, modocache

Differential Revision: https://reviews.llvm.org/D25593

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@285101 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-10-25 19:43:44 +00:00
parent 6979a42e44
commit 8330b1ec02
3 changed files with 40 additions and 19 deletions

View File

@@ -342,6 +342,11 @@ endif()
# 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)

View File

@@ -16,6 +16,41 @@ New entries should be added directly below the "Version" header.
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. For this reason
removing these symbols is safe because every "linkage unit" which uses these
functions will contain their own definition.
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
* r284206 - Implement C++17 aligned allocation in <new>
x86_64-linux-gnu

View File

@@ -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'}