about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-07-25 18:57:57 +0200
committerGitHub <noreply@github.com>2024-07-25 18:57:57 +0200
commitc96311bf8a172726e7772cc8a7ea7768f464705b (patch)
tree04dc05f2d86b2f5eb7d576b531ea174ab910df24 /src
parent155ba22f3cc7e2710cbac05eb2f844fbcc4dffd8 (diff)
parentc629bfc9e177a9f6380cb6bad166e51194c18887 (diff)
downloadrust-c96311bf8a172726e7772cc8a7ea7768f464705b.tar.gz
rust-c96311bf8a172726e7772cc8a7ea7768f464705b.zip
Rollup merge of #127999 - ChrisDenton:arm32, r=Amanieu
Inject arm32 shims into Windows metadata generation

I had been keen to eventually move to using windows-sys as a normal Cargo dependency. But for linking, compile times and other reasons that's unlikely to ever happen.

So if we're sticking with generated bindings then injecting any necessary missing type definitions (i.e. for the MS unsupported arm32) is simpler than defining whole functions ourselves just because we need to manually implement those types on a tier 3 platform. This also reduces the places we need to change when making changes to how we use `#[link]`.

r? libs
Diffstat (limited to 'src')
-rw-r--r--src/tools/generate-windows-sys/src/main.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/generate-windows-sys/src/main.rs b/src/tools/generate-windows-sys/src/main.rs
index fd21e7a86b0..90fce2b675a 100644
--- a/src/tools/generate-windows-sys/src/main.rs
+++ b/src/tools/generate-windows-sys/src/main.rs
@@ -4,6 +4,24 @@ use std::fs;
 use std::io::{Read, Seek, SeekFrom, Write};
 use std::path::PathBuf;
 
+/// 32-bit ARM is not supported by Microsoft so ARM types are not generated.
+/// Therefore we need to inject a few types to make the bindings work.
+const ARM32_SHIM: &str = r#"
+#[cfg(target_arch = "arm")]
+#[repr(C)]
+pub struct WSADATA {
+    pub wVersion: u16,
+    pub wHighVersion: u16,
+    pub szDescription: [u8; 257],
+    pub szSystemStatus: [u8; 129],
+    pub iMaxSockets: u16,
+    pub iMaxUdpDg: u16,
+    pub lpVendorInfo: PSTR,
+}
+#[cfg(target_arch = "arm")]
+pub enum CONTEXT {}
+"#;
+
 fn main() -> Result<(), Box<dyn Error>> {
     let mut path: PathBuf =
         env::args_os().nth(1).expect("a path to the rust repository is required").into();
@@ -16,6 +34,7 @@ fn main() -> Result<(), Box<dyn Error>> {
     println!("{info}");
 
     let mut f = std::fs::File::options().append(true).open("windows_sys.rs")?;
+    f.write_all(ARM32_SHIM.as_bytes())?;
     writeln!(&mut f, "// ignore-tidy-filelength")?;
     writeln!(&mut f, "use super::windows_targets;")?;