Does Rust have an equivalent of GCC's C CFLAGS="-Ofast -march=native" compiler optimizations?
To optimise for the native CPU, you can use
RUSTFLAGS="-C target-cpu=native"
I think LLVM optimises for speed (or more specifically, throughput) by default; I couldn't really find documentation on this, but this is what the source code suggests.
You should be able to select a different cost model using e.g.
RUSTFLAGS="-C target-cpu=native -C llvm-args='-cost-kind=latency'"
but I haven't tried this, nor do I know any details about the effect of this switch.
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