Skip to content

Add WebAssembly to core.stdc.config#22844

Open
IDONTUSEGH wants to merge 2 commits intodlang:masterfrom
IDONTUSEGH:wasm
Open

Add WebAssembly to core.stdc.config#22844
IDONTUSEGH wants to merge 2 commits intodlang:masterfrom
IDONTUSEGH:wasm

Conversation

@IDONTUSEGH
Copy link
Copy Markdown
Contributor

Added a version(WebAssembly) block to provide the correct C compatible
type aliases.

This is a copy of the WASI block.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @IDONTUSEGH! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22844"

@thewilsonator thewilsonator added the Druntime Specific to druntime label Mar 31, 2026
@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Mar 31, 2026

When I added stdc definitions for WebAssembly, I was told that it's the C runtime (e.g. WASI) instead of the architecture (WASM) dictating C types: dlang/druntime#3848

Added a version(WebAssembly) block to provide the correct C compatible type aliases.

What source do you have for these definitions being correct for WebAssembly in general?

@IDONTUSEGH
Copy link
Copy Markdown
Contributor Author

IDONTUSEGH commented Mar 31, 2026

This is needed because LDC imports that module for ImportC.

WASI adopts the data model of the underlying WebAssembly architecture it is compiled for, hence why I copied the version block, and I confirmed with: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md

The feedback on that PR refers to runtime specific libc definitions. My PR is the exception because it just defines the fundamental C types. I think yours would have been accepted if it'd have just been that.

@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Mar 31, 2026

That document says:

As mentioned in README, it's not the only possible C ABI. It is the ABI that the clang/LLVM WebAssembly backend is currently using, and any other C or C++ compiler wishing to be ABI-compatible with it.

@IDONTUSEGH
Copy link
Copy Markdown
Contributor Author

IDONTUSEGH commented Mar 31, 2026

It's the same story with the WASI aliases, I think it's fine.

ping @kinke @ibuclaw , do you think this is fine to have? Or should they be separate for GDC/LDC?

@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Mar 31, 2026

I also think it's fine to just assume LLVM backend conventions since there are no other D compilers targeting WebAssembly currently, but then we could also just replace the version (WASI) with version (WebAssembly) and add a comment about our assumption rather than copying the WASI block.

@ibuclaw
Copy link
Copy Markdown
Member

ibuclaw commented Mar 31, 2026

If unsure, ask feedable in #gcc on OFTC, who's doing the gcc port. But otherwise likely nothing worth blocking.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Mar 31, 2026

Also note that version(WebAssembly) also applies to Emscripten targets, where other versions are predefined (Posix, linux, CRuntime_Musl), so please take care not to break those targets.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Mar 31, 2026

For clarity, here for this PR, I suggest simply renaming the existing WASI block to WebAssembly, ideally including a link to https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md#data-representation. It's a copy of the earlier Posix block anyway, and GCC has its own leading version (GNU) block.

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

Labels

Druntime Specific to druntime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants