Use attribute((internal_linkage)) instead of always_inline and visibility("hidden") when it is available.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Note, this breaks tuple_cat.pass.cpp test.
With -O0, replacing always_inline with internal_linkage results in less optimization being done (namely, no inlining happens). This ends up exposing
https://llvm.org/bugs/show_bug.cgi?id=23256
which is fixed by
http://reviews.llvm.org/D12502
The same failure can be reproduced in the current ToT libc++ by running this test with -O2.
This change depends on D12502.
include/__config | ||
---|---|---|
237 | Use __internal_linkage__ here. Users are allowed to #define internal_linkage before including this header. (x4) |
Woops, I meant the tuple patch but I see the other comment now. I'm curious as to how inlininging ends up affecting which overload's SFINAE are evaluated.
Drive by comment: Is the change from __attribute__((__visibility__("hidden"), __always_inline__)) to __attribute__((__internal_linkage__)) ABI compatible?
As I understand, in that test we pick a default(?) constructor instead of a move(?) constructor, and end up reading uninitialized memory. Then any code change can affect the test result. Like adding -O2 does, for example.
Drive by comment: Is the change from __attribute__((__visibility__("hidden"), __always_inline__)) to __attribute__((__internal_linkage__)) ABI compatible?
I think so. I'll verify tomorrow.
Depends on D15432.
Depends on D15433.
With all that change, the switch to internal_linkage attribute removes 3 symbols from the libc++ export table, all in basic_string:
insert(..., InputIterator
insert(..., ForwardIterator
replace(..., InputIterator
These are template methods of a template class. They are instantiated only in functions/methods that are marked with LIBCPP_INLINE_VISIBILITY; normally they are exported as linkonce_odr; after the internal_linkage switch they are not instantiated at all because their callers are never evaluated.
Do you think this is an ABI break?
With http://reviews.llvm.org/D15434, there is no difference in libc++ export list with the switch to internal_linkage.
Sorry about the long delay in reviewing this. @eugenis Are you still able/willing to proceed with this?
Yes, I'd like to try.
I think this is blocked on the changes that move visibility attributes to the first declaration, right?
Also, re: cfi-commits thread for r255177, it appears that on Mac we can neither hide nor expose existing methods (i.e. if something was hidden, it can not be exported and vice versa; basically, the set of exports must stay exactly the same).
I think this should be closed since the work we did on internal_linkage in 2018. @eugenis
Use __internal_linkage__ here. Users are allowed to #define internal_linkage before including this header. (x4)