Skip to content

Conversation

@MaxDesiatov
Copy link

@MaxDesiatov MaxDesiatov commented Oct 29, 2025

Cherry-pick of #75, merged as cbd8eae

Explanation: This change allows building the cmark-gfm target for both wasm32-unknown-wasi and wasm32-unknown-wasip1-threads.
Scope: Limited to WASI support.
Risk: Low due to changes not impacting other platforms.
Testing: Added in swift-format repo, which has a transitive dependency on swift-cmark.
Issue: rdar://163652438
Reviewer: @QuietMisdreavus

kkebo added 4 commits October 29, 2025 17:15
This change allows building the `cmark-gfm` target for both `wasm32-unknown-wasi` and `wasm32-unknown-wasip1-threads`. The other targets are not tested.

The differences between two target triples:

- `wasm32-unknown-wasi`
  - C
    - can import `unistd.h`
    - has `__wasi__`
    - does not have `__unix__`
    - **does not have `_REENTRANT`**
    - **does not have `_POSIX_THREADS`**
    - **does not support pthreads API at all**
  - Swift
    - can use `#if os(WASI)`
  - SwiftPM
    - `BuildSettingsCondition`'s `Platform` is `.wasi`
- `wasm32-unknown-wasip1-threads`
  - C
    - can import `unistd.h`
    - has `__wasi__`
    - does not have `__unix__`
    - **has `_REENTRANT` (defined in wasi-libc)**
    - **has `_POSIX_THREADS` (defined in wasi-libc)**
    - **supports a subset of pthreads API**
  - Swift
    - can use `#if os(WASI)`
  - SwiftPM
    - `BuildSettingsCondition`'s `Platform` is `.wasi`
@MaxDesiatov MaxDesiatov marked this pull request as ready for review October 29, 2025 17:22
Copy link

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is already being used by the toolchain builds of Swift-DocC (since the toolchain is using gfm directly for release/6.2 instead of this branch) so that plus the fact that there shouldn't be any code change for non-WASI platforms means that this should be safe to use.

@QuietMisdreavus QuietMisdreavus merged commit 5d9bdaa into release/6.2 Oct 29, 2025
@QuietMisdreavus QuietMisdreavus deleted the maxd/wasi-6.2 branch October 29, 2025 17:26
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.

4 participants