There are some target-feature
s which can be used by adding parameter -C target-feature=+sse,+avx
to compiler. Available features can be shown using rustc --print target-features
. There are also some default activated features, for example, SSE on AMDx64 targets.
How can I look which features are activated by default? I cannot find this anywhere and they aren't printed when I run cargo build --release --verbose
.
Edit: Matěj Laitl reached me in GitHub and told me better way to do this.
You need run command rustc --print=cfg -C target-cpu=skylake
You can replace skylake
with your target CPU or native
.
I found that rustc --print target-features
prints results of llc -march=x86-64 -mcpu=x86-64 -mattr=help
(if you need other -march
, you can use llc --version).
I gave up looking for docs and written simple script which shows which attributes enabled.
There are 3 steps in usage of script:
rustc --print target-features
So, I got this features enabled by default at this moment:
feature fxsr
feature sse
feature sse2
With RUSTFLAGS='-C target-cpu=native' cargo run
I got this list:
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
Script is available as gist.
I did some research and it looks like default features are saved at TargetOption::features which is available as part of Target::option.
I'm not sure if you can ask compiler to print it somehow but you can lookup for default features via github serach (probably it doesn't cover all the places but I believe it gives a good hint for future).
Or you can start from another end and check your architecture's spec file here.
P.S. Default features for some platforms:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With