Skip to content

Commit 1a6e5cc

Browse files
committed
Add windows-targets crate to std's sysroot
1 parent c7b0d4e commit 1a6e5cc

File tree

10 files changed

+30
-7
lines changed

10 files changed

+30
-7
lines changed

library/Cargo.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ dependencies = [
339339
"std_detect",
340340
"unwind",
341341
"wasi",
342+
"windows-targets 0.0.0",
342343
]
343344

344345
[[package]]
@@ -359,6 +360,7 @@ dependencies = [
359360
"proc_macro",
360361
"std",
361362
"test",
363+
"windows-targets 0.0.0",
362364
]
363365

364366
[[package]]
@@ -421,9 +423,13 @@ version = "0.52.0"
421423
source = "registry+https://github.com/rust-lang/crates.io-index"
422424
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
423425
dependencies = [
424-
"windows-targets",
426+
"windows-targets 0.52.5",
425427
]
426428

429+
[[package]]
430+
name = "windows-targets"
431+
version = "0.0.0"
432+
427433
[[package]]
428434
name = "windows-targets"
429435
version = "0.52.5"

library/std/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ object = { version = "0.36.0", default-features = false, optional = true, featur
5757
'archive',
5858
] }
5959

60+
[target.'cfg(windows)'.dependencies.windows-targets]
61+
path = "../windows_targets"
62+
6063
[dev-dependencies]
6164
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
6265
rand_xorshift = "0.3.0"
@@ -116,7 +119,7 @@ std_detect_env_override = ["std_detect/std_detect_env_override"]
116119

117120
# Enable using raw-dylib for Windows imports.
118121
# This will eventually be the default.
119-
windows_raw_dylib = []
122+
windows_raw_dylib = ["windows-targets/windows_raw_dylib"]
120123

121124
[package.metadata.fortanix-sgx]
122125
# Maximum possible number of threads when testing

library/std/src/sys/pal/windows/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::alloc::{GlobalAlloc, Layout, System};
44
use crate::ffi::c_void;
55
use crate::ptr;
66
use crate::sync::atomic::{AtomicPtr, Ordering};
7-
use crate::sys::c::{self, windows_targets};
7+
use crate::sys::c;
88
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
99

1010
#[cfg(test)]

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

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr};
99
use core::{mem, ptr};
1010

11-
pub(super) mod windows_targets;
12-
1311
mod windows_sys;
1412
pub use windows_sys::*;
1513

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

-1
Original file line numberDiff line numberDiff line change
@@ -3317,4 +3317,3 @@ pub struct WSADATA {
33173317
#[cfg(target_arch = "arm")]
33183318
pub enum CONTEXT {}
33193319
// ignore-tidy-filelength
3320-
use super::windows_targets;

library/sysroot/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ proc_macro = { path = "../proc_macro" }
99
std = { path = "../std" }
1010
test = { path = "../test" }
1111

12+
[target.'cfg(windows)'.dependencies]
13+
windows-targets = { path = "../windows_targets" }
14+
1215
# Forward features to the `std` crate as necessary
1316
[features]
1417
default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"]

library/windows_targets/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "windows-targets"
3+
description = "A drop-in replacement for the real windows-targets crate for use in std only."
4+
version = "0.0.0"
5+
edition = "2021"
6+
7+
[features]
8+
# Enable using raw-dylib for Windows imports.
9+
# This will eventually be the default.
10+
windows_raw_dylib = []

library/std/src/sys/pal/windows/c/windows_targets.rs renamed to library/windows_targets/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
//!
33
//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
44
//! It's very roughly equivalent to the windows-targets crate.
5+
#![no_std]
6+
#![no_core]
7+
#![feature(decl_macro)]
8+
#![feature(no_core)]
59

610
#[cfg(feature = "windows_raw_dylib")]
711
pub macro link {

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

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ fn main() -> Result<(), Box<dyn Error>> {
3535
let mut f = std::fs::File::options().append(true).open("windows_sys.rs")?;
3636
f.write_all(ARM32_SHIM.as_bytes())?;
3737
writeln!(&mut f, "// ignore-tidy-filelength")?;
38-
writeln!(&mut f, "use super::windows_targets;")?;
3938

4039
Ok(())
4140
}

src/tools/tidy/src/pal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::walk::{filter_dirs, walk};
3636

3737
// Paths that may contain platform-specific code.
3838
const EXCEPTION_PATHS: &[&str] = &[
39+
"library/windows_targets",
3940
"library/panic_abort",
4041
"library/panic_unwind",
4142
"library/unwind",

0 commit comments

Comments
 (0)