Skip to content

Instantly share code, notes, and snippets.

@zhangyuan
Last active October 24, 2021 16:49
Show Gist options
  • Save zhangyuan/d42f4bdc0895451b381062188b39c9b9 to your computer and use it in GitHub Desktop.
Save zhangyuan/d42f4bdc0895451b381062188b39c9b9 to your computer and use it in GitHub Desktop.
Cross-compilation for Linux release from Mac OSX
  1. Install musl-cross
brew install FiloSottile/musl-cross/musl-cross
  1. Add x86_64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl
  1. Add the following linker configuration to .cargo/config
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
  1. Compile the command below:
CC=x86_64-linux-musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment