Uh oh!
There was an error while loading. Please reload this page.
migrate compiler, bootstrap and compiletest to windows-rs - #106610
Conversation
rustbot
commented
Jan 9, 2023
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
davidtwco
commented
Jan 9, 2023
r? @jyn514 |
klensy
commented
Jan 9, 2023
Shouldn't windows-sys be used instead? https://github.com/microsoft/windows-rs#windows-sys: |
ChrisDenton
commented
Jan 9, 2023
Unless it makes compiling rustc significantly slower, I think the |
klensy
commented
Jan 9, 2023
But there no windows perf runs, yet. |
ChrisDenton
commented
Jan 9, 2023
Sure. I wouldn't expect the compile time of one crate to have a significant impact here though. And if it does we should see slower CI times. We can always switch to windows-sys if it does cause problems. |
ChrisDenton
left a comment
There was a problem hiding this comment.
Looks good. I just have a few comments, mostly nits.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Rather than using unsafe on almost every line, why not just keep the big unsafe block?
There was a problem hiding this comment.
Personally I prefer limiting the scope as much as possible, to just the FFI calls.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jyn514
commented
Jan 10, 2023
The idea seems fine, but I'm short on review time and not familiar with Windows. r? @ChrisDenton (thank you for your reviews so far ❤️) |
bors
commented
Jan 14, 2023
☔ The latest upstream changes (presumably #106851) made this pull request unmergeable. Please resolve the merge conflicts. |
rustbot
commented
Jan 15, 2023
Some changes occurred in src/tools/cargo cc @ehuss |
euclio
commented
Jan 15, 2023
Sorry for the ping, accidentally included the cargo submodule in the previous rebase. |
ChrisDenton
commented
Jan 16, 2023
I'm happy to review this; I'd mostly be keen to make sure the API calls end up the same. However, I'm not sure that I'm actually authorized to sign off on this change (I'm more std/libs). cc @Mark-Simulacrum maybe? Moving on from winapi (which is no longer updated) makes sense to do at some point. @klensy brings up the point that maybe we should be using |
jyn514
commented
Jan 16, 2023
@ChrisDenton consider this permission to sign off of the change :) I trust your judgement. @bors delegate=ChrisDenton |
bors
commented
Jan 16, 2023
✌️ @ChrisDenton can now approve this pull request |
ChrisDenton
commented
Jan 16, 2023
Oh ok! In that case I'm fine with this as long as CI is also ok. @bors r+ rollup=never |
bors
commented
Jan 16, 2023
📌 Commit 2c691ae6036bab3dbd06ca0f0cd8c7e28f3b473f has been approved by It is now in the queue for this repository. |
riverar
commented
Mar 20, 2023
@euclio Hey Andy, mind resolving the conflict here so we can give bors another whack at this? |
ChrisDenton
commented
Mar 20, 2023
Ok, lets try again @bors r+ |
bors
commented
Mar 20, 2023
bors
commented
Mar 20, 2023
bors
commented
Mar 20, 2023
☀️ Test successful - checks-actions |
rust-timer
commented
Mar 20, 2023
Finished benchmarking commit (44f5180): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
kennykerr
commented
Mar 21, 2023
Sweet - thanks all - that was some serious collaboration. 🎉 |
ChrisDenton
commented
Mar 21, 2023
Yay! 🎉 It's in nightly now so we'll see how this goes... |
klensy
commented
Mar 21, 2023
Hm, export table size of rustc_driver changed from 18104 to 25790 items (some nearby nightly), plus it looks like there imported few unused fn from windows libs. |
kennykerr
commented
Mar 21, 2023
@dpaoliello could this be related to |
ChrisDenton
commented
Mar 21, 2023
Just for future reference, the two relevant nightly versions are: rustc 1.70.0-nightly (44f5180 2023-03-20) Though in rustup you'll need to +1 to those dates. E.g.: |
dpaoliello
commented
Mar 22, 2023
@kennykerr I don't think it's raw-dylib, look like a lot of the various windows-rs wrappers seem to be being exported. Using When dump that function via WinDbg: That looks like a COM or WinRT call wrapper to me... I'm guessing that |
kennykerr
commented
Mar 22, 2023
Thanks, yeah if it's a lib then that's not too surprising. |
dpaoliello
commented
Mar 22, 2023
It's not a lib, it's a dll that is exporting Rust functions (rather than C functions). If I understand Rust's model for this, then all Would it be possible to trim down the API exposed by |
Just using Cargo features - there's a discussion here about reducing the size of the largest namespaces where I mentioned the Reducing the size of that namespace would go a long way toward reducing the number of Alternatively, you could use the |
kennykerr
commented
Mar 29, 2023
https://github.com/microsoft/windows-rs/releases/tag/0.47.0 has been published and includes an update to the metadata resulting in a much smaller |
Update windows-sys This updates the windows-sys dependency from 0.45 to 0.48. This shouldn't add or remove any duplicate dependencies (since there are other dependencies still using 0.45 and 0.42). The intent is to move it along the direction towards unifying in the future (though it seems like a moving target that will be difficult to ever hit). This also bumps the home crate version. I think it should be OK to make the migration from winapi to windows-sys a patch version, though there seems to be some issues with the way windows-sys works that could introduce some build-time problems in some situations (such as those encountered in rust-lang/rust#108665 and rust-lang/rust#106610). However, I don't expect too much of an issue.
This PR migrates the compiler, bootstrap, and compiletest to use windows-rs instead of winapi-rs. windows-rs is the bindings crate provided by Microsoft, and is actively maintained compared to winapi-rs. Not all ecosystem crates have migrated over yet, so there will be a period of time where both crates are used.
windows-rs also provides some nice ergonomics over winapi-rs to convert return values to
Results (which found a case where we forgot to check the return value ofCreateFileW).