Skip to content

druntime: Treat WASI as Posix - #23475

Merged
kinke merged 6 commits into
dlang:masterfrom
QuantumSegfault:wasi-is-posix
Jul 29, 2026
Merged

druntime: Treat WASI as Posix#23475
kinke merged 6 commits into
dlang:masterfrom
QuantumSegfault:wasi-is-posix

Conversation

@QuantumSegfault

Copy link
Copy Markdown
Contributor

Adds WASI (or rather wasi-libc) support to core.sys.posix, and makes all WASI triples define Posix.

Also removes or adjust other WASI specific code accordingly.


Upstreaming of ldc-developers/ldc#5230

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

DMD perf check

Metric Base PR delta
compile hello.d (instr) 215.4 M 215.9 M +0.21%
compile hello.d -O (instr) 234.0 M 234.4 M +0.20%
compile Phobos (instr) 5,070.3 M 5,074.0 M +0.07%
compile vibe.d (instr) 15,120.1 M 15,121.9 M +0.01%
dmd binary size (stripped) 6.90 MB 6.90 MB 0.00%
hello binary size 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 43 MB 44 MB +0.52%
peak RSS (compile Phobos) 631 MB 631 MB 0.00%
peak RSS (compile vibe.d) 1980 MB 1981 MB +0.04%

@rikkimax

Copy link
Copy Markdown
Contributor

Append with empty changelist, and push.
Looks like CircleCI is just being weird.

@kinke kinke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've already approved of this for LDC, where WASI druntime support is CI-tested now (with D stable/v2.113), and all druntime unittests pass, as well as the awesome importc_compare.d test verifying the bindings (the error-exclusion list additions are still missing for that test in this PR).

The ongoing core.thread refactoring causing immediate merge conflicts is unfortunate.

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

the error-exclusion list additions are still missing for that test in this PR

Ooooh. Right. I'll get that (and fix the merge conflict).

@kinke
kinke merged commit 91defa1 into dlang:master Jul 29, 2026
42 checks passed
@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

@denizzzka

An extra reminder. This impacts your thread refactoring.

@denizzzka

Copy link
Copy Markdown
Contributor

@QuantumSegfault thanks, #23481 rebased

{}
else version (Solaris)
{}
else version (WASI)

@denizzzka denizzzka Jul 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@QuantumSegfault Why was there this lines was added?

We decided to rely on Posix or ...?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, found answer here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. Rather than supporting WASI directly, we're using emulated Posix.

wasi-libc is MOSTLY Posix compliant (for our purposes).

But they for instance don't provide semaphores (it's straight up not defined in the current release; it will soon be defined, but always error out ENOTSUP).

Signals aren't supported either.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about mutexes? Without it multithreading will not work in D because GC needs it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I disabled COLLECT_PARALLEL and COLLECT_FORK on WASI (WASI is single-threaded at the moment)

But they do support mutex.

I tested it in LDC, all the DRuntime unit-tests pass (some involve GC collections)

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