Skip to content
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

Fix __errno_location under wasm workers. NFC #22744

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 15, 2024

Previously the wasm workers build of __errno_location was using the
single threaded code path which doesn't use a thead local location.

In addition this change avoids the use of __EMSCRIPTEN_PTHREADS__ in
__errno_location.c which is helpful for unifying the shared memory
libc build. See #22735.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 15, 2024

@eyebrowsoffire

@sbc100 sbc100 requested a review from kripken October 15, 2024 17:32
@sbc100 sbc100 changed the title Avoid use of __EMSCRIPTEN_PTHREADS__ in __errno_location.c Avoid use of __EMSCRIPTEN_PTHREADS__ in __errno_location.c Oct 15, 2024
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 15, 2024

@eyebrowsoffire I'm running into the fact the -sSHARED_MEMORY builds don't link here.. :( I guess we need your change first?

system/lib/libc/musl/src/errno/__errno_location.c Outdated Show resolved Hide resolved
test/test_sockets.py Outdated Show resolved Hide resolved
@sbc100 sbc100 force-pushed the errno_location branch 2 times, most recently from 8180dba to 2559ddc Compare October 15, 2024 20:28
@sbc100 sbc100 changed the title Avoid use of __EMSCRIPTEN_PTHREADS__ in __errno_location.c Fix __errno_location under wasm workers. NFC Oct 15, 2024
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 15, 2024

Updated PR description and title to better reflect the purpose of this change.

@@ -742,7 +742,7 @@ def vary_on(cls):

@classmethod
def get_default_variation(cls, **kwargs):
return super().get_default_variation(is_mt=settings.PTHREADS, is_ww=settings.WASM_WORKERS and not settings.PTHREADS, **kwargs)
return super().get_default_variation(is_mt=settings.PTHREADS, is_ww=settings.SHARED_MEMORY and not settings.PTHREADS, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed in this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@eyebrowsoffire, is this maybe enough to resolve #22683

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason this is needed for this PR is because it makes __errno_location into a function that, in non-threads build, has TLS erased, making it incompatible with -sSHARED_MEMORY, which triggers the problem found in #22683. Basically it make the problem found in #22683 happen is way more cases, including simple hello world programs.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm otherwise

@sbc100 sbc100 force-pushed the errno_location branch 4 times, most recently from 5e6053c to 3ec754a Compare October 16, 2024 20:40
Previously the wasm workers build of `__errno_location` was using the
single threaded code path which doesn't use a thead local location.

In addition this change avoids the use of `__EMSCRIPTEN_PTHREADS__` in
`__errno_location.c` which is helpful for unifying the shared memory
libc build.  See emscripten-core#22735.
@sbc100 sbc100 enabled auto-merge (squash) October 16, 2024 21:26
@sbc100 sbc100 merged commit 814ec05 into emscripten-core:main Oct 16, 2024
28 checks passed
@sbc100 sbc100 deleted the errno_location branch October 16, 2024 21:55
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.

2 participants