Make loader.cpp
compatible with glibc <= 2.17
#173
Closed
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.
In the current
loader.cpp
, the symbol__cxa_thread_atexit_impl
is introduced byextern "C"
: https://github.com/pytorch/multipy/blob/main/multipy/runtime/loader.cpp#L247-L248However, this symbol is exposed in libc.so.6 only when glibc version is >=2.18. With old glibc, compile fails.
In this PR, the problem is solved by replacing
__cxa_thread_atexit_impl
with__cxxabiv1::__cxa_thread_atexit
.The function
__cxxabiv1::__cxa_thread_atexit
is a simple wrapper of__cxa_thread_atexit_impl
and does exactly the same job: https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/libsupc%2B%2B/atexit_thread.cc#L41-L47. The function is declared in thecxxabi.h
. So we can use it byinclude <cxxabi.h>
and the code no longer depends on glibc version.