pacak / cargo-show-asm

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

Prevent linking of instances of the same function #338

Closed e00E closed 2 days ago

e00E commented 3 days ago

I have two functions that happen to have the same assembly. In the output of cargo-asm this looks like this:

.set my_crate::foo, my_crate::bar

The assembly for bar contains the actual assembly.

This is annoying because I would like to see the assembly immediately in foo. I do not want to see this output and then have to switch to bar. Both functions are marked inline-never.

I noticed that whether I get the .set behavior depends on what the lto setting is. I'm not sure whether that is relevant.

pacak commented 3 days ago

This linking is done by rustc/llvm so I can't really prevent it. Forbidding lto and setting unreasonably high codegen unit count would help if not for https://github.com/rust-lang/cargo/issues/13672

What I can try is to detect this kind of behavior and make it so your_crate::bar is displayed alongside the output you get right now either unconditionally or using recursive context flag...

pacak commented 2 days ago

You can pass -c 1 to see the actual implementation of your_crate::bar included in the additional context.