d4-format icon indicating copy to clipboard operation
d4-format copied to clipboard

Static d4tools binary

Open oyvinev opened this issue 9 months ago • 1 comments

I think d4tools would gain a lot more traction if it was available as a static binary.

I have very little experience with rust, but was able to generate a static binary like this:

static-binary.sh:

#!/bin/bash

apt update
apt install -y musl-tools
rustup target add x86_64-unknown-linux-musl
cargo build --target=x86_64-unknown-linux-musl --profile release

Executed from the d4-format root directory like:

docker run -it -v $(pwd):$(pwd) --workdir $(pwd) rust:1.84-bookworm ./static-binary.sh

Thoughts?

Edit: Ok, the binary is 129MB 😅

Edit2:

$ ldd ./target/x86_64-unknown-linux-musl/release/d4tools
	statically linked

oyvinev avatar Feb 12 '25 09:02 oyvinev

I'll add this for the next release. We can probably reduce with some of these: https://github.com/johnthagen/min-sized-rust

brentp avatar Feb 12 '25 22:02 brentp