Skip to content

Commit 9c4cff4

Browse files
authored
Rollup merge of #112527 - bdbai:fix/winarm32, r=ChrisDenton
Add windows_sys type definitions for ARM32 manually `windows_sys` bindings do not include platform-specific type definitions for ARM 32 architecture, so it breaks `thumbv7a-pc-windows-msvc` and `thumbv7a-uwp-windows-msvc` targets. This PR tries to add them back by manually inserting them together with the generated ones. `WSADATA` is copied from the generated definition for `x86`. `CONTEXT` is copied from the definition before `windows_sys` is introduced (which is just an empty enum): https://github.com/rust-lang/rust/blob/4a18324a4df6bc98bec0b54d35908d7a9cdc7c32/library/std/src/sys/windows/c.rs#L802. Fixes #112265.
2 parents 8475a88 + df08f56 commit 9c4cff4

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

library/std/src/sys/windows/c/windows_sys.rs

+20
Original file line numberDiff line numberDiff line change
@@ -4275,3 +4275,23 @@ impl ::core::clone::Clone for XSAVE_FORMAT {
42754275
*self
42764276
}
42774277
}
4278+
// Begin of ARM32 shim
4279+
// The raw content of this file should be processed by `generate-windows-sys`
4280+
// to be merged with the generated binding. It is not supposed to be used as
4281+
// a normal Rust module.
4282+
cfg_if::cfg_if! {
4283+
if #[cfg(target_arch = "arm")] {
4284+
#[repr(C)]
4285+
pub struct WSADATA {
4286+
pub wVersion: u16,
4287+
pub wHighVersion: u16,
4288+
pub szDescription: [u8; 257],
4289+
pub szSystemStatus: [u8; 129],
4290+
pub iMaxSockets: u16,
4291+
pub iMaxUdpDg: u16,
4292+
pub lpVendorInfo: PSTR,
4293+
}
4294+
pub enum CONTEXT {}
4295+
}
4296+
}
4297+
// End of ARM32 shim
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Begin of ARM32 shim
2+
// The raw content of this file should be processed by `generate-windows-sys`
3+
// to be merged with the generated binding. It is not supposed to be used as
4+
// a normal Rust module.
5+
cfg_if::cfg_if! {
6+
if #[cfg(target_arch = "arm")] {
7+
#[repr(C)]
8+
pub struct WSADATA {
9+
pub wVersion: u16,
10+
pub wHighVersion: u16,
11+
pub szDescription: [u8; 257],
12+
pub szSystemStatus: [u8; 129],
13+
pub iMaxSockets: u16,
14+
pub iMaxUdpDg: u16,
15+
pub lpVendorInfo: PSTR,
16+
}
17+
pub enum CONTEXT {}
18+
}
19+
}
20+
// End of ARM32 shim

src/tools/generate-windows-sys/src/main.rs

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const PRELUDE: &str = r#"// This file is autogenerated.
1111
// ignore-tidy-filelength
1212
"#;
1313

14+
/// This is a shim for the ARM (32-bit) architecture, which is no longer supported by windows-rs.
15+
const ARM_SHIM: &str = include_str!("arm_shim.rs");
16+
1417
fn main() -> io::Result<()> {
1518
let mut path: PathBuf =
1619
std::env::args_os().nth(1).expect("a path to the rust repository is required").into();
@@ -32,6 +35,7 @@ fn main() -> io::Result<()> {
3235
let mut f = std::fs::File::create(&path)?;
3336
f.write_all(PRELUDE.as_bytes())?;
3437
f.write_all(bindings.as_bytes())?;
38+
f.write_all(ARM_SHIM.as_bytes())?;
3539

3640
Ok(())
3741
}

0 commit comments

Comments
 (0)