add emit_asm aspect to view rustc assembly output#21
Open
oliverlee wants to merge 1 commit into
Open
Conversation
Introduces a Bazel aspect that compiles Rust targets with `--emit=asm` and demangles the output via `rustfilt`, producing a `.s` file in an `asm_files` output group. The aspect forces `codegen-units=1` so rustc emits a single .s file with a predictable name rather than per-CGU files whose count isn't known at action declaration time. DWARF is stripped (`debuginfo=0`) to reduce noise, and `--sysroot` is derived from the rustc executable path. An `//tools/emit_asm:opt` string flag allows overriding the optimization level independently of the build configuration. `rust_test` targets are handled correctly via `--test` rather than `--crate-type bin`. On the module side, `bazel_skylib` is added as a dev dep for `string_flag`, and an isolated `bindeps` crate extension pulls in `rustfilt` as a host binary built against a nightly `rust_host_tools` toolchain. ``` bazel build //path/to:target \ --aspects=//tools/emit_asm:aspect.bzl%emit_asm_aspect \ --output_groups=asm_files \ --//tools/emit_asm:opt=3 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a Bazel aspect that compiles Rust targets with
--emit=asmand demangles the output viarustfilt, producing a.sfile in anasm_filesoutput group.The aspect forces
codegen-units=1so rustc emits a single .s file with a predictable name rather than per-CGU files whose count isn't known at action declaration time. DWARF is stripped (debuginfo=0) to reduce noise, and--sysrootis derived from the rustc executable path. An//tools/emit_asm:optstring flag allows overriding the optimization level independently of the build configuration.rust_testtargets are handled correctly via--testrather than--crate-type bin.On the module side,
bazel_skylibis added as a dev dep forstring_flag, and an isolatedbindepscrate extension pulls inrustfiltas a host binary built against a nightlyrust_host_toolstoolchain.