What is Rust’s equivalent of compiling C++ with -O3?

100 points bran7230 29 comments

Hello everyone,

I’m building an Axum API and want to optimize the release binary for runtime performance. In C++, I would use flags such as -O3, and possibly -march=native.

I know cargo build --release enables optimizations, but are there additional Cargo profile settings or rustc flags worth using?

What settings do you typically use for production Rust web APIs?