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?
post
replies:
I'm glad you figured it out.
I don't know what is it with new rustaceans and binary size, but many of them seem to be incessant on wasting time uselessly optimizing it, usually without actually understanding what they're doing, without gaining any relevant benefit, and possibly even causing relevant harm (e.g. degrading run-time performance for no good reason).
@Doods are you using release ? If you want the best dead-code elimination, you can also enable Link time optimisations (LTO): https://doc.rust-lang.org/cargo/reference/profiles.html#lto
replies:
permalink
fedilink
source
parent
hideshow 2 child comments
Yes, I am using both LTO and release mode, I can show you:
[profile.release]
opt-level = 3
codegen-units = 1
panic = "abort"
strip = true
lto = true
cargo build --release
all 15 comments