While I\'ve seen docs on using rustc directly to output assembly, having to manually extract commands used by Cargo and edit them to write assembly is tedious.<
In addition to kennytm's answer, you can also use the RUSTFLAGS environment variable and use the standard cargo commands:
RUSTFLAGS="--emit asm" cargo build
cat target/debug/deps/project_name-hash.s
Or in release mode (with optimizations):
RUSTFLAGS="--emit asm" cargo build --release
cat target/release/deps/project_name-hash.s
You can pass different values to the --emit parameter, including (but not limited to):
mir (Rust intermediate representation)llvm-ir (LLVM intermediate representation)llvm-bc (LLVM byte code)asm (assembly)