I tried this way.
1.rustup target add x86_64-unknown-linux-musl
2.brew install FiloSottile/musl-cross/musl-cross
3. vi ~/.cargo/config , and add
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
4.CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" cargo build --release --target=x86_64-unknown-linux-musl
But it not work.
error[E0425]: cannot find value `SO_INCOMING_CPU` in crate `libc`
--> /Users/zhpan/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.4.0/src/sys/unix.rs:1201:69
|
1201 | getsockopt::<c_int>(self.inner, libc::SOL_SOCKET, libc::SO_INCOMING_CPU)
| ^^^^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `SO_INCOMING_CPU` in crate `libc`
--> /Users/zhpan/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.4.0/src/sys/unix.rs:1217:23
|
1217 | libc::SO_INCOMING_CPU,
| ^^^^^^^^^^^^^^^ not found in `libc`
Compiling hostname v0.3.1
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
error: could not compile `socket2`
To learn more, run the command again with --verbose.
It failed with build crate socket2.
How to solve this problem, can you help me?
But I try to use a ubuntu image based ecs on aliyun to build it, it have another error. Only centos can build it? I developed it on mac. I am so confused with the reason. I am a golang programmer before. It's easy to cross-platform build. But a lot of strange error happened when build it on linux.