Why does rust use -O3 for release builds instead of -O2?

โš“ Rust    ๐Ÿ“… 2026-02-10    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 7      

surdeus

Hello! 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

Read full topic

๐Ÿท๏ธ Rust_feed