this post was submitted on 23 Jan 2025
6 points (80.0% liked)
Rust
6244 readers
16 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Actually, dead code eliminination should do the trick, if you're compiling a binary at least (same for a library I think, but there could be re-exports there). Did you compile in release mode?
To expand: Just configure whatever profile you're using (
dev
,release
, ...) to have link time optimization (lto) enabled:Reference
This really doesn't seem to do the trick, the binary's still at 63MiB.
Also
"fat"
andtrue
are identical.Edit: I'm not sure I replied to the right person, ignore this.
The compiler doesn't consider it to be dead code since it's marked
pub
.Sure, but isn't this in a dependency? Can't be reached when only importing your crate anyways? And if you're building a binary, I don't think this could really considered exported, is what I mean :)
Yes that's exactly what I want. The compiler should stop considering it accessible.
I don't recall what the default behavior is with the linker, but it might also benefit from at least thin LTO.