Skip to content

Fix for -pthread + -sRELOCATABLE #22110

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

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jun 18, 2024

Fixes: #22108

@sbc100 sbc100 requested review from kripken and dschuff June 18, 2024 19:19
@dschuff
Copy link
Member

dschuff commented Jun 18, 2024

Why doesn't this function actually need to work?

// RELOCATABLE is used without MAIN_MODULE. This is because the call
// site in pthread_create.c is not able to distinguish between these
// two cases.
_emscripten_thread_exit_joinable: (thread) => {},
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should error if actually called? I assume it would be invalid to do so?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it can be called on pthread exit.. in any PIC build. The prolbem is that we only have one single PIC flavor of libc and so we can't distinguish between -sRELOCATABLE and -sMAIN_MODULE in the native code.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 19, 2024

The function is only used to keep track of shared library loading (i.e. when MAIN_MODULE is defined).

The problem is that the native code that calls this function cannot distinguish between MAIN_MODULE and RELOCATABLE since we only build just one PIC flavor of libc.. not one for MAIN_MODULE and another for RELOCATABLE.

@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 19, 2024

See

#ifdef EMSCRIPTEN_DYNAMIC_LINKING
// When dynamic linking is enabled we need to keep track of zombie threads
_emscripten_thread_exit_joinable(self);
#endif

@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 19, 2024

I would really love to completely get rid of the "RELOCATABLE but not MAIN_MODULE" build mode one day.. because I don't think it has any/many valid uses.

@sbc100 sbc100 merged commit 77448a9 into emscripten-core:main Jun 20, 2024
29 checks passed
@sbc100 sbc100 deleted the fix_relocatable branch June 20, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to add _emscripten_thread_exit_joinable to EXPORTED_FUNCTIONS
3 participants