💾 Archived View for gemini.ctrl-c.club › ~coolcoder613 › portlog.gmi captured on 2024-03-21 at 15:30:22. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
I wanted to build the smallest possible binary of portlog, because... I like small binaries?
So, after much trial and error, my build command looked like this:
RUSTFLAGS="-C target-feature=+crt-static -Zlocation-detail=none" cargo +nightly build -Z build-std=std,panic_abort \ --target x86_64-unknown-linux-gnu --release
And in `Cargo.toml`:
[profile.release] lto = true opt-level = "z" strip=true
And on the binary:
upx --best portlog
Final result:
coolcoder613@coolcoder613-ThinkPad-T430:~/Repos/portlog$ ls -lh target/x86_64-unknown-linux-gnu/release/portlog -rwxr-xr-x 1 501 dialout 224K Feb 9 16:14 target/x86_64-unknown-linux-gnu/release/portlog coolcoder613@coolcoder613-ThinkPad-T430:~/Repos/portlog$ ls -l target/x86_64-unknown-linux-gnu/release/portlog -rwxr-xr-x 1 501 dialout 229100 Feb 9 16:14 target/x86_64-unknown-linux-gnu/release/portlog
Original file:
coolcoder613@coolcoder613-ThinkPad-T430:~/Repos/portlog$ ls -lh target/x86_64-unknown-linux-gnu/debug/portlog -rwxr-xr-x 1 501 dialout 11M Feb 9 16:25 target/x86_64-unknown-linux-gnu/debug/portlog coolcoder613@coolcoder613-ThinkPad-T430:~/Repos/portlog$ ls -l target/x86_64-unknown-linux-gnu/debug/portlog -rwxr-xr-x 1 501 dialout 10717312 Feb 9 16:25 target/x86_64-unknown-linux-gnu/debug/portlog