pacak /cargo-show-asm
cargo subcommand showing the assembly, LLVM-IR and MIR generated for Rust code
★ 998⑂ 52👁 4⑃ 364● 126▤ 0◈ 12
998
stars
52
forks
4
watchers
364
prs
126
issues
0
releases
12
discussions
README
cargo-show-asm A cargo subcommand that displays the Assembly, LLVM-IR, MIR and WASM generated for Rust source code. Install console $ cargo install cargo-show-asm Features - Platform support: - OS: Linux and macOS. Limited support for Windows - Rust: nightly and stable. - Architectures: x86, x86_64, aarch64, etc. - Cross-compilation support. - Displaying: - Assembly in Intel or AT&T syntax. - Corresponding Rust source code alongside assembly. - llvm-ir. - rustc MIR - Wasm code - llvm-mca analysis cargo asm Show the code rustc generates for any function Usage: cargo asm \[-p=_SPEC_\] \[_ARTIFACT_\] \[-M=_ARG_\]... \[_TARGET-CPU_\] \[--rust\] \[-c=_COUNT_\] \[--simplify\] \[--include-constants\] \[--json\] \[--this-workspace | --all-crates | --all-sources\] _OUTPUT-FORMAT_ \[--callers-of _REGEX_ \[_DEPTH_\]\] (--everything | \[_FUNCTION_\]... \[_INDEX_\]) Usage: 1. Focus on a single assembly producing target: text % cargo asm -p isin --lib here we are targeting lib in isin crate 2. Narrow down a function: text % cargo asm -p isin --lib from_ here "from_" is part of the function you are interested intel 3. Get the full results: text % cargo asm -p isin --lib isin::base36::from_alphanum Pick artifact for analysis: - --lib — Show results from library code - --test=_TEST_ — Show results from an integration test - --bench=_BENCH_ — Show results from a benchmark - --example=_EXAMPLE_ — Show results from an example - --bin=_BIN_ — Show results from a binary Cargo options - --manifest-path=_PATH_ — Path to Cargo.toml, defaults to one in current folder - --config=__ — Override a cargo configuration value - --target-dir=_DIR_ — Use custom target directory for generated artifacts, create if missing Uses environment variable CARGO_TARGET_DIR - --dry — Produce a build plan instead of actually building - --frozen — Requires Cargo.lock and cache to be up-to-date - --locked — Requires Cargo.lock to be up-to-date - --offline — Run without accessing the network - -q, --quiet — Do not print cargo log messages - --no-default-features — Do not activate default feature - --all-features — Activate all available features - -F, --features=_FEATURE_ — A feature to activate, can be used multiple times - --release — Compile in release mode (default) - --dev — Compile in dev mode - --profile=_PROFILE_ — Build for this specific profile, you can also use dev and release here Uses environment variable CARGO_SHOW_ASM_PROFILE - --target=_TRIPLE_ — Build for the target triple - -C=_FLAG_ — Codegen flags to rustc, see 'rustc -C help' for details - -Z=_FLAG_ — Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for detail
Top issues
#374target-cpu shouldn't default to native when cross-compiling13 comments · 2025-02-11#304Add the ability to strip data8 comments · 2024-09-19#360Cross-compile profile from different workspace7 comments · 2025-01-08#382Fails to find source file when cross-compiling due to mixed slashes6 comments · 2025-03-01#366LTO is not working, again5 comments · 2025-01-26#96open loop in uica4 comments · 2022-11-21#434Outpout of "cargo asm" does not match objdump of actual benchmark3 comments · 2025-12-06#410`cargo-show-asm` can misidentify functions in the assembly3 comments · 2025-08-09
Discussions
#386How to get Godbolt-like output?1 comments · 2025-03-10#343Square bracket numbers (lines of asm) doesn't correspond with what is actually generated1 comments · 2024-11-29#316Enable Link-Time Optimization (LTO) for cargo-show-asm itself1 comments · 2024-10-02#287Support `rustc_codegen_cranelift`2 comments · 2024-06-09#195Select the function to dump via fuzzy finder2 comments · 2023-08-10#181Compare / Diff between two version of Compilation4 comments · 2023-06-30#173see syscall in assembly in hello world3 comments · 2023-05-31#205Show asm for functions in a different crate from benchmark5 comments · 2023-05-26