WebAssembly / WebAssembly/wabt

wasm-interp --wasi --enable-threads can't handle emcc's pthread support

Open
#1,645 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

I suspect this is a known issue, but recording it here:

emcc will allow you to compile with -pthread, and generate nice wrapper callers for POSIX pthread calls. I'd expect that invoking with --wasi --enable-threads would allow wasm code of this form to load and run, but it fails at load time with wasi error: unknown module import: env

Looking at the wasm2wat output for my code I see only two symbols in env:

(import "env" "pthread_create" (func $pthread_create (type 7)))
(import "env" "pthread_join" (func $pthread_join (type 1)))

I presume this is a known-ish issue due to the current incomplete status of wasi support? Just wanted to note it down here for reference (and in case someone else encounters it).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using an emcc-generated module with --wasi --enable-threads, then inspect the wasm2wat output and the env imports for pthread_create and pthread_join. The issue does not name source files or tests; done means the module can load and run without the wasi error: unknown module import: env failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
operating-systems, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.