-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Size issues (again?) #489
Comments
I built a simple script to test sizes over time. Nothing terribly exciting. Without specifying options, the size changes very little. Output below shows only size changes and removed any failed builds. Tested between v0.1.4 and v0.3.22 which was output from
Disabling default features has about the same effect
#!/usr/bin/env bash
BIN_NAME=test_opts
function build() {
cp Cargo.template Cargo.toml
rm -f Cargo.lock
echo "structopt = {version =\"=$1\", default-features=false}" >> Cargo.toml
echo -n "Build $1 size is "
if `cargo build --release -q 2>/dev/null`; then
ls -s target/release/$BIN_NAME
else
echo "unknown (build failed)"
fi
}
for version in `cat versions | sort -V`; do
build $version
done |
Strange, no idea after a quick look at the code, the features seems well forwarded to clap. Do you see the same behavior if using only clap? |
cargo bloat with default-features:
with default-features = false:
Everything seems fine. The features don't really minimize the binary size. |
Default features being off results in a 0.1MiB increase in your test despite things like |
Clap v2 is not really size optimized, so the code used in place of the external library is not a size gain. Nothing structopt can do. You can also try clap master (future v3) than embeds directly structopt. The clap features came at a size cost. Sorry to see you leaving structopt, but there is alternatives because there is different needs :-) |
Absolutely. I only mention it so you have some feedback. Thanks!
|
I've been playing around with getting my final binaries smaller and after finding #46 I'm somewhat confused about why structopts is the biggest contributor to my binary size after the standard library. What's a little funny is turning default features off grows the final binary so there's nowhere to go but up? This is all on Linux with 1.56.0-nightly but I see the same results in stable.
Here's some experiments:
The code for this:
The text was updated successfully, but these errors were encountered: