From c21b720eea765c947ba3044f60bf31157bd89e6b Mon Sep 17 00:00:00 2001 From: Skkeye Date: Thu, 24 Sep 2026 02:59:23 -0400 Subject: [PATCH] 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 --- .cargo/config.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 15fab5a..20dba1b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -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'", +]