Skip to content

Commit 5b268e9

Browse files
committed
Recommend -Zshare-generics=false
opt-level=z|s implicitly enables -Zshare-generics=true, which sometimes has a positive and sometimes has a negative impact. Update README.md
1 parent f1db29c commit 5b268e9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ Enable this in `Cargo.toml`:
122122
panic = "abort"
123123
```
124124

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+
125141
# Remove Location Details
126142

127143
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)
@@ -438,4 +454,4 @@ use std::alloc::System;
438454

439455
#[global_allocator]
440456
static A: System = System;
441-
```
457+
```

0 commit comments

Comments
 (0)