summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-07-05 14:04:26 +0000
committerChris Denton <chris@chrisdenton.dev>2024-07-05 16:11:25 +0000
commite136f08a6f4f784d1a1751aced5bf919bb094436 (patch)
tree174dc8b7fa0719fced9ab4379c5114a0b07f4d14 /library/std/src/sys
parenta5dc082d6f51b1df9dc0bf0daf365ccf933f46d5 (diff)
downloadrust-e136f08a6f4f784d1a1751aced5bf919bb094436.tar.gz
rust-e136f08a6f4f784d1a1751aced5bf919bb094436.zip
Add experimental raw-dylib feature to std
For Windows, this allows defining imports without needing the user to have import libraries. It's intended for this to become the default.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/windows/c/windows_targets.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/sys/pal/windows/c/windows_targets.rs b/library/std/src/sys/pal/windows/c/windows_targets.rs
index 56c563462d3..252bceb7094 100644
--- a/library/std/src/sys/pal/windows/c/windows_targets.rs
+++ b/library/std/src/sys/pal/windows/c/windows_targets.rs
@@ -3,6 +3,18 @@
 //! 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
@@ -17,6 +29,7 @@ pub macro link {
     )
 }
 
+#[cfg(not(feature = "windows_raw_dylib"))]
 #[link(name = "advapi32")]
 #[link(name = "ntdll")]
 #[link(name = "userenv")]