snippetrustCritical
How to get assembly output from building with Cargo?
Viewed 0 times
withhowfromoutputbuildingassemblycargoget
Problem
While I've seen docs on using
Is there a way to run Cargo that writes out assembly files?
rustc directly to output assembly, having to manually extract commands used by Cargo and edit them to write assembly is tedious.Is there a way to run Cargo that writes out assembly files?
Solution
You can use Cargo's
For optimized assembly:
If you see multiple
cargo rustc command to send arguments to rustc directly:cargo rustc -- --emit asm
ls target/debug/deps/-.sFor optimized assembly:
cargo rustc --release -- --emit asm
ls target/release/deps/-.sIf you see multiple
--.rcgu.s files instead of a -.s file, disable incremental compilation by setting the environment variable CARGO_INCREMENTAL=0.Code Snippets
cargo rustc -- --emit asm
ls target/debug/deps/<crate_name>-<hash>.scargo rustc --release -- --emit asm
ls target/release/deps/<crate_name>-<hash>.sContext
Stack Overflow Q#39219961, score: 118
Revisions (0)
No revisions yet.