M Moadeli
M Moadeli

Reputation: 99

failure to build rust-libc using cargo when rustc is musl-enabled

I successfully created a musl configured rustc by following this link

My attempt to build a project (which builds fine using non-musl configured rust) failed when I used cargo rustc -- --target=x86_64-unknown-linux-musl

 'error: could not find crate `libc` with expected target triple x86_64-unknown-linux-musl'

Then, I tried to create rust-libc library using the code from crate. To be more accurate, I used the command provided by cargo to build rust-libc, I've only added --target=x86_64-unknown-linux-musl to the command. This time it failed reporting:

'error: could not find native static library `c`, perhaps an -L flag is missing?`'

I have two questions:

Upvotes: 6

Views: 1962

Answers (1)

M Moadeli
M Moadeli

Reputation: 99

This worked for me to build libc:

rustc --target=x86_64-unknown-linux-musl /address-of-libc/lib.rs --crate-name libc --crate-type lib -L /address-of-musldist/musldist/lib/ --out-dir=/your-chosen-address/target --cfg feature=\"default\" --cfg feature=\"cargo-build\" --emit=dep-info,link

Upvotes: 3

Related Questions