naresh97 / trojan-rs

A Trojan proxy implementation written in Rust. Optimizing for size.
GNU General Public License v3.0
3 stars 0 forks source link

added feature flag 'vendored' for including openssl for native-tls #14

Closed cattyhouse closed 5 months ago

cattyhouse commented 5 months ago

with this feature enabled in Cargo.toml, it is able to cross compile musl static target with cargo-zigbuild

naresh97 commented 5 months ago

Thanks for the tip. I haven't considered compiling with musl instead of glibc. It'll be interesting to see what can of binary sizes I can get with it.

cattyhouse commented 5 months ago

it's about 4MB with feature socks5 only for aarch64-unknown-linux-musl

cattyhouse commented 5 months ago

it looks like to cross compile aarch64-unknown-linux-gnu, vendored is still needed

-tokio-native-tls = "0.3.1"
+tokio-native-tls = { version="0.3.1", features = ["vendored"] }
naresh97 commented 5 months ago

it's about 4MB with feature socks5 only for aarch64-unknown-linux-musl

I'm surprised. Did you compile with --release ? The current build with glibc is ~800KB

cattyhouse commented 5 months ago

when you use vendored, and do cross compile, openssl-sys is compiled into the binary, does not matter it is gnu or musl target.

naresh97 commented 5 months ago

Ah, now I understand. Hmm, you are using Cross to cross-compile? Maybe if you installed openssl in the build environment, then you don't need to use vendored ?

cattyhouse commented 5 months ago

Yeah, maybe. But i like a static linked binary that runs everywhere. I'll apply this patch for my use case.

naresh97 commented 5 months ago

Yes, that's a good option to have. I'll implement this as a feature flag too.