rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
133 stars 8 forks source link

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

Closed mkb2091 closed 3 years ago

mkb2091 commented 3 years ago

Tried compiling empty project and it failed with the error

Compiling compiler_builtins v0.1.46
   Compiling core v0.0.0 (/home/mkb/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.93
   Compiling cc v1.0.68
   Compiling std v0.0.0 (/home/mkb/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/std)
   Compiling unwind v0.0.0 (/home/mkb/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-core v1.99.0 (/home/mkb/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: could not find native static library `c`, perhaps an -L flag is missing?

   Compiling alloc v0.0.0 (/home/mkb/.rustup/toolchains/nightly-x86_64-unknown-linux-musl/lib/rustlib/src/rust/library/alloc)
error: aborting due to previous error

error: could not compile `libc`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

cargo version: cargo 1.55.0-nightly (9233aa06c 2021-06-22) system: Void Linux with musl and libc

command to reproduce

cargo new --bin project && cd project
cargo +nightly build --release -Z build-std=std --target=x86_64-unknown-linux-musl

But I tested instead creating a project with libc as a dependency and compiled as normal cargo +nightly build --release and it builds fine, so libc isn't the entire problem

mkb2091 commented 3 years ago

duplicate of https://github.com/rust-lang/wg-cargo-std-aware/issues/66, hadn't spotted that also covered same error on musl system

12101111 commented 2 years ago

worksround: export RUSTFLAGS="-Lnative=/usr/lib"

mkb2091 commented 2 years ago

Yeah that workaround works for me, thanks