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.
This commit is contained in:
parent
a5dc082d6f
commit
e136f08a6f
@ -87,6 +87,10 @@ std_detect_file_io = ["std_detect/std_detect_file_io"]
|
|||||||
std_detect_dlsym_getauxval = ["std_detect/std_detect_dlsym_getauxval"]
|
std_detect_dlsym_getauxval = ["std_detect/std_detect_dlsym_getauxval"]
|
||||||
std_detect_env_override = ["std_detect/std_detect_env_override"]
|
std_detect_env_override = ["std_detect/std_detect_env_override"]
|
||||||
|
|
||||||
|
# Enable using raw-dylib for Windows imports.
|
||||||
|
# This will eventually be the default.
|
||||||
|
windows_raw_dylib = []
|
||||||
|
|
||||||
[package.metadata.fortanix-sgx]
|
[package.metadata.fortanix-sgx]
|
||||||
# Maximum possible number of threads when testing
|
# Maximum possible number of threads when testing
|
||||||
threads = 125
|
threads = 125
|
||||||
|
@ -3,6 +3,18 @@
|
|||||||
//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
|
//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
|
||||||
//! It's very roughly equivalent to the windows-targets crate.
|
//! 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 {
|
pub macro link {
|
||||||
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
|
($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
|
// Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't
|
||||||
@ -17,6 +29,7 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "windows_raw_dylib"))]
|
||||||
#[link(name = "advapi32")]
|
#[link(name = "advapi32")]
|
||||||
#[link(name = "ntdll")]
|
#[link(name = "ntdll")]
|
||||||
#[link(name = "userenv")]
|
#[link(name = "userenv")]
|
||||||
|
@ -27,3 +27,4 @@ profiler = ["std/profiler"]
|
|||||||
std_detect_file_io = ["std/std_detect_file_io"]
|
std_detect_file_io = ["std/std_detect_file_io"]
|
||||||
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
|
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
|
||||||
std_detect_env_override = ["std/std_detect_env_override"]
|
std_detect_env_override = ["std/std_detect_env_override"]
|
||||||
|
windows_raw_dylib = ["std/windows_raw_dylib"]
|
||||||
|
Loading…
Reference in New Issue
Block a user