Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Is it mandatory to build musl configured cargo to be able to use cargo build --target=x86_64-unknown-linux-musl?

  • How can I address this:

    'error: could not find native static library `c`, perhaps an -L flag is missing?'
    
like image 357
M Moadeli Avatar asked Aug 06 '15 09:08

M Moadeli


1 Answers

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

like image 164
M Moadeli Avatar answered Nov 15 '22 20:11

M Moadeli