如何从使用Cargo构建的装配中获取装配输出? [英] How to get assembly output from building with Cargo?

查看:108
本文介绍了如何从使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆