-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows-sys
without CRT?
#1989
Comments
Could you provide a repro? I'm not sure I'm seeing the same as you are, however, the (failed) imports I see aren't actually from the CRT, but rather the SEH infrastructure ( This is the repro I'm using: Cargo.toml [package]
name = "nostd_windows-sys"
version = "0.0.0"
edition = "2021"
[dependencies.windows-sys]
version = "0.36.1"
features = [
"Win32_Foundation",
"Win32_System_Threading",
] src/main.rs #![no_std]
#![no_main]
use core::panic::PanicInfo;
use windows_sys::Win32::System::Threading::{GetCurrentProcess, TerminateProcess};
#[panic_handler]
fn panic_abort(_info: &PanicInfo) -> ! {
unsafe {
let h = GetCurrentProcess();
TerminateProcess(h, 1);
};
unreachable!();
}
#[no_mangle]
pub extern "C" fn EntryPoint() -> u32 {
0
} .cargo/config.toml [build]
rustflags = [
"-C", "link-arg=/ENTRY:EntryPoint"
] (Note: I don't know why the linker cannot find the entry point.) |
I'm seeing similar CRT functions getting referenced (__CxxFrameHandler3) as @Zymlex reported using @tim-weis's sample (after adding an empty eh_personality function and setting the subsystem):
|
Using panic=abort would be an option for removing panic handling. Although it may also need lto=true to remove all panic handling infrastructure. Also compiler-builtins can provide mem* functions. But I don't think any of this has anything to do with windows-sys. |
Doesn't work for me. |
Hm, this seems to have regressed in 1.60. For 1.59 and earlier the panic handling code is removed with panic=abort and lto. |
The windows-sys crate only contains type and function declarations. There's no code, so I don't think this issue is specific to this crate. |
@ChrisDenton I used to have [profile.release]
panic = 'abort'
lto = 'fat' in Cargo.toml, but that didn't change anything. This is using 1.63, so this at least doesn't contradict your hypothesis. Still, as Kenny points out, I cannot think of any way that the Seems to be an issue with my repro, or @Zymlex's, or rustc. |
Rafael pointed out that the impl ::core::clone::Clone for IO_COUNTERS {
fn clone(&self) -> Self {
*self
}
} This can result in the Rust compiler, or LLVM, injecting calls to functions or intrinsics like |
Does this help? #1992 |
Minimal sample: https://github.com/Zymlex/TestCRTLinking
Link args
|
This set is also of interest:
|
So, That said, I recognize that without a real working end-to-end example, this all feels like a sham. You might want to get the ball rolling on https://github.com/rust-lang/rust/issues. Some issues to keep an eye on: |
Managed to figure it out! Due to a bug, it is necessary to pass arguments through environment variables + cargo args:
So I was able to build without CRT, Winsock and other... |
I'm not really sure what you mean by that? I created some examples. The The |
As I see,
windows-sys
usesno_std
, but still try to link with CRT.Is it possible to use
windows-sys
without CRT?upd: #1989 (comment)
The text was updated successfully, but these errors were encountered: