哪些目标功能默认使用rustc?
有一些target-features 可以通过向-C target-feature=+sse,+avx编译器添加参数来使用。可用功能可以使用 显示rustc --print target-features。还有一些默认激活的功能,例如 AMDx64 目标上的 SSE。
如何查看默认激活了哪些功能?我在任何地方都找不到它,并且当我运行cargo build --release --verbose.
回答
编辑: Mat?j Laitl 在GitHub 上找到我并告诉我更好的方法来做到这一点。您需要运行命令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 - 将其放入脚本中(对于 x86-64 目标,它具有 2020-12-06 的实际值)。
- 运行脚本。
因此,我此时默认启用了此功能:
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
脚本可作为gist 使用。