-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default-features = false
not working for dependency inside workspace.
#8366
Comments
Features in a workspace are unified across all roots selected on the command-line. In your example, you have selected both You can use The behavior of "workspace features unify based on what is being built" is tracked in #4463. |
You're right, in the first case when just running But this still leaves the case where |
I'm not sure I understand your last comment. Using your example, the following does not select the default features for the dependency:
|
I think he means that this still builds
|
Ah. Path dependencies are automatically added as workspace members, so it doesn't matter whether or not it is listed. |
Oh right. |
So is this working as intended? It is quite surprising that behaviour changes simply by switching to a path dependency for local debugging. |
For now that is the intended behavior. I would recommend choosing the specific packages you want to build (with |
Closing as this is the intended behavior for now. There are links above to issues tracking things like workspace unification. |
Trying to build in an no-std doesn't work. Example with zune-jpg and x86_64-unknown-uefi: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-core v0.2.13 (/home/zoid/clone/active/zune-image/zune-core) error[E0463]: can't find crate for `std` | = note: the `x86_64-unknown-uefi` target may not support the standard library = note: `std` is required by `zune_core` because it does not declare `#![no_std]` [...] ``` This seems to be due to a bug (or expected behavior) in the cargo worktrees: rust-lang/cargo#8366 From zune-jpeg we can't disable the default features of zune-core. But that's no problem, since zune-jpeg already enabled the std feature in zune-core, whenver its std feature is enabled. With this patch, compilation succeeds: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-jpeg v0.3.16 (/home/zoid/clone/active/zune-image/zune-jpeg) warning: dropping unsupported crate type `cdylib` for target `x86_64-unknown-uefi` warning: `zune-jpeg` (lib) generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.15s ``` Signed-off-by: Daniel Schaefer <[email protected]>
Trying to build in an no-std doesn't work. Example with zune-jpg and x86_64-unknown-uefi: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-core v0.2.13 (/home/zoid/clone/active/zune-image/zune-core) error[E0463]: can't find crate for `std` | = note: the `x86_64-unknown-uefi` target may not support the standard library = note: `std` is required by `zune_core` because it does not declare `#![no_std]` [...] ``` This seems to be due to a bug (or expected behavior) in the cargo worktrees: rust-lang/cargo#8366 From zune-jpeg we can't disable the default features of zune-core. But that's no problem, since zune-jpeg already enabled the std feature in zune-core, whenver its std feature is enabled. With this patch, compilation succeeds: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-jpeg v0.3.16 (/home/zoid/clone/active/zune-image/zune-jpeg) warning: dropping unsupported crate type `cdylib` for target `x86_64-unknown-uefi` warning: `zune-jpeg` (lib) generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.15s ``` Signed-off-by: Daniel Schaefer <[email protected]>
Trying to build in an no-std doesn't work. Example with zune-jpg and x86_64-unknown-uefi: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-core v0.2.13 (/home/zoid/clone/active/zune-image/zune-core) error[E0463]: can't find crate for `std` | = note: the `x86_64-unknown-uefi` target may not support the standard library = note: `std` is required by `zune_core` because it does not declare `#![no_std]` [...] ``` This seems to be due to a bug (or expected behavior) in the cargo worktrees: rust-lang/cargo#8366 From zune-jpeg we can't disable the default features of zune-core. But that's no problem, since zune-jpeg already enabled the std feature in zune-core, whenver its std feature is enabled. With this patch, compilation succeeds: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-jpeg v0.3.16 (/home/zoid/clone/active/zune-image/zune-jpeg) warning: dropping unsupported crate type `cdylib` for target `x86_64-unknown-uefi` warning: `zune-jpeg` (lib) generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.15s ``` Signed-off-by: Daniel Schaefer <[email protected]>
Trying to build in an no-std doesn't work. Example with zune-jpg and x86_64-unknown-uefi: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-core v0.2.13 (/home/zoid/clone/active/zune-image/zune-core) error[E0463]: can't find crate for `std` | = note: the `x86_64-unknown-uefi` target may not support the standard library = note: `std` is required by `zune_core` because it does not declare `#![no_std]` [...] ``` This seems to be due to a bug (or expected behavior) in the cargo worktrees: rust-lang/cargo#8366 From zune-jpeg we can't disable the default features of zune-core. But that's no problem, since zune-jpeg already enabled the std feature in zune-core, whenver its std feature is enabled. With this patch, compilation succeeds: ``` > cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features Compiling zune-jpeg v0.3.16 (/home/zoid/clone/active/zune-image/zune-jpeg) warning: dropping unsupported crate type `cdylib` for target `x86_64-unknown-uefi` warning: `zune-jpeg` (lib) generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.15s ``` Signed-off-by: Daniel Schaefer <[email protected]>
Problem
Setting
default-features = false
for a dependency of one member of a workspace on another workspace member does not work.Steps
using
cargo build -vv
and see thatdep
is compiled with--cfg 'feature="default"' --cfg 'feature="should_not_be_enabled"'
.Possible Solution(s)
–
Notes
Output of
cargo version
:as well as
The same thing also happens if
dep
is not a workspace member but a plain subdirectory.Also, the problem does not happen when running
cargo build -vv
inside oflib
after acd lib
.The text was updated successfully, but these errors were encountered: