Allow use of windows-rs Rust crate
Categories
(Firefox Build System :: General, task, P3)
Tracking
(firefox124 fixed)
| Tracking | Status | |
|---|---|---|
| firefox124 | --- | fixed |
People
(Reporter: saschanaz, Assigned: glandium)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
(Not sure this is the right component, but I know :glandium knows well about this at least)
This is intended to be a tracking issue since I think someone will have to take a look when the existing dependencies start embracing it. There are also some interests within Gecko for:
- new API uses since windows-rs simply has better API coverage than winapi does
- potential migration to Rust in widget component since the modern C++/WinRT is exception-based and thus does not fit in Gecko. (Using deprecated WRL makes the code dirty.)
A known issue is that windows-rs is BIG (200 MB).
| Assignee | ||
Comment 1•3 years ago
|
||
It's been worked around in bug 1773189, and I'll be working with upstream to attempt to reduce its size and the version churn.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 4•3 years ago
|
||
(In reply to Kagami :saschanaz from comment #3)
Fixed by which bug? 👀
Based on the title's (or workaround it somehow) and Glandium's comment It's been worked around in bug 1773189 I interpreted it as it being resolved by Bug 1773189. If that's not the case, I can re-open it. Though, from the rest of Glandium's comment it seems like the rest of the work to be done is upstream (which I presume to mean the rust repo outside of Bugzilla).
| Reporter | ||
Comment 5•3 years ago
|
||
By "workaround" I meant more like to use it without vendoring it like we do with Windows SDK. Glandium's workaround is about not using windows-rs. I believe those are two different thing, but anyway changing the title to reduce confusion.
A fix would be allowing use of windows-rs in whatever way.
| Reporter | ||
Updated•3 years ago
|
Comment 6•1 year ago
|
||
It appears that windows upstream now has a stable way to filter generated bindings via the windows-bindgen crate. Based on my understanding of :glandium's revision message in D183826 (for bug 1844001):
The windows crate, however, is still too big, and upstream is working towards making it easier to generate adhoc bindings.
…it seems that generating filtered bindings would be an acceptable solution. So, I think we might be able to make forward progress now? Of course, this assumes that we can keep the disk size of vendored WinMD metadata and generated code within tolerance.
We in the WebGPU team are blocked on the consumption of several open-source components that improve WGPU's performance considerably, windows ecosystem, particularly for the gpu-allocator crate and making our D3D12 bindings much safer. We'd be happy to work on this under :glandium's guidance, if bandwidth is the only blocker here!
| Assignee | ||
Comment 7•1 year ago
|
||
As kind of hinted by the recent addition of a dependency and the more recent fixing of said dependency, this is actually actively under work. @nrishel has been testing a proof of concept I provided. Nick, apart from the rust-analyzer completion problem, how has it been going?
Comment 8•1 year ago
•
|
||
:glandium I found that development was going too slow without rust-analyzer for the PoC, so it's on the back burner. I was implementing a COM object with weird constraints and had a lot of copying/pasting from the docs since I couldn't relying on autocomplete. Things were compiling as expected once I worked through build errors so I suspect vendoring a crate like gpu-allocator that (I assume) abstracts over windows might be an easier path to a PoC.
Comment 9•1 year ago
•
|
||
:nrishel: It should be fairly easy to use windows-bindgen to generate the necessary COM APIs that gpu-allocator uses. If you also enable the windows_rs feature for wgpu-hal in gfx/wgpu_bindings/Cargo.toml, and things compile, I'd consider that a successful PoC (for our purposes)!
| Reporter | ||
Comment 10•1 year ago
•
|
||
FWIW, I was also testing on my own PoC on top of glandium's Jan-11 windows-rs stack, things build and functions run as expected. Somehow I'm getting memory access violation crash either from:
- jemalloc through
windows_core::imp::heap::heap_free - SHCore.dll with 0xc000374 which is reportedly heap corruption error code
and I'm unsure whether that's my fault or because of some kind of conflict between jemalloc and windows-rs.
| Reporter | ||
Comment 11•1 year ago
|
||
Or a MOZ_DIAGNOSTIC_ASSERT(arena->mMagic == ARENA_MAGIC); failure where arena is nullptr. 🤔
Comment 12•1 year ago
|
||
:ErichDonGubler can confirm it builds and runs after vendoring gpu-allocator and enabling the windows_rs feature in wgpu-hal on top of :glandium's changes.
| Assignee | ||
Comment 13•1 year ago
|
||
| Assignee | ||
Comment 14•1 year ago
|
||
The windows-rs crate is too large to reasonably vendor in a normal
fashion. So we'll use a bootstrappable toolchain.
| Assignee | ||
Comment 15•1 year ago
|
||
| Assignee | ||
Updated•1 year ago
|
Comment 16•1 year ago
|
||
Comment 17•1 year ago
|
||
| bugherder | ||
| Assignee | ||
Updated•1 year ago
|
Comment 18•1 year ago
|
||
Comment 19•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/3b8bc578e6b6
https://hg.mozilla.org/mozilla-central/rev/baf146e5aff6
Description
•