Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows-bindgen should generate no_std bindings by default #3335

Closed
mwcampbell opened this issue Oct 31, 2024 · 9 comments · Fixed by #3359 or #3366
Closed

windows-bindgen should generate no_std bindings by default #3335

mwcampbell opened this issue Oct 31, 2024 · 9 comments · Fixed by #3359 or #3366
Labels
enhancement New feature or request

Comments

@mwcampbell
Copy link

Since the windows crate recently gained support for using no_std while still supporting alloc, it would be useful to have a complete example of an executable or DLL built this way. I read in #3047 that some low-level components, including in Windows itself, use the crate this way. I understand if this is an impractical request because all the real examples are too tightly coupled to Windows's build system or other proprietary bits.

@kennykerr kennykerr added the question Further information is requested label Oct 31, 2024
@kennykerr
Copy link
Collaborator

While we can probably add/update a sample, there's not really much to illustrate here beyond adding #![no_std] to your lib.rs or main.rs and taking it for a spin. The compiler should quickly point out what you might be missing.

@kennykerr
Copy link
Collaborator

Actually, I attempted to port a sample to use no_std and ran into a few minor issues so I'll use this issue to track those and then make sure we have test coverage and a working sample.

@kennykerr kennykerr added enhancement New feature or request and removed question Further information is requested labels Nov 1, 2024
@kennykerr kennykerr changed the title Complete no_std example using windows crate with alloc? windows-bindgen should generate no_std bindings by default Nov 1, 2024
@kennykerr
Copy link
Collaborator

Note to self: sample_direct2d is a good test case for this.

@mwcampbell
Copy link
Author

What I had in mind for a complete no_std sample was things like setting up a panic handler, allocator (if you've actually figured out a way to use no_std with alloc in user space), and any other bits that are required for non-trivial no_std projects on Windows.

@kennykerr
Copy link
Collaborator

If you mean the alloc crate then you can find various examples by searching this repo. It is used for allocation support under no_std.

If you mean a custom allocator then you may want to look at https://github.com/microsoft/windows-drivers-rs for examples.

@mwcampbell
Copy link
Author

@kennykerr Are you still planning to make the sample_direct2d project no_std as a test case and demo?

@kennykerr
Copy link
Collaborator

Yes, this issue was mostly resolved by #3359 but I'll open again to address some remaining issues and update the sample.

@kennykerr kennykerr reopened this Dec 9, 2024
@kennykerr
Copy link
Collaborator

Thanks for checking! 🙂

@kennykerr
Copy link
Collaborator

@mwcampbell I decided against updating the sample as it butched the sample undesirably, but I fixed the underlying code gen and added tests to ensure that everything should build with no_std if so desired.

Please take #3366 for a spin and let me know if you run into any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants