Skip to content

Commit 16edf69

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 0199b00 + b1460b9 commit 16edf69

File tree

8 files changed

+26
-6
lines changed

8 files changed

+26
-6
lines changed

Cargo.lock

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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]

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

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)]

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

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;

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 = []

std/src/sys/pal/windows/c/windows_targets.rs renamed to 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 {

0 commit comments

Comments
 (0)