1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| ## 1. 安装linux编译工具链
$ brew install FiloSottile/musl-cross/musl-cross
## 2. 创建musl-gcc
$ ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc
## 3. 添加linux平台目标
$ rustup target add x86_64-unknown-linux-musl
## 4. 修改配置文件
$ cat <<EOF >> ~/.cargo/config
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
EOF
## 5. 编译
$ cargo build --release --target x86_64-unknown-linux-musl
|