I found out that target riscv64gc-unknown-linux-musl may help. When I try to add the target, I am told that
toolchain 'nightly-x86_64-unknown-linux-gnu' does not contain component 'rust-std' for target 'riscv64gc-unknown-linux-musl'
help: consider using
cargo build -Z build-stdinstead
So I ran this command, "cargo build -Z build-std --target riscv64gc-unknown-linux-musl", but got a lot compile error:
error[E0412]: cannot find type `c_char` in the crate root
--> /home/simon/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/libc-0.2.93/src/unix/mod.rs:45:29
|
6 | pub type c_schar = i8;
| ---------------------- similarly named type alias `c_schar` defined here
...
45 | pub gr_name: *mut ::c_char,
| ^^^^^^ help: a type alias with a similar name exists: `c_schar`
>error[E0412]: cannot find type `c_char` in the crate root
--> /home/simon/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/libc-0.2.93/src/unix/mod.rs:46:31
|
6 | pub type c_schar = i8;
| ---------------------- similarly named type alias `c_schar` defined here
...
46 | pub gr_passwd: *mut ::c_char,
| ^^^^^^ help: a type alias with a similar name exists: `c_schar`
error: aborting due to 679 previous errors
Some errors have detailed explanations: E0412, E0425, E0573. For more information about an error, try
rustc --explain E0412.error: could not compile `libc`
How can I understand the detail of build-std and make it work? By reading the source code of cargo and rust?