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

wasm2c: Fix WASM_RT_THREAD_LOCAL to check for __thread and add an error path #2488

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shravanrn
Copy link
Collaborator

wasm2c's thread_local needs two fixes

  1. WASM_RT_THREAD_LOCAL should use __thread compiler intrinsic where possible (gcc, clang, icc) to avoid making C11 a hard dependency to compile the wasm2c runtime.
  2. The WASM_RT_THREAD_LOCAL fallback when there is no thread_local implementation either from compiler intrinsics or C11 is to #define WASM_RT_THREAD_LOCAL, i.e., leave it empty. This is pretty unsafe, as this fallback would mean wasm2c generated code would have race conditions if two instances are run in separate threads. This PR adds an extra macro (WASM_RT_ASSUME_SINGLE_THREADED_APP) for users to declare their app is single threaded, at which point this fallback is allowed.

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.

1 participant