如何全局配置 Cargo 配置文件选项? [英] How can I globally configure a Cargo profile option?

查看:36
本文介绍了如何全局配置 Cargo 配置文件选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Cargo,我可以设置项目的开发设置以使用并行代码生成:

With Cargo, I can set a project's development settings to use parallel code generation:

[profile.dev]
codegen-units = 8

根据文档,应该可以将其放入~/.cargo/config 将此设置应用于所有项目.这对我不起作用:似乎根本没有使用 .cargo/config 文件.有没有办法将这样的配置应用到我编译的每个项目?

According to the documentation, it should be possible to put this into ~/.cargo/config to apply this setting to all projects. This doesn't work for me: it seems that the .cargo/config file isn't used at all. Is there any way to apply such configuration to every project I compile?

推荐答案

您可以在 .cargo/config 文件中为所有构建或每个目标设置 rustflags.

You can set rustflags for all builds or per target in your .cargo/config file.

[build] # or [target.$triple]
rustflags = ["-Ccodegen-units=4"]

明确地说,这将为您的所有项目(由该 .cargo/config 覆盖)设置代码生成单元,而不管配置文件如何.

To be clear, this will set the codegen-units for all your projects (covered by this .cargo/config) regardless of profile.

为确保实际设置,您还可以在同一文件中设置详细输出.这将显示每个 rustc 命令以及货物调用的标志.

To make sure it's actually set, you can also set verbose output in the same file. This will show each rustc command with flags that cargo invokes.

[term]
verbose = true

这篇关于如何全局配置 Cargo 配置文件选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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