Skip to content

D guest bindings generator - #1561

Draft
QuantumSegfault wants to merge 47 commits into
bytecodealliance:mainfrom
QuantumSegfault:dlang
Draft

D guest bindings generator#1561
QuantumSegfault wants to merge 47 commits into
bytecodealliance:mainfrom
QuantumSegfault:dlang

Conversation

@QuantumSegfault

Copy link
Copy Markdown
Contributor

Implements a d subcrate to support generating bindings for the D programming language.

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

This PR is not yet finished. Just opening a draft early to help interested parties keep track.

@alexcrichton

Copy link
Copy Markdown
Member

Thanks! One thing I'd also recommend as you're implementing things is to add D to this enum as well to hook this into the testing infrastructure. You can then add d to this matrix as appropriate with CI-specific steps to setup the compiler and environment. That'll get codegen/runtime tests working and you'll be able to test out your work by dropping files into the tests/runtime/* folder to implement various components. You'll need to write some orchestration for the test runner to know how to compile D programs (you can draw inspiration from how C is organized) too.

Happy to help answer questions about anything in specific if you have them, and if you have any questions about Rust/idioms/etc feel free to leave a comment here and I can dig in. Otherwise I'll leave this be until you're ready, in which case feel free to ping me and I can take a closer look.

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

@alexcrichton

Things are coming along nicely, but there's one question I have so far.

The codegen tests are excellent for verifying the output of generated imports and types bindings.

Problems arise with the testing of the export wrappers. The way I've implemented exports is using D templates, which are not and cannot be semantically analyzed at all until they have been instantiated. Until an implementation is provided, the wrappers can't be tested.

Is this a problem? This gap in the testing? Or are the runtime tests that will be written enough to compensate?

@alexcrichton

Copy link
Copy Markdown
Member

A good question! If I understand the problem right I believe you're looking for this. The --stubs argument to the Rust generator generates a stub implementation of all exports to ensure that they're codegen'd well. That can also be useful from a "getting started with the generated code" perspective. Would something like that make sense for D, and would that solve the problem too?

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

Yeah! That's pretty much the answer I'm looking for. Something that can create a very basic stub (no impl; just declarations of functions and types) that I can pump into the exports wrapper soley for tests. Thanks!

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

@alexcrichton

I'm still working on getting full test coverage, but I'm ready for this to start getting reviewed.

Support for the new async stuff will be tackled in a future PR. Same with map and implements. This PR brings D support up to the feature set needed for WASIp2.

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Integration points all look good to me 👍. I can't speak much to D idioms and I'm not looking too closesly at crates/d/src/lib.rs, but that's what'd be in your purview

@alexcrichton

Copy link
Copy Markdown
Member

For the CI failure, can you publish a wit-bindgen-d crate to crates.io and then invite the wasmtime-publish user? I'll configure the crate through that and remove you as an owner afterwards

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

For the CI failure, can you publish a wit-bindgen-d crate to crates.io and then invite the wasmtime-publish user? I'll configure the crate through that and remove you as an owner afterwards

I'll do that closer to when this is all ready. I might find more small things needing tweaking as I flesh out the tests. No point making more releases than necessary.

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.

2 participants