#assembly #llvm-ir #cargo-subcommand #source #generated #optimization #display

app cargo-asm

A cargo subcommand that displays the generated assembly of Rust source code

17 releases

Uses old Rust 2015

0.1.16 Jun 7, 2018
0.1.15 Jun 7, 2018
0.1.14 May 24, 2018
0.1.13 Apr 10, 2018
0.1.10 Feb 27, 2018

#272 in Cargo plugins

Download history 136/week @ 2024-06-09 149/week @ 2024-06-16 184/week @ 2024-06-23 298/week @ 2024-06-30 169/week @ 2024-07-07 201/week @ 2024-07-14 194/week @ 2024-07-21 230/week @ 2024-07-28 259/week @ 2024-08-04 189/week @ 2024-08-11 321/week @ 2024-08-18 152/week @ 2024-08-25 182/week @ 2024-09-01 177/week @ 2024-09-08 176/week @ 2024-09-15 866/week @ 2024-09-22

1,420 downloads per month

MIT/Apache

89KB
2K SLoC

cargo-asm

crates.io version Travis build status Appveyor build status License

A cargo subcommand that displays the assembly or llvm-ir generated for Rust source code.

Install

cargo install cargo-asm

Example

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 git@github.com:gnzlbg/cargo-asm.git
cd cargo-asm/cargo-asm-test/lib_crate

and type:

cargo asm lib_crate::bar::double_n --rust

which outputs:

screenshot

(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

Features

  • Platform support:

    • OS: Linux, Windows, and MacOSX.
    • Rust: nightly and stable.
    • Architectures: x86, x86_64, arm, aarch64, powerpc, mips, sparc.
  • Displaying:

    • Assembly in Intel or AT&T syntax.
    • Corresponding Rust source code alongside assembly.
    • JSON AST for further processing.
    • LLVM-IR.
  • Querying:

    • functions, for example: foo:
    cargo asm crate::path::to::foo
    
    • inherent method, for example: foo of a type Foo (that is, Foo::foo):
    cargo asm crate::path::to::Foo::foo
    
    • trait method implementations, for example: bar of the trait Bar for the type Foo:
    cargo asm "<crate::path::to::Foo as crate::path::to::Bar>::bar"
    
    • generic functions, methods, ...

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.

License

This project is licensed under either of

at your option.

Contribution

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.

Dependencies

~4–12MB
~124K SLoC