Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Rust have an equivalent of -Ofast -march=native? [duplicate]

Tags:

rust

Does Rust have an equivalent of GCC's C CFLAGS="-Ofast -march=native" compiler optimizations?

like image 909
belteshazzar Avatar asked Oct 25 '25 01:10

belteshazzar


1 Answers

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.

like image 98
Sven Marnach Avatar answered Oct 28 '25 05:10

Sven Marnach