Why does rust use -O3 for release builds instead of -O2?
โ Rust ๐ 2026-02-10 ๐ค surdeus ๐๏ธ 7Hello! I hope that you are doing well.
I recently found that that rustc by default uses the equivalent to -O3 when compiling for release builds. I find this odd as there is a lot of data on the internet that implies that -O2 sometimes beats -O3 because of less coad bloat, and -O3 can cause weird program behaviour, and possibly other things I canโt really remember right now.
Is there any deeper reason for choosing this flag for release builds?
Thanks!
3 posts - 3 participants
๐ท๏ธ Rust_feed