Skip to content

coop-threads: Pthread primitives change ABI when coop threading is enabled #823

Description

@alexcrichton

For wasm32-wasip3 the public ABI of the pthread_* primitives (e.g. mutex/condvar/rwlock/etc) currently change with -DENABLE_COOP_THREADS=ON. This'll make the bindings story for languages like Rust more difficult in the wasip3 world and is, I believe, ideally something we should avoid. In talking with @TartanLlama about this what I'm thinking we might be able to do here is:

  • Unconditionally, for all wasi targets, compile the wasi-threads primitives for mutexes/condvars/etc
  • Have a #ifdef'd implementation for a futex-style API
    • On wasip1/2/3 w/o threads this just returns an error/panics/traps/etc on blocking
    • On wasi-threads it does memory.atomic.*
    • On coop threads it does __waitlist_node or what's there today
  • This additionally paves the way to exporting a futex-style API from wasi-libc itself for other languages like Rust to use

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions