如何从使用Cargo构建的装配中获取装配输出? [英] How to get assembly output from building with Cargo?
问题描述
虽然我看过有关直接使用rustc
来输出程序集的文档,但是必须手动提取Cargo使用的命令并对其进行编辑以编写程序集很麻烦.
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.
有没有一种方法可以运行Cargo来写出装配文件?
Is there a way to run Cargo that writes out assembly files?
推荐答案
您可以使用Cargo的cargo rustc
命令将参数直接发送到rustc
:
You can use Cargo's cargo rustc
command to send arguments to rustc
directly:
cargo rustc -- --emit asm
ls target/debug/deps/<crate_name>-<hash>.s
对于优化的装配:
cargo rustc --release -- --emit asm
ls target/release/deps/<crate_name>-<hash>.s
如果看到多个<crate_name>-<hash>-<hash>.rcgu.s
文件而不是<crate_name>-<hash>.s
文件,请通过设置环境变量CARGO_INCREMENTAL=0
禁用增量编译.
If you see multiple <crate_name>-<hash>-<hash>.rcgu.s
files instead of a <crate_name>-<hash>.s
file, disable incremental compilation by setting the environment variable CARGO_INCREMENTAL=0
.
这篇关于如何从使用Cargo构建的装配中获取装配输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!