about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-14 05:05:51 +0200
committerGitHub <noreply@github.com>2024-08-14 05:05:51 +0200
commitf4c860a9964142db5f2e3c256f95347c9437b582 (patch)
treee9ba7895bf62695895554c9e9b2f66b220aba9fc /library/std/src/sys
parent85180cd365f2a518183b24468fb5754f6c842e0f (diff)
parenta1b2b7ff78b9dbaeffe8341b3616a8c8c4fd4351 (diff)
downloadrust-f4c860a9964142db5f2e3c256f95347c9437b582.tar.gz
rust-f4c860a9964142db5f2e3c256f95347c9437b582.zip
Rollup merge of #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.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/windows/alloc.rs2
-rw-r--r--library/std/src/sys/pal/windows/c.rs2
-rw-r--r--library/std/src/sys/pal/windows/c/windows_sys.rs1
-rw-r--r--library/std/src/sys/pal/windows/c/windows_targets.rs37
4 files changed, 1 insertions, 41 deletions
diff --git a/library/std/src/sys/pal/windows/alloc.rs b/library/std/src/sys/pal/windows/alloc.rs
index 92b68b26032..2205885687d 100644
--- a/library/std/src/sys/pal/windows/alloc.rs
+++ b/library/std/src/sys/pal/windows/alloc.rs
@@ -4,7 +4,7 @@ use crate::alloc::{GlobalAlloc, Layout, System};
 use crate::ffi::c_void;
 use crate::ptr;
 use crate::sync::atomic::{AtomicPtr, Ordering};
-use crate::sys::c::{self, windows_targets};
+use crate::sys::c;
 use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
 
 #[cfg(test)]
diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs
index 08b75186aef..2f5d75dc4bc 100644
--- a/library/std/src/sys/pal/windows/c.rs
+++ b/library/std/src/sys/pal/windows/c.rs
@@ -8,8 +8,6 @@
 use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr};
 use core::{mem, ptr};
 
-pub(super) mod windows_targets;
-
 mod windows_sys;
 pub use windows_sys::*;
 
diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs
index 9f22f548195..529c96a0e1e 100644
--- a/library/std/src/sys/pal/windows/c/windows_sys.rs
+++ b/library/std/src/sys/pal/windows/c/windows_sys.rs
@@ -3317,4 +3317,3 @@ pub struct WSADATA {
 #[cfg(target_arch = "arm")]
 pub enum CONTEXT {}
 // ignore-tidy-filelength
-use super::windows_targets;
diff --git a/library/std/src/sys/pal/windows/c/windows_targets.rs b/library/std/src/sys/pal/windows/c/windows_targets.rs
deleted file mode 100644
index 252bceb7094..00000000000
--- a/library/std/src/sys/pal/windows/c/windows_targets.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! Provides the `link!` macro used by the generated windows bindings.
-//!
-//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
-//! It's very roughly equivalent to the windows-targets crate.
-
-#[cfg(feature = "windows_raw_dylib")]
-pub macro link {
-    ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
-        #[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]
-        #[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]
-        extern $abi {
-            $(#[link_name=$link_name])?
-            pub fn $($function)*;
-        }
-    )
-}
-#[cfg(not(feature = "windows_raw_dylib"))]
-pub macro link {
-    ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
-        // Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't
-        // have in this repo. So instead we always link kernel32.lib and add the rest of the import
-        // libraries below by using an empty extern block. This works because extern blocks are not
-        // connected to the library given in the #[link] attribute.
-        #[link(name = "kernel32")]
-        extern $abi {
-            $(#[link_name=$link_name])?
-            pub fn $($function)*;
-        }
-    )
-}
-
-#[cfg(not(feature = "windows_raw_dylib"))]
-#[link(name = "advapi32")]
-#[link(name = "ntdll")]
-#[link(name = "userenv")]
-#[link(name = "ws2_32")]
-extern "C" {}