Skip to content

Make loader.cpp compatible with glibc <= 2.17 #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

JiayiFeng
Copy link

In the current loader.cpp, the symbol __cxa_thread_atexit_impl is introduced by extern "C": https://github.com/pytorch/multipy/blob/main/multipy/runtime/loader.cpp#L247-L248

However, 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 the cxxabi.h. So we can use it by include <cxxabi.h> and the code no longer depends on glibc version.

@facebook-github-bot
Copy link
Contributor

Hi @JiayiFeng!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #173 (902b3d7) into main (5562304) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #173   +/-   ##
=======================================
  Coverage   89.06%   89.06%           
=======================================
  Files          67       67           
  Lines        3888     3888           
=======================================
  Hits         3463     3463           
  Misses        425      425           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@d4l3k d4l3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch -- was looking for a replacement for that but missed the cxxabi.h file

We do need to have the CLA signed before we can merge -- otherwise the code looks good

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 16, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@d4l3k has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants