Why does Rust generate 10x as much unoptimized assembly as GCC?

The debug profile with debug assertions can be as optimized as the release profile, and the release profile can have debug info. You can mix and match all options in [profiles.*].

You can have e.g. debug = true + debug-assertions = true + opt-level=z.

What Rust doesn't expose yet is opt-level=g that is like opt-level=2, but without a few optimizations that reduce precision of debug info.

4 Likes