https://bugs.llvm.org/show_bug.cgi?id=38138

            Bug ID: 38138
           Summary: libc++'s ABI depends on optimization flags
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: ldio...@apple.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

It appears that the symbols exported by libc++.dylib differ depending on
optimization flags. In debug mode, the following symbols are exported, and they
are not in Release mode:

```
$ ./libcxx/utils/sym_diff.py --only-stdlib-symbols --strict
libcxx/lib/abi/x86_64-apple-darwin.abilist --names-only $(find . -name
libc++.1.dylib)
Symbol added:
__ZNSt3__110__find_endIPFbccEPKcS4_EET0_S5_S5_T1_S6_T_NS_26random_access_iterator_tagES8_
Symbol added:
__ZNSt3__110__find_endIPFbwwEPKwS4_EET0_S5_S5_T1_S6_T_NS_26random_access_iterator_tagES8_
Symbol added: __ZNSt3__111unique_lockINS_5mutexEE6unlockEv
Symbol added: __ZNSt3__112__rotate_gcdINS_11__wrap_iterIPcEEEET_S4_S4_S4_
Symbol added: __ZNSt3__112__rotate_gcdINS_11__wrap_iterIPwEEEET_S4_S4_S4_
Symbol added: __ZNSt3__113__lower_boundIRNS_6__lessIjmEEPKjmEET0_S6_S6_RKT1_T_
Symbol added: __ZNSt3__113__rotate_leftINS_11__wrap_iterIPcEEEET_S4_S4_
Symbol added: __ZNSt3__113__rotate_leftINS_11__wrap_iterIPwEEEET_S4_S4_
Symbol added: __ZNSt3__114__ptr_in_rangeIcEEbPKT_S3_S3_
Symbol added: __ZNSt3__114__ptr_in_rangeIwEEbPKT_S3_S3_
Symbol added: __ZNSt3__114__rotate_rightINS_11__wrap_iterIPcEEEET_S4_S4_
Symbol added: __ZNSt3__114__rotate_rightINS_11__wrap_iterIPwEEEET_S4_S4_
Symbol added: __ZNSt3__118__find_first_of_ceIPKcS2_PFbccEEET_S5_S5_T0_S6_T1_
Symbol added: __ZNSt3__118__find_first_of_ceIPKwS2_PFbwwEEET_S5_S5_T0_S6_T1_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIaaEEPaEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIccEEPcEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIddEEPdEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIeeEEPeEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIffEEPfEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIhhEEPhEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIiiEEPiEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIjjEEPjEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIllEEPlEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessImmEEPmEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIssEEPsEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIttEEPtEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIwwEEPwEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIxxEEPxEEvT0_S5_T_
Symbol added: __ZNSt3__118__insertion_sort_3IRNS_6__lessIyyEEPyEEvT0_S5_T_
Symbol added:
__ZNSt3__121__thread_specific_ptrINS_15__thread_structEE11set_pointerEPS1_
Symbol added:
__ZNSt3__123mersenne_twister_engineIjLm32ELm624ELm397ELm31ELj2567483615ELm11ELj4294967295ELm7ELj2636928640ELm15ELj4022730752ELm18ELj1812433253EE4seedEj
Symbol added:
__ZNSt3__123mersenne_twister_engineIjLm32ELm624ELm397ELm31ELj2567483615ELm11ELj4294967295ELm7ELj2636928640ELm15ELj4022730752ELm18ELj1812433253EEclEv
Symbol added: __ZNSt3__125__num_get_signed_integralIlEET_PKcS3_Rji
Symbol added: __ZNSt3__125__num_get_signed_integralIxEET_PKcS3_Rji
Symbol added: __ZNSt3__127__num_get_unsigned_integralIjEET_PKcS3_Rji
Symbol added: __ZNSt3__127__num_get_unsigned_integralImEET_PKcS3_Rji
Symbol added: __ZNSt3__127__num_get_unsigned_integralItEET_PKcS3_Rji
Symbol added: __ZNSt3__127__num_get_unsigned_integralIyEET_PKcS3_Rji
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIaaEEPaEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIccEEPcEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIddEEPdEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIeeEEPeEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIffEEPfEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIhhEEPhEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIiiEEPiEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIjjEEPjEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIllEEPlEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessImmEEPmEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIssEEPsEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIttEEPtEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIwwEEPwEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIxxEEPxEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort3IRNS_6__lessIyyEEPyEEjT0_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIeeEEPeEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort4IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIaaEEPaEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIccEEPcEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIddEEPdEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIffEEPfEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIhhEEPhEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIiiEEPiEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIjjEEPjEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIllEEPlEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessImmEEPmEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIssEEPsEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIttEEPtEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__17__sort5IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_S5_T_
Symbol added: __ZNSt3__18valarrayImE7__clearEv
Symbol added:
__ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EERKS9_PKS6_
Symbol added:
__ZSt18make_exception_ptrINSt3__112future_errorEESt13exception_ptrT_
```

I believe the reason is that those functions are not marked with the proper
visibility attributes. Those are pretty much all implementation details of
user-facing functionality (for example
`__ZNSt3__118__insertion_sort_3IRNS_6__lessIyyEEPyEEvT0_S5_T_` is used inside
`std::sort`). At least some of those symbols are used inside functions that are
themselves declared as extern templates, and hence part of the ABI. The problem
seems to be that since they are not marked to be internal, they are included in
the dylib when we explicitly instantiate them, unless they are inlined
completely (which doesn't happen without optimizations).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to