Skip to content

Commit 66d3db0

Browse files
authored
Rollup merge of rust-lang#128873 - ChrisDenton:windows-targets, r=Mark-Simulacrum
Add windows-targets crate to std's sysroot With this PR, when backtrace is used as a crate from crates.io it will (once updated) use the real [windows-targets](https://crates.io/crates/windows-targets) crate. But when used from std it'll use std's replacement version. This allows sharing our customized `windows_tagets::link!` macro between std proper and the backtrace crate when used as part of std, ensuring a consistent linking story. This will be especially important once we move to using [`raw-dylib`](https://doc.rust-lang.org/reference/items/external-blocks.html#dylib-versus-raw-dylib) by default.
2 parents 806f8ce + a1b2b7f commit 66d3db0

File tree

10 files changed

+27
-7
lines changed

10 files changed

+27
-7
lines changed

Diff for: library/Cargo.lock

+6-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]]
@@ -421,9 +422,13 @@ version = "0.52.0"
421422
source = "registry+https://github.com/rust-lang/crates.io-index"
422423
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
423424
dependencies = [
424-
"windows-targets",
425+
"windows-targets 0.52.5",
425426
]
426427

428+
[[package]]
429+
name = "windows-targets"
430+
version = "0.0.0"
431+
427432
[[package]]
428433
name = "windows-targets"
429434
version = "0.52.5"

Diff for: library/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
exclude = [
99
# stdarch has its own Cargo workspace
1010
"stdarch",
11+
"windows_targets"
1112
]
1213

1314
[profile.release.package.compiler_builtins]

Diff for: 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

Diff for: 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)]

Diff for: 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

Diff for: 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;

Diff for: 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 = []

Diff for: 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 {

Diff for: 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
}

Diff for: 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)