有一些 目标特性
可以通过将参数 -C target-feature=+sse,+avx
添加到编译器中进行使用。可以使用 rustc --print target-features
命令查看可用的特性。此外,还有一些默认激活的特性,例如在 AMDx64 目标上激活了 SSE。
我该如何查看默认激活了哪些特性?我无法在任何地方找到它们,并且当我运行 cargo build --release --verbose
命令时不会打印出来。
有一些 目标特性
可以通过将参数 -C target-feature=+sse,+avx
添加到编译器中进行使用。可以使用 rustc --print target-features
命令查看可用的特性。此外,还有一些默认激活的特性,例如在 AMDx64 目标上激活了 SSE。
我该如何查看默认激活了哪些特性?我无法在任何地方找到它们,并且当我运行 cargo build --release --verbose
命令时不会打印出来。
rustc --print=cfg -C target-cpu=skylake
,您可以将skylake
替换为您的目标CPU或native
。
我发现rustc --print target-features
打印llc -march=x86-64 -mcpu=x86-64 -mattr=help
的结果(如果您需要其他-march
,可以使用llc --version)。
我放弃查找文档,并编写了一个简单的脚本,显示启用的属性。
使用脚本有3个步骤:
rustc --print target-features
获取功能列表因此,我当前默认启用了以下功能:
feature fxsr
feature sse
feature sse2
使用 RUSTFLAGS='-C target-cpu=native' cargo run
命令,我得到了以下列表:
feature aes
feature avx
feature avx2
feature bmi2
feature fma
feature fxsr
feature lzcnt
feature popcnt
feature rdseed
feature sha
feature sse
feature sse2
feature sse3
feature sse4.1
feature sse4.2
feature ssse3
feature xsave
feature xsavec
feature xsaveopt
feature xsaves