{"id":13478562,"url":"https://github.com/pacak/cargo-show-asm","last_synced_at":"2025-05-14T03:03:40.634Z","repository":{"id":39848792,"uuid":"465951193","full_name":"pacak/cargo-show-asm","owner":"pacak","description":"cargo subcommand showing the assembly, LLVM-IR and MIR generated for Rust code ","archived":false,"fork":false,"pushed_at":"2025-04-18T22:22:02.000Z","size":891,"stargazers_count":802,"open_issues_count":19,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-08T18:58:33.804Z","etag":null,"topics":["assembly","cargo","cargo-plugin","cargo-subcommand","llvm-ir","optimization","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pacak.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["pacak"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2022-03-04T02:12:53.000Z","updated_at":"2025-05-05T17:06:01.000Z","dependencies_parsed_at":"2023-02-18T16:46:01.535Z","dependency_job_id":"e5f32a8f-81ed-4f48-aba4-112b6388feab","html_url":"https://github.com/pacak/cargo-show-asm","commit_stats":{"total_commits":307,"total_committers":18,"mean_commits":"17.055555555555557","dds":0.2931596091205212,"last_synced_commit":"3594acbde4dce66914b138687488b80dca5a6bbf"},"previous_names":[],"tags_count":71,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacak%2Fcargo-show-asm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacak%2Fcargo-show-asm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacak%2Fcargo-show-asm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacak%2Fcargo-show-asm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pacak","download_url":"https://codeload.github.com/pacak/cargo-show-asm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059474,"owners_count":22007767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","cargo","cargo-plugin","cargo-subcommand","llvm-ir","optimization","rust"],"created_at":"2024-07-31T16:01:58.745Z","updated_at":"2025-05-14T03:03:40.588Z","avatar_url":"https://github.com/pacak.png","language":"Rust","funding_links":["https://github.com/sponsors/pacak"],"categories":["Rust","Programming Languages"],"sub_categories":[],"readme":"# cargo-show-asm\n\nA cargo subcommand that displays the Assembly, LLVM-IR, MIR and WASM generated for Rust source code.\n\n# Install\n\n```console\n$ cargo install cargo-show-asm\n```\n\n# Features\n\n- Platform support:\n\n  - OS: Linux and macOS. Limited support for Windows\n  - Rust: nightly and stable.\n  - Architectures: `x86`, `x86_64`, `aarch64`, etc.\n  - Cross-compilation support.\n\n- Displaying:\n\n  - Assembly in Intel or AT\u0026T syntax.\n  - Corresponding Rust source code alongside assembly.\n  - llvm-ir.\n  - rustc MIR\n  - Wasm code\n  - llvm-mca analysis\n\n# cargo asm\n\nShow the code rustc generates for any function\n\n**Usage**: **`cargo asm`** \\[**`-p`**=_`SPEC`_\\] \\[_`ARTIFACT`_\\] \\[**`-M`**=_`ARG`_\\]... \\[_`TARGET-CPU`_\\] \\[**`--rust`**\\] \\[**`-c`**=_`COUNT`_\\] \\[**`--simplify`**\\] \\[**`--include-constants`**\\] \\[**`--this-workspace`** | **`--all-crates`** | **`--all-sources`**\\] _`OUTPUT-FORMAT`_ \\[**`--everything`** | _`FUNCTION`_ \\[_`INDEX`_\\]\\]\n\n Usage:\n 1. Focus on a single assembly producing target:\n\n  ```text\n   % cargo asm -p isin --lib   # here we are targeting lib in isin crate\n\n\n  ```\n 2. Narrow down a function:\n\n  ```text\n   % cargo asm -p isin --lib from_ # here \"from_\" is part of the function you are interested intel\n\n\n  ```\n 3. Get the full results:\n\n  ```text\n   % cargo asm -p isin --lib isin::base36::from_alphanum\n  ```\n\n\n**Pick artifact for analysis:**\n- **`    --lib`** \u0026mdash; \n  Show results from library code\n- **`    --test`**=_`TEST`_ \u0026mdash; \n  Show results from an integration test\n- **`    --bench`**=_`BENCH`_ \u0026mdash; \n  Show results from a benchmark\n- **`    --example`**=_`EXAMPLE`_ \u0026mdash; \n  Show results from an example\n- **`    --bin`**=_`BIN`_ \u0026mdash; \n  Show results from a binary\n\n\n\n**Cargo options**\n- **`    --manifest-path`**=_`PATH`_ \u0026mdash; \n  Path to Cargo.toml, defaults to one in current folder\n- **`    --config`**=_`\u003cKEY=VALUE\u003e`_ \u0026mdash; \n  Override a cargo configuration value\n- **`    --target-dir`**=_`DIR`_ \u0026mdash; \n  Use custom target directory for generated artifacts, create if missing\n   \n  Uses environment variable **`CARGO_TARGET_DIR`**\n- **`    --dry`** \u0026mdash; \n  Produce a build plan instead of actually building\n- **`    --frozen`** \u0026mdash; \n  Requires Cargo.lock and cache to be up-to-date\n- **`    --locked`** \u0026mdash; \n  Requires Cargo.lock to be up-to-date\n- **`    --offline`** \u0026mdash; \n  Run without accessing the network\n- **`-q`**, **`--quiet`** \u0026mdash; \n  Do not print cargo log messages\n- **`    --no-default-features`** \u0026mdash; \n  Do not activate `default` feature\n- **`    --all-features`** \u0026mdash; \n  Activate all available features\n- **`-F`**, **`--features`**=_`FEATURE`_ \u0026mdash; \n  A feature to activate, can be used multiple times\n- **`    --release`** \u0026mdash; \n  Compile in release mode (default)\n- **`    --dev`** \u0026mdash; \n  Compile in dev mode\n- **`    --profile`**=_`PROFILE`_ \u0026mdash; \n  Build for this specific profile, you can also use `dev` and `release` here\n   \n  Uses environment variable **`CARGO_SHOW_ASM_PROFILE`**\n- **`    --target`**=_`TRIPLE`_ \u0026mdash; \n  Build for the target triple\n- **`-C`**=_`FLAG`_ \u0026mdash; \n  Codegen flags to rustc, see 'rustc -C help' for details\n- **`-Z`**=_`FLAG`_ \u0026mdash; \n  Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details\n\n\n\n**Postprocessing options:**\n- **`    --rust`** \u0026mdash; \n  Print interleaved Rust code\n- **`-c`**, **`--context`**=_`COUNT`_ \u0026mdash; \n  Include other called functions, recursively, up to COUNT depth\n   \n  [default: 0]\n- **`    --color`** \u0026mdash; \n  Enable color highlighting\n- **`    --no-color`** \u0026mdash; \n  Disable color highlighting\n- **`    --full-name`** \u0026mdash; \n  Include full demangled name instead of just prefix\n- **`    --short-name`** \u0026mdash; \n  Include demangled names without hash suffix (default)\n- **`    --keep-mangled`** \u0026mdash; \n  Do not demangle symbol names\n- **`-K`**, **`--keep-labels`** \u0026mdash; \n  Keep all the original labels\n- **`-B`**, **`--keep-blanks`** \u0026mdash; \n  Strip redundant labels, but keep spaces in their place\n- **`-R`**, **`--reduce-labels`** \u0026mdash; \n  Strip redundant labels entirely\n- **`-v`**, **`--verbose`** \u0026mdash; \n  more verbose output, can be specified multiple times\n- **`-s`**, **`--silent`** \u0026mdash; \n  print less user-forward information to make consumption by tools easier\n- **`    --simplify`** \u0026mdash; \n  Try to strip some of the non-assembly instruction information\n- **`    --include-constants`** \u0026mdash; \n  Include sections containing string literals and other constants\n- **`-b`**, **`--keep-blank`** \u0026mdash; \n  Keep blank lines\n- **`    --this-workspace`** \u0026mdash; \n  Show rust sources from current workspace only\n- **`    --all-crates`** \u0026mdash; \n  Show rust sources from current workspace and from rust registry\n- **`    --all-sources`** \u0026mdash; \n  Show all the rust sources including stdlib and compiler\n\n\n\n**Pick output type:**\n- **`    --asm`** \u0026mdash; \n  Show assembly\n- **`    --disasm`** \u0026mdash; \n  Disassembly binaries or object files\n- **`    --llvm`** \u0026mdash; \n  Show llvm-ir\n- **`    --llvm-input`** \u0026mdash; \n  Show llvm-ir before any LLVM passes\n- **`    --mir`** \u0026mdash; \n  Show MIR\n- **`    --wasm`** \u0026mdash; \n  Show WASM, needs wasm32-unknown-unknown target installed\n- **`    --mca`** \u0026mdash; \n  Show llvm-mca anasysis\n- **`    --intel`** \u0026mdash; \n  Use Intel style for assembly\n- **`    --att`** \u0026mdash; \n  Use AT\u0026T style for assembly\n\n\n\n**Pick item to display from the artifact**\n- **`    --everything`** \u0026mdash; \n  Dump the whole file\n- _`FUNCTION`_ \u0026mdash; \n  Dump a function with a given name, filter functions by name\n- _`INDEX`_ \u0026mdash; \n  Select specific function when there's several with the same name\n\n\n\n**Available options:**\n- **`-p`**, **`--package`**=_`SPEC`_ \u0026mdash; \n  Package to use, defaults to a current one,\n\n  required for workspace projects, can also point to a dependency\n- **`    --file`**=_`PATH`_ \u0026mdash; \n  Disassemble or process this file instead of calling cargo,\nrequires cargo-show-asm to be compiled with disasm feature\n\n  You can specify executable, rlib or an object file\n- **`-M`**, **`--mca-arg`**=_`ARG`_ \u0026mdash; \n  Pass parameter to llvm-mca for mca targets\n- **`    --native`** \u0026mdash; \n  Optimize for the CPU running the compiler\n- **`    --target-cpu`**=_`CPU`_ \u0026mdash; \n  Optimize code for a specific CPU, see 'rustc --print target-cpus'\n- **`-h`**, **`--help`** \u0026mdash; \n  Prints help information\n- **`-V`**, **`--version`** \u0026mdash; \n  Prints version information\n\n\n\n\nYou can start by running `cargo asm` with no parameters - it will suggest how to narrow the\nsearch scope - for workspace crates you need to specify a crate to work with, for crates\ndefining several targets (lib, binaries, examples) you need to specify exactly which target to\nuse. In a workspace `cargo asm` lists only workspace members as suggestions but any crate from\nworkspace tree is available.\n\nOnce `cargo asm` focuses on a single target it will run rustc producing assembly file and will\ntry to list of available public functions:\n\n```console,ignore\n$ cargo asm --lib\nTry one of those\n\"\u003c\u0026T as core::fmt::Display\u003e::fmt\" [17, 12, 12, 12, 12, 19, 19, 12]\n\"\u003c\u0026mut W as core::fmt::Write\u003e::write_char\" [20]\n\"\u003c\u0026mut W as core::fmt::Write\u003e::write_fmt\" [38]\n\"\u003c\u0026mut W as core::fmt::Write\u003e::write_str\" [90]\n\"\u003cF as nom::internal::Parser\u003cI,O,E\u003e\u003e::parse\" [263]\n# ...\n```\n\nName in quotes is demangled rust name, numbers in square brackets represent number of lines\nin asm file. Function with the same name can be present in several instances.\n\nSpecifying exact function name or a uniquely identifying part of it will print its assembly code\n\n```console,ignore\n$ cargo asm --lib \"cargo_show_asm::opts::focus::{{closure}}\"\n```\nTo pick between different alternatives you can either specify the index\n\n```console,ignore\n$ cargo asm --lib \"cargo_show_asm::opts::focus::{{closure}}\" 2\n```\nOr start using full names with hex included:\n\n```console,ignore\n$ cargo asm --lib --full-name\n# ...\n$ cargo asm --lib \"once_cell::imp::OnceCell\u003cT\u003e::initialize::h9c5c7d5bd745000b\"\n```\n\n`cargo-show-asm` comes with a built-in search function. Just pass partial name\ninstead of a full one and only matching functions will be listed\n\n```console\n$ cargo asm --lib Debug\n```\n\n# My function isn't there!\n\n`rustc` will only generate the code for your function if it knows what type it is, including\ngeneric parameters and if it is exported (in case of a library) and not inlined (in case of a\nbinary, example, test, etc.). If your function takes a generic parameter - try making a monomorphic\nwrapper around it and make it `pub` and `#[inline(never)]`.\n\nAlternatively if your function is too small - `rustc` might decide to inline it automatically\nwith the same result. Marking it with `#[inline(never)]` fixes this problem.\nSee https://github.com/rust-lang/rust/pull/116505 for more details\n\n# Include related functions?\n\nSo suppose you have a function `foo` that calls some other function - `bar`. With `--context N`\nor it's short variant `-c N` you can ask cargo-show-asm to include body of bar to the input.\nThis is done recursively up to N steps. See https://github.com/pacak/cargo-show-asm/issues/247\n\n\n# What about `cargo-asm`?\n\n`cargo-asm` is not maintained: \u003chttps://github.com/gnzlbg/cargo-asm/issues/244\u003e. This crate is a reimplementation which addresses a number of its shortcomings, including:\n\n* `cargo-asm` recompiles everything every time with 1 codegen unit, which is slow and also not necessarily what is in your release profile. `cargo-show-asm` avoids that.\n\n* Because of how `cargo-asm` handles demangling the output looks like asm but isn't actually asm. It contains a bunch of extra commas which makes reusing it more annoying.\n\n* `cargo-asm` always uses colors unless you pass a flag while `cargo-show-asm` changes its default behavior if output is not sent to a terminal.\n\n* `cargo-show-asm` also supports MIR (note that the formatting of human-readable MIR is not stable).\n\n# Shell completion\n\n`cargo-asm` comes with shell completion generated by [`bpaf`](https://crates.io/crates/bpaf),\nuse one of the lines below and place it into the place right for your shell.\n\n```console\n$ cargo-asm --bpaf-complete-style-bash\n$ cargo-asm --bpaf-complete-style-zsh\n$ cargo-asm --bpaf-complete-style-fish\n$ cargo-asm --bpaf-complete-style-elvish\n```\n\nYou'll need to use it as `cargo-asm` command rather than `cargo asm` to take advantage of it.\n\n\n# Colorful line parser output\n\nYou can install `cargo-show-asm` with one of two features to get prettier command line\n```console\ncargo install cargo-show-asm -F bright-color\ncargo install cargo-show-asm -F dull-color\n```\n\n# License\nThis project is licensed under either of\n\n* Apache License, Version 2.0, (LICENSE-APACHE or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n* MIT license (LICENSE-MIT or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this project by you, as defined in the Apache-2.0 license,\nshall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacak%2Fcargo-show-asm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpacak%2Fcargo-show-asm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacak%2Fcargo-show-asm/lists"}