(Yet another) Optimization for TLS access #17220
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This time for C code on Linux. (
I've probably hit a linker bug on aarch64.....Found workaround)ifunc
) to set the address of a symbol at runtime.weak
symbol to detect (inifunc
) whether the static version ofTLS is available.
This is actually pretty much the original plan for #14083 (i.e. resolve the symbol to the better version at linker level) before realizing that undefined symbol in shared library is not really well supported on all platforms, and weak symbol doesn't do what most people (me included) would naively assume ;-p....
The use of
ifunc
in this PR is not particularly reliably in that the weak symbol check might return missing of the static version when it actually exist if the linker does the relocation in the wrong order (ld tries to do it in the right order though and I haven't seen any issue like that on the platforms I've tested). In such case, this should just fallback to the same code with the one on current master.This is the last bit of optimization I can imagine for linux (apart from starting to pass it around more). The actual performance gain is a hard to measure.