Build Rust app using Cargos 'build-std' feature (with naersk) fails because rust-src is missing

So I have a working example using Naersk now. The main problem is that the build-std feature of cargo needs dependencies from crates.io to build the standard library. Naersk only provides sources for everything in Cargo.toml, so this fails.

My workaround is to add everything to [dev-dependencies] in Cargo.toml. This is pretty ugly, but it works:

[dev-dependencies]
compiler_builtins = "0.1.43"
cfg-if = "0.1.10"
getopts = "0.2.21"
libc = "=0.2.93"
hashbrown = "=0.11.0"
rustc-demangle = "=0.1.18"
hermit-abi = "=0.1.17"
dlmalloc = "0.2.1"
wasi = "=0.9.0"
fortanix-sgx-abi = "0.3.3"
cc = "1.0.67"

I’m currently not sure where this needs to be fixed. It feels like Cargo should add all dependencies it uses to compile std to Cargo.lock.

In the meantime, it would be nice to get a hand from Naersk here and be able to specify additional crates that need to be downloaded from crates.io.

Maybe @nmattia has an opinion here?

1 Like