Skip to content

Commit 6ee73e3

Browse files
authored
Update README.md
1 parent c6a6bbd commit 6ee73e3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ opt-level = "z" # Optimize for size.
7272
> It is recommended to experiment with different levels to find the right balance for your project.
7373
> There may be surprising results, such as ... the `"s"` and `"z"` levels not being necessarily
7474
> smaller.
75-
>
76-
> When using `"z"`, you can also try the `-Zshare-generics=false` rustc flag with the nightly toolchain
77-
> (via RUSTFLAGS).
7875
7976
# Enable Link Time Optimization (LTO)
8077

@@ -125,6 +122,22 @@ Enable this in `Cargo.toml`:
125122
panic = "abort"
126123
```
127124

125+
# (Un)Share Generics
126+
127+
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)
128+
129+
Currently Rust enables `-Zshare-generics` implicitly for opt-level `"s"` and `"z"`.
130+
Just like `"s"` vs `"z"`, this can sometimes be helpful and sometimes cause larger binaries.
131+
132+
To avoid sharing generics, use the unstable
133+
`rustc` `-Zshare-generics` flag:
134+
flag:
135+
136+
```bash
137+
$ RUSTFLAGS="-Zshare-generics=false" cargo +nightly build --release
138+
```
139+
140+
128141
# Remove Location Details
129142

130143
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)

0 commit comments

Comments
 (0)