New crate announcement cargo-show-asm

116 points manpacket

Ever wondered what kind of asm code rustc generates behind your back? There is godbolt but copying all the dependencies from a typical project is too much work. There is cargo rustc -- --emit asm but good luck finding exact piece of code you want to look at. There is cargo-asm but it's dead.

Now there is also cargo-show-asm.

Start with

cargo install cargo-show-asm

Pick a function from your project (you might need to specify a package for workspace projects)

cargo asm --lib

Pick something you want to see the asm code for from the list

cargo asm --lib "mini_std::math::lerp"

And get the results right in your terminal.

mini_std::math::lerp:
.Lfunc_begin25:
        .cfi_startproc
        movsd xmm3, qword ptr [rip + .LCPI25_0]
.Ltmp646:
        subsd xmm3, xmm2
        mulsd xmm3, xmm0
        mulsd xmm1, xmm2
.Ltmp647:
        addsd xmm3, xmm1
        movapd xmm0, xmm3
.Ltmp648:
        ret
.Ltmp649:
.Lfunc_end25:
        .size   mini_std::math::lerp, .Lfunc_end25-mini_std::math::lerp
        .cfi_endproc

Should support adding rust code, AT&T syntax, different targets, MacOS... Readme contains a bit more detailed usage information.