Skip to content

no_std support with extern main #98

Closed
@joseluis

Description

@joseluis

This minimal example fails to compile:

#!/usr/bin/env -S rust-script -c
//! ```cargo
//! [dependencies]
//! libc = { version = "0.2", default-features = false }
//! 
//! [profile.release]
//! strip = true
//! lto = true
//! opt-level = "s" # "z"
//! codegen-units = 1
//! panic = "abort"
//! ```

#![no_std]
#![no_main]

#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
    loop {}
}

#[no_mangle]
pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
    unsafe {
        libc::printf("hello, world\0".as_ptr() as *const _);
    }
    0
}

I've just sent a PR that updates the contains_main_method making the main detection work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions