Dev-dependencies force features in dependencies so that cargo build is not possible


#1

I have a no_std device driver crate for which I have written the examples and documentation examples using linux-embedded-hal (dev-dependency).
It is possible to build this crate for other targets where there is no std by adding it as a dependency.
However, it is not possible to build the crate for other targets when it is by itself with cargo build --target thumbv7m-none-eabi. This succeeds if commenting-out the linux-embedded-hal dev-dependency.

It seems like the linux-embedded-hal dev dependency activates the std feature of crate void which is a dependency of embedded-hal. embedded-hal is a dependency of this crate and in this way, the std is now required for a normal build.
Here are clearer steps to reproduce:

git clone https://github.com/eldruin/ds1307-rs
cd ds1307-ds
cargo build --target thumbv7m-none-eabi # fails, there is no std
# ... comment out linux-embedded-hal line in Cargo.toml
cargo build --target thumbv7m-none-eabi # works

Surprisingly, adding a #[cfg] to Cargo.toml did also not work. This still fails:

[target.'cfg(target_arch = "x86_64")'.dev-dependencies]
linux-embedded-hal = "0.2"

I know it is not possible (at least at the moment) to have dependencies only for examples but is there any way to solve this?
I cannot activate CI builds for the really interesting platforms because of this.
Again, the crate builds fine for no_std targets when it is built as a dependency of another project.


#2

Yes, this is a common headache:


#3

Thanks @cuviper! I hope it gets fixed soon.