Add cargo linux to build a static Linux binary from any OS

Builds for x86_64-unknown-linux-musl with rust-lld. The result is fully
static, so the same file runs on Void (glibc or musl) and Fedora. The
linker is set inside the alias, not globally, so native builds on
Void-musl keep their usual linker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
skkeyeandClaude Opus 5.5 committed 2026-09-24 02:59:23 -04:00
1 parent 235c4f0ad5
commit c21b720eea
1 file changed
+8
+8
View File
@@ -6,3 +6,11 @@ rustflags = ["-C", "target-feature=+crt-static"]
[alias]
# `cargo lint`: the strict check to run before committing.
lint = "clippy --all-targets -- -D warnings"
# `cargo linux`: build a Linux binary from any OS (needs, once:
# `rustup target add x86_64-unknown-linux-musl`). It's fully static, so the
# same file runs on Void (glibc or musl), Fedora and other distributions:
# target/x86_64-unknown-linux-musl/release/skyshift
linux = [
"build", "--release", "--target", "x86_64-unknown-linux-musl",
"--config", "target.x86_64-unknown-linux-musl.linker = 'rust-lld'",
]