seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.5k stars 1.06k forks source link

How to reduce binary size? #2145

Closed normalllll closed 1 month ago

normalllll commented 4 months ago
[lib]
crate-type = ["dylib"]

[profile.release]
#opt-level = "z"
codegen-units = 1
strip = true
lto = true
panic = 'abort'

[dependencies]
reqwest = { version = "0.11.24", default-features = false, features = ["http3", "blocking", "rustls-tls", "gzip"] }

The dll binary file compiled using only the dylib of the reqwest crate is too large (5.91MB). How to reduce its size?

valaphee commented 1 month ago

For example you could use the native-tls feature instead of rustls-tls, as it doesn't include a whole tls stack. HTTP3 is also fairly large because of QUIC.

Would be interesting to see how https://github.com/seanmonstar/reqwest/issues/2052 would affect the size.

valaphee commented 1 month ago

With WinHTTP the size shrunk from ~6 MB to ~2.7 MB, but it's probably possible to get all the way down to 1 MB