Skip to content

Update Win32 metadata - #3111

Merged
Kenny Kerr (kennykerr) merged 12 commits into
masterfrom
win32metadata
Jun 19, 2024
Merged

Kenny Kerr (kennykerr) merged 12 commits into
masterfrom
win32metadata

Conversation

@kennykerr

@kennykerr Kenny Kerr (kennykerr) commented Jun 18, 2024 •

Copy link
Copy Markdown
Collaborator

This is the first update to the Win32 and WDK metadata for some time so there's a fair bit of ripple.

@ChrisDenton

Copy link
Copy Markdown
Collaborator

Hm, that failure looks similar to one I've seen elsewhere. Rustup stopped modifying PATH but it seems that -gnu was sometimes relying on this modification to find its own libraries. Try adding RUSTUP_WINDOWS_PATH_ADD_BIN=1 to the environment for gnu builders and see if it fixes it?

@riverar

Copy link
Copy Markdown
Collaborator

Here's the real error:

The procedure entry point CoRevokeDeviceCatalog could not be located in the dynamic link library C:\Sources\windows-rs\target\x86_64-pc-windows-gnu\debug\deps\com-bd87402ef0e70998.exe. 

Interestingly, this function doesn't live in OLE32 as documented but is rather exported by an apiset (and ultimately now lives in COMBASE). Investigating further.

@riverar

Copy link
Copy Markdown
Collaborator

I corrected metadata locally and regenerated libs/bindings, and tests pass. Filed an issue microsoft/win32metadata#1928 to get this fixed on the metadata side.

Now to investigate why we're just now pulling that in.

@kennykerr

Copy link
Copy Markdown
Collaborator Author

CoRevokeDeviceCatalog isn't something we use in any way, but perhaps its being used by the GNU CRT/startup code? Still the import for this function hasn't changed in windows-rs by this metadata so it's unclear how this change was caused by metadata.

@riverar

Copy link
Copy Markdown
Collaborator

We added it for RAII purposes about a month ago microsoft/win32metadata@d7c12d8#diff-3aa5b50df6faebc7292a072a8060e1ec5d900ed37522da9168f3a35a9f33da7cR696 and with the linker stuffing everything under the sun into the import tables, ... 💥

So think we'll quickly fix up metadata and maybe try again soon.

@kennykerr

Copy link
Copy Markdown
Collaborator Author

Makes total sense - thanks Rafael!

@kennykerr

Copy link
Copy Markdown
Collaborator Author

Part of the issue is the eagerness the Rust compiler has for generating code for functions even when they're not called on the assumption that the optimizer will strip it out in the end. This is why I originally added the #[inline] attribute to all function wrappers in the windows crate. The immediate solution here is to also add the #[inline] attribute to the free functions from #3013 - this is the correct fix even if the Win32 metadata didn't have any invalid imports. So we still need to deal with microsoft/win32metadata#1928 but at least b379b7f unblocks windows-rs.

@kennykerr
Kenny Kerr (kennykerr) merged commit d331301 into master Jun 19, 2024
@kennykerr
Kenny Kerr (kennykerr) deleted the win32metadata branch June 19, 2024 17:38
@kennykerr

Copy link
Copy Markdown
Collaborator Author

Chris Denton (@ChrisDenton) please take it for a spin and let me know if the new pointer handles is a better fit.

@ChrisDenton

Copy link
Copy Markdown
Collaborator

I've been trying it out in a number of projects and so far it's mostly just meant no longer needing as casts when using from/as/into raw_handle on std types. So yeah that's a nice, if modest, change. Though honestly the overall impact has be roughly on par with other changes (such as places where we now correctly use PCWSTR instead of *mut c_void) so it's not as big a deal as I thought it might be. Mind you, I wouldn't be surprised if there are libraries out there that will see a bigger impact.

@riverar

Copy link
Copy Markdown
Collaborator

Chris Denton (@ChrisDenton) Maybe a dumb question--should we be using that std HANDLE type directly instead of *mut c_void? Or is that going to cause MSRV issues?

@ChrisDenton

Copy link
Copy Markdown
Collaborator

We could do except that it's std only so no_std projects can't use it. This would affect the windows-sys crate and potentially people who generate their own bindings. However it ultimately doesn't matter because the std type is just an alias of *mut core::ffi::c_void so they're the exact same type in any case.

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.

Consider using pointers for handle types rather than isize

3 participants