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-sys generated WinAPI bindings break ARM platforms #112265

Closed
bdbai opened this issue Jun 4, 2023 · 8 comments · Fixed by #112527
Closed

windows-sys generated WinAPI bindings break ARM platforms #112265

bdbai opened this issue Jun 4, 2023 · 8 comments · Fixed by #112527
Labels
C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state O-windows-msvc Toolchain: MSVC, Operating system: Windows P-low Low priority regression-untriaged Untriaged performance or correctness regression. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@bdbai
Copy link
Contributor

bdbai commented Jun 4, 2023

In #110152 the WinAPI definitions have been replaced by windows-bindgen generated bindings. However, the win32metadata project does not generate metadata for ARM32-specific items, hence the generated bindings lack a few types like CONTEXT and WSADATA on this platform. It effectively breaks thumbv7a-*-windows-* for Rust.

@ChrisDenton

@bdbai bdbai added the C-bug Category: This is a bug. label Jun 4, 2023
@ChrisDenton
Copy link
Member

Unfortunately, 32-bit ARM is not being supported by Microsoft going forward. What we could do is insert our own definitions in the prelude, copied from before the changes.

@bdbai
Copy link
Contributor Author

bdbai commented Jun 4, 2023

Besides the issue with ARM, all UWP targets actually have problems with linkage as well. Previously the APIs forbidden on UWP are gated behind fine-grained conditional compilation flags, but it is no longer the case with generated ones. I got this when building the UWP app that links again a Rust staticlib.
image

@ChrisDenton
Copy link
Member

Iirc, the Nt functions were never gated. But we loaded them lazily (and panicked if they didn't load). This did allow UWP targets to compile. No idea if they actually ran. I'm not sure who's responsible for these targets.

@bdbai
Copy link
Contributor Author

bdbai commented Jun 4, 2023

Iirc, the Nt functions were never gated. But we loaded them lazily (and panicked if they didn't load). This did allow UWP targets to compile. No idea if they actually ran. I'm not sure who's responsible for these targets.

I think you are correct. I can reproduce the link errors with toolchain nightly-2023-05-06. Let me file another issue after I pinpoint the underlying problem.

@ChrisDenton
Copy link
Member

Oh wait, as staticlib? You currently need to make sure to link all the libraries it depends on. You can get them using --print native-static-libs.

@bdbai
Copy link
Contributor Author

bdbai commented Jun 4, 2023

Oh wait, as staticlib? You currently need to make sure to link all the libraries it depends on. You can get them using --print native-static-libs.

This will fail Windows App Cert Kit tests.

image

@jyn514 jyn514 added O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) regression-untriaged Untriaged performance or correctness regression. labels Jun 4, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 4, 2023
@ChrisDenton
Copy link
Member

In that case I'm surprised that lazy loading worked.

@apiraino
Copy link
Contributor

apiraino commented Jun 6, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-low

@rustbot rustbot added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 6, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 10, 2023
Fix ntdll linkage issues on Windows UWP platforms

See discussion: rust-lang#112265 (comment)

Static loading `ntdll` functions does not work for UWP programs, which will end up link errors complaining about missing symbols, or failure to pass the WACK tests. The breakage was introduced in rust-lang#108262.

This PR basically reverts part of the changes in rust-lang#108262 for UWP only, and fixes some lint suggestions.
@bors bors closed this as completed in 9c4cff4 Jun 12, 2023
thomcc pushed a commit to tcdi/postgrestd that referenced this issue Aug 24, 2023
Fix ntdll linkage issues on Windows UWP platforms

See discussion: rust-lang/rust#112265 (comment)

Static loading `ntdll` functions does not work for UWP programs, which will end up link errors complaining about missing symbols, or failure to pass the WACK tests. The breakage was introduced in #108262.

This PR basically reverts part of the changes in #108262 for UWP only, and fixes some lint suggestions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state O-windows-msvc Toolchain: MSVC, Operating system: Windows P-low Low priority regression-untriaged Untriaged performance or correctness regression. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants