pacak / cargo-show-asm

cargo subcommand showing the assembly, LLVM-IR and MIR generated for Rust code
Apache License 2.0
710 stars 33 forks source link

example of public non generic library function not appearing #320

Closed e00E closed 4 weeks ago

e00E commented 4 weeks ago

Consider a library crate with the following contents:

pub fn foo(a: u32) -> u8 {
    a as u8
}

This function does not show up in cargo asm, not with --everything either. I can get the function to show up by tagging it #[no_mangle] or #[inline(never)].

I'm reporting this as an issue because the Readme says this:

rustc will only generate the code for your function if it knows what type it is, including generic parameters and if it is exported (in case of a library) and not inlined (in case of a binary, example, test, etc.). If your function takes a generic parameter - try making a monomorphic wrapper around it and make it pub and #[inline(never)].

This makes it sound like this shouldn't happen.

pacak commented 4 weeks ago

I appreciate the report, this is a known problem caused by rustc itself - see https://github.com/rust-lang/rust/pull/116505

I forgor to update the documentation, will fix.