cargo subcommand showing the assembly or llvm-ir generated for Rust code
See the codeA
cargosubcommand that displays the assembly or llvm-ir generated for Rust source code.
cargo install cargo-asm
To view the assembly of the function double_n in the module bar of the crate
lib_crate annotated with its corresponding Rust code, go to the crate's root
directory
git clone [email protected]:gnzlbg/cargo-asm.git
cd cargo-asm/cargo-asm-test/lib_crate
and type:
cargo asm lib_crate::bar::double_n --rust
which outputs:

(note: the source-code mapping information emitted by rustc after optimizations is sometimes far from perfect, like in this case. Take it with a grain of salt.)
To view the LLVM IR type
cargo llvm-ir lib_crate::bar::double_n
Platform support:
Displaying:
Querying:
foo:cargo asm crate::path::to::foo
foo of a type Foo (that is, Foo::foo):cargo asm crate::path::to::Foo::foo
bar of the trait Bar for the type Foo:cargo asm "<crate::path::to::Foo as crate::path::to::Bar>::bar"
To search for a function named foo in some path, one can just type cargo asm foo. The command will return a list of all similarly named functions
independently of the path.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 108)
1,026 followers · starred Dec 2018
1,943 followers · starred Nov 2021
347 followers · starred Mar 2018
50 followers · starred Oct 2019
cargo subcommand showing the assembly or llvm-ir generated for Rust code
See the codeA
cargosubcommand that displays the assembly or llvm-ir generated for Rust source code.
cargo install cargo-asm
To view the assembly of the function double_n in the module bar of the crate
lib_crate annotated with its corresponding Rust code, go to the crate's root
directory
git clone [email protected]:gnzlbg/cargo-asm.git
cd cargo-asm/cargo-asm-test/lib_crate
and type:
cargo asm lib_crate::bar::double_n --rust
which outputs:

(note: the source-code mapping information emitted by rustc after optimizations is sometimes far from perfect, like in this case. Take it with a grain of salt.)
To view the LLVM IR type
cargo llvm-ir lib_crate::bar::double_n
Platform support:
Displaying:
Querying:
foo:cargo asm crate::path::to::foo
foo of a type Foo (that is, Foo::foo):cargo asm crate::path::to::Foo::foo
bar of the trait Bar for the type Foo:cargo asm "<crate::path::to::Foo as crate::path::to::Bar>::bar"
To search for a function named foo in some path, one can just type cargo asm foo. The command will return a list of all similarly named functions
independently of the path.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 108)
1,026 followers · starred Dec 2018
1,943 followers · starred Nov 2021
347 followers · starred Mar 2018
50 followers · starred Oct 2019