Skip to content

Commit 9285dda

Browse files
committed
Add note about opt-level surprising results
1 parent e413cf9 commit 9285dda

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ which optimizes the binary for **speed**. To instruct Cargo to optimize for mini
6565
opt-level = "z" # Optimize for size.
6666
```
6767

68+
Note that in some cases the `"s"` level may result in a smaller binary than `"z"`, as explained in
69+
the
70+
[`opt-level` documentation](https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level):
71+
72+
> It is recommended to experiment with different levels to find the right balance for your project.
73+
There may be surprising results, such as ... the `"s"` and `"z"` levels not being necessarily
74+
smaller.
75+
6876
# Enable Link Time Optimization (LTO)
6977

7078
![Minimum Rust: 1.0](https://img.shields.io/badge/Minimum%20Rust%20Version-1.0-brightgreen.svg)

0 commit comments

Comments
 (0)