You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
When building project dependencies, feature selection from indirect dependencies appear to be ignored, which can result in build failures in circumstances where features get opted-into that were configured to be opted-out. This can produce build failures as some std requiring features in otherwise no_std crates are turned on.
What Currently happens:
When building the upstream library against a target that does not have the std crate, the build succeeds (As expected).
When building the downstream application against the same target, WITH the upstream library specified as a dependency, the build fails (cannot find crate for std)
What I expect to happen:
building the downstream should succeed, and the upstream dependencies retain their feature configuration (unless explicitly overridden by the downstream application).
$ docker build .
Sending build context to Docker daemon 194kB
Step 1/7 : FROM rust
---> 84ba1f55dee3
Step 2/7 : ADD project /project
---> Using cache
---> 49126adfc4e2
Step 3/7 : RUN rustup target add thumbv7em-none-eabihf
---> Using cache
---> 295dc9ff58c9
Step 4/7 : WORKDIR /project/upstream_lib/my_lib
---> Running in fa11316d7cab
Removing intermediate container fa11316d7cab
---> aec209d34f56
Step 5/7 : RUN cargo build --target thumbv7em-none-eabihf
---> Running in 96adcf9c0e9f
Updating git repository `https://github.com/danburkert/prost.git`
Updating crates.io index
Downloading crates ...
Downloaded proc-macro2 v1.0.13
Downloaded quote v1.0.6
Downloaded syn v1.0.22
Downloaded itertools v0.9.0
Downloaded anyhow v1.0.31
Downloaded bytes v0.5.4
Downloaded unicode-xid v0.2.0
Downloaded either v1.5.3
Compiling proc-macro2 v1.0.13
Compiling unicode-xid v0.2.0
Compiling syn v1.0.22
Compiling anyhow v1.0.31
Compiling either v1.5.3
Compiling bytes v0.5.4
Compiling itertools v0.9.0
Compiling quote v1.0.6
Compiling prost-derive v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling prost v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling prost-types v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling my_lib v0.1.0 (/project/upstream_lib/my_lib)
Finished dev [unoptimized + debuginfo] target(s) in 36.82s
Removing intermediate container 96adcf9c0e9f
---> 45072de0df9a
Step 6/7 : WORKDIR /project/downstream_application/some_application
---> Running in 2966d4c24da3
Removing intermediate container 2966d4c24da3
---> 4864d7d17ac8
Step 7/7 : RUN cargo build --target thumbv7em-none-eabihf
---> Running in f0fb3dc89155
Compiling proc-macro2 v1.0.13
Compiling unicode-xid v0.2.0
Compiling anyhow v1.0.31
Compiling syn v1.0.22
Compiling either v1.5.3
Compiling bytes v0.5.4
Compiling itertools v0.9.0
Compiling quote v1.0.6
Compiling prost-derive v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling prost v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling prost-types v0.6.1 (https://github.com/danburkert/prost.git#80256277)
Compiling my_lib v0.1.0 (/project/upstream_lib/my_lib)
Compiling some_application v0.1.0 (/project/downstream_application/some_application)
error[E0463]: can't find crate for `std`
|
= note: the `thumbv7em-none-eabihf` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `some_application`.
To learn more, run the command again with --verbose.
The command '/bin/sh -c cargo build --target thumbv7em-none-eabihf' returned a non-zero code: 101
Possible Solution(s)
Notes
This occurs regardless of how the upstream dependency is specified, occurs with local paths, crates.io dependencies, and private Git dependencies.
Additional context:
I am targeting an embedded platform, specifically using the thumbv7em-none-eabihf toolchain.
While prost was used as the example for my above demonstration, this has also hit me with other, unrelated dependencies that also deselect features in their dependencies.
Issue reproduced in docker, however is reproduce-able outside containers.
OS: Ubuntu 19.10 x64
The text was updated successfully, but these errors were encountered:
Have you tried the new feature resolver? It looks like you have some build dependencies, maybe those are adding the features you don't want? There is documentation for it here, and there is a new global opt-in documented here where you add resolver = "2" to your package definition.
Switched to nightly and built my project using cargo -Zfeatures=all build
and the project compiled successfully; appears nightly's new resolver does a better job at handling feature selections.
also builds if resolver = "2" is specified in my downstream's Cargo.toml
applying these changes to my above docker example fixes the above build error as well.
Problem
When building project dependencies, feature selection from indirect dependencies appear to be ignored, which can result in build failures in circumstances where features get opted-into that were configured to be opted-out. This can produce build failures as some
std
requiring features in otherwiseno_std
crates are turned on.What Currently happens:
When building the upstream library against a target that does not have the
std
crate, the build succeeds (As expected).When building the downstream application against the same target, WITH the upstream library specified as a dependency, the build fails (cannot find crate for
std
)What I expect to happen:
building the downstream should succeed, and the upstream dependencies retain their feature configuration (unless explicitly overridden by the downstream application).
Steps
Possible Solution(s)
Notes
This occurs regardless of how the upstream dependency is specified, occurs with local paths,
crates.io
dependencies, and private Git dependencies.Output of
cargo version
:Additional context:
I am targeting an embedded platform, specifically using the
thumbv7em-none-eabihf
toolchain.While
prost
was used as the example for my above demonstration, this has also hit me with other, unrelated dependencies that also deselect features in their dependencies.Issue reproduced in docker, however is reproduce-able outside containers.
OS: Ubuntu 19.10 x64
The text was updated successfully, but these errors were encountered: