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

Support for wasm32-wasip1-threads #1217

Closed
oligamiq opened this issue Sep 28, 2024 · 7 comments · Fixed by #1221
Closed

Support for wasm32-wasip1-threads #1217

oligamiq opened this issue Sep 28, 2024 · 7 comments · Fixed by #1221

Comments

@oligamiq
Copy link

The -pthread is required as a flag.
For -D_WASI_EMULATED_MMAN, it is not necessary yet because the Rust compiler does not support it!

@NobodyXu
Copy link
Collaborator

Sorry I didn't quite get you.

cc-rs only compiles the source code and produce an archive, it does not performing linking, so I don't think -pthread is needed

@oligamiq
Copy link
Author

When compiling C or C++ for wasm32-wasip1-threads, it is necessary to include the -pthreads flag. Otherwise, during linking, you will encounter an error such as:

note: wasm-ld: error: --shared-memory is disallowed by dlmalloc.o because it was not compiled with 'atomics' or 'bulk-memory' features.

@NobodyXu
Copy link
Collaborator

When compiling C or C++ for wasm32-wasip1-threads, it is necessary to include the -pthreads flag. Otherwise, during linking, you will encounter an error such as:

note: wasm-ld: error: --shared-memory is disallowed by dlmalloc.o because it was not compiled with 'atomics' or 'bulk-memory' features.

So -pthread needs to be provided when compiling objects, otherwise the linking will fail?

Hmmm I didn't know that -pthread flag has that effect during compilation.

@oligamiq
Copy link
Author

Yes

@NobodyXu
Copy link
Collaborator

In that case, we might want to special case for this target

@oligamiq
Copy link
Author

Small example:
https://github.com/oligamiq/small_example_pthread

Running the command cargo +nightly b --target wasm32-wasip1-threads fails.

However, when I replace rusqlite in Cargo.toml, it succeeds.
The only patch applied is for pthreads:
oligamiq/rusqlite@95bcbdf

@NobodyXu
Copy link
Collaborator

Thanks, I can reproduce this.

Will create a PR for it.

NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
NobodyXu added a commit that referenced this issue Sep 30, 2024
Signed-off-by: Jiahao XU <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants