cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.21k stars 354 forks source link

binary size 3x larger #1504

Closed Sibz closed 1 month ago

Sibz commented 1 month ago

Checklist

Describe your issue

When building using cross, my binary size is significantly larger than when not.

cmd: cross build -r --target x86_64-pc-windows-gnu Run using docker in docker, my devcontainer using wsl on windows.

What target(s) are you cross-compiling for?

x86_64-pc-windows-gnu

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5

Example

cross build -r --target x86_64-pc-windows-gnu My binary built natively on a windows machine is 8mb using cross its 23mb.

Additional information / notes

Probably the difference between x86_64-pc-windows-msvc and x86_64-pc-windows-gnu targets

Emilgardis commented 1 month ago

Comparing binary sizes for -gnu and -msvc doesnt really make sense, msvc has a lot of dynamic linking, it also bundles debuginfo in a .pdb file.

See https://doc.rust-lang.org/cargo/reference/profiles.html for tuning artifacts, and https://github.com/johnthagen/min-sized-rust for more tips