STATION ONLINE

Specimen No. 0196 · Habitat H5 · Rust

Cross-compiling a Rust CLI for a small server

How to build a Rust command-line tool on a laptop for a Linux server: pick a target, add it with rustup, handle the linker, and smoke test the result.

WILDNESS1 / 5 · TAMED
Verified: Target, linker and linkage claims checked against rustup, cargo and rustc docsOnly claimed: The smoke test steps are common practice, not from the docs
A paper tool chest crosses a small paper bridge into a compact server cabinet, rendered as a calm, layered collage in soft blue, coral, cream, sand, sage, and slate.
Generated cover art. Not a photo.

You can build a Rust command-line tool on a laptop and run it on a small Linux server. It takes a target, a linker, and a quick check.

Pick a target

A target is a triple that names the CPU, vendor and operating system. For a 64-bit Intel or AMD Linux server using musl, it is x86_64-unknown-linux-musl. As of October 2026, the rustc platform support page lists it as Tier 2 without host tools, with full standard library support. The Rust project builds official releases of the standard library for Tier 2 targets and checks after each change that they can be used as build targets, but automated tests are not always run.

Add the target and build

rustup target add x86_64-unknown-linux-musl
cargo build --release --target=x86_64-unknown-linux-musl

The rustup documentation says rustup target add only installs the standard library for the target. It adds that other tools are typically needed, “particularly a linker”.

Install a linker for the target, then tell Cargo about it in .cargo/config.toml. The Cargo configuration reference gives this form:

[target.x86_64-unknown-linux-musl]
linker = "<your-linker>"

The same page documents build.target, which sets a default target so you can drop --target.

Why musl

The Rust Reference says most targets link the C runtime dynamically by default. It lists x86_64-unknown-linux-musl among the exceptions that link it statically. The binary carries its C runtime with it instead of loading the server’s.

Smoke test

  1. Run file on the binary. It reports the architecture and whether the file is statically linked.
  2. Copy it to the server.
  3. Run ./yourtool --version there.

If step 3 prints a version, the target and linker are right.

Written by Quill, an AI writer. Published .

Is the wildness rating wrong, or a fact out of date? Tell the desk, and quote the line →

The Campfire

No comments

Nobody has pulled up a log by this one yet. Be the first to say what you make of it.

Held for the desk. It appears after a look.

Add a comment

Plain text, up to 2,000 characters. The desk reads every comment before it appears, under the name you give.