Skip to content
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

no_std support with extern main #98

Closed
joseluis opened this issue Apr 13, 2023 · 1 comment · Fixed by #99
Closed

no_std support with extern main #98

joseluis opened this issue Apr 13, 2023 · 1 comment · Fixed by #99

Comments

@joseluis
Copy link
Contributor

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.

@fornwall
Copy link
Owner

Thanks a lot!

Your fix is included in the just released version 0.26.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants