File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff 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`:
125122panic = " 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 )
You can’t perform that action at this time.
0 commit comments