我如何根据货物特性选择性地传递rustc标志?

我如何根据货物特性选择性地传递rustc标志?,rust,rust-cargo,Rust,Rust Cargo,当-C target cpu=native标志传递给rustc时,我正在编写的程序运行得更快。我想为用户提供一种简单、独立于平台的方式,以便在编译时启用此功能,因此我在Cargo.toml中添加了Cargo功能cpu\u native=[],并在我的项目中创建了此Cargo配置: [target.'cfg(cpu_native)'] rustflags = ["-C", "target-cpu=native"] 但是,这对我的程序没有影响,将--特性cpu_native传递给Cargo甚至不会

-C target cpu=native
标志传递给
rustc
时,我正在编写的程序运行得更快。我想为用户提供一种简单、独立于平台的方式,以便在编译时启用此功能,因此我在Cargo.toml中添加了Cargo功能
cpu\u native=[]
,并在我的项目中创建了此Cargo配置:

[target.'cfg(cpu_native)']
rustflags = ["-C", "target-cpu=native"]
但是,这对我的程序没有影响,将
--特性cpu_native
传递给Cargo甚至不会触发重新编译。更改为以下货物配置会强制使用更快的指令重新编译:

[build]
rustflags = ["-C", "target-cpu=native"]

但是,这将使用默认的Cargo特性编译
targetcpu=native
,这不是我想要的。从货运手册上看,我想要的似乎是可能的,但我看不出我做错了什么。

我认为这还不受支持。我需要打印出解析时检查的配置标志:

[
名称(“调试_断言”),
名称(“proc_宏”),
密钥对(“target_arch”、“x86_64”),
密钥对(“target_endian”,“little”),
密钥对(“target_env”,“”),
密钥对(“目标_系列”、“unix”),
密钥对(“target_os”、“macos”),
密钥对(“目标指针宽度”,“64”),
名称(“unix”),
]
[target.cfg(cpu_native)]


这是货物功能的不正确语法;它通常是cfg(feature=“cpu_native”)

@Tim我不确定这是完全相同的问题,但有相同的关键字(“target”和“feature”)。