Skip to content

Use C11 _Thread_local for current locale. NFC#26486

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:tls_locale
Mar 18, 2026
Merged

Use C11 _Thread_local for current locale. NFC#26486
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:tls_locale

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 18, 2026

We already do a similar thing for __errno_location.

This means that locale usage no longer depends on pthread_self, which means it works correctly in Wasm Workers.

I guess the codesize savings here come from the fact that the TLS data doesn't need to initialized programmatically anymore.

@dschuff
Copy link
Member

dschuff commented Mar 18, 2026

This looks reasonable, but what's the endgame? How many of these are there going to be?

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 18, 2026

My goal is to make is to remove __pthread_self() completely from the wasm workers build. Currently its still used (erroneously) in a couple of places. Not to many luckily.

I think for these two struct member it makes a lot of sense to use normal TLS here, espcially since its a code size saving!

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 18, 2026

The end game PR is here #26487.. but its depends on this one as well as #26471

We already do a similar thing for `__errno_location`.

This means that locale usage no longer depends on pthread_self, which
means it works correctly in Wasm Workers.

I guess the codesize savings here come from the fact that the TLS data
doesn't need to initialized programmatically anymore.
@sbc100 sbc100 merged commit daccb8f into emscripten-core:main Mar 18, 2026
18 of 38 checks passed
@sbc100 sbc100 deleted the tls_locale branch March 18, 2026 23:19
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 19, 2026
This test was being very naughty indeed.  The test was added back in
2017 in emscripten-core#4813, although its hard to say what exactly its purpose is.
sbc100 added a commit that referenced this pull request Mar 19, 2026
This test was being very naughty indeed. The test was added back in 2017
in #4813, although its hard to say what exactly its purpose is.
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