当-C target-cpu=native
标志被传递给rustc
时,我正在编写的程序运行得更快。我想给用户一种简单的、独立于平台的方式来在编译时启用它,所以我在Cargo.toml中添加了Cargo特性cpu_native = []
,并在我的项目中创建了这个Cargo配置:
[target.'cfg(cpu_native)']
rustflags = ["-C", "target-cpu=native"]
但是,这对我的程序没有任何影响,将--features cpu_native
传递给Cargo甚至不会触发重新编译。更改为以下Cargo配置确实会强制使用更快的指令重新编译:
[build]
rustflags = ["-C", "target-cpu=native"]
但是,这将使用默认的Cargo特性在target-cpu=native
中编译,这不是我想要的。从货运单上看,我想要的似乎是可能的,但我看不出我做错了什么。
发布于 2018-06-04 03:32:43
我不认为这是被支持的(目前?)。我增强了Cargo,以便打印出在解析时检查哪些配置标志:
[
Name("debug_assertions"),
Name("proc_macro"),
KeyPair("target_arch", "x86_64"),
KeyPair("target_endian", "little"),
KeyPair("target_env", ""),
KeyPair("target_family", "unix"),
KeyPair("target_os", "macos"),
KeyPair("target_pointer_width", "64"),
Name("unix"),
]
[target.'cfg(cpu_native)']
这是货物特性的错误语法;它通常是cfg(feature = "cpu_native")
。
https://stackoverflow.com/questions/50669828
复制相似问题