Skip to content

#![windows_subsystem = "windows"] overwrites entrypoint symbol name #147746

@MauriceKayser

Description

@MauriceKayser

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

  1. 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
    }
  2. Linking succeeds via: rustc example.rs -C panic=abort -C link-arg=/Subsystem:Windows
  3. Add #![windows_subsystem = "windows"] to example.rs
  4. Linking fails via: rustc example.rs -C panic=abort

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions