`#![windows_subsystem = "windows"]` overwrites entrypoint symbol name
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Description
Using #![windows_subsystem = "windows"] overwrites the default entrypoint symbol name WinMainCRTStartup with mainCRTStartup. This is by design, but can be unexpected in certain scenarios, for example when specifying #![no_main]. It should either be adapted for those scenarios, or mentioned in the user facing documentation.
Reproduction
- Create
example.rs:#![no_main] #![no_std] #[cfg(not(test))] #[panic_handler] fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } #[unsafe(no_mangle)] extern "system" fn WinMainCRTStartup() -> i32 { 0 } - Linking succeeds via:
rustc example.rs -C panic=abort -C link-arg=/Subsystem:Windows - Add
#![windows_subsystem = "windows"]toexample.rs - Linking fails via:
rustc example.rs -C panic=abort
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two rustc commands with the provided example.rs, then inspect the linked logic in compiler/rustc_codegen_ssa/src/back/linker.rs and the Windows subsystem attribute documentation in the Rust Reference. Determine whether the behavior should change for no_main or be documented, and consider the issue done when the selected resolution is verified by the reproduction or clearly explained to users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100