-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
proc macro crate causes extra dependency compilation in workspace #10645
Comments
Thanks for the report! This is a known issue with proc-macros inside a workspace (#8312). Essentially the proc-macro activates features as a member of the workspace, and then separately as a proc-macro dependency. In your particular case, this causes some dependencies to be built twice, once with the "default" feature enabled and once without. This is due to the frequent use of default-features=false. One workaround is to not use diff --git a/lib/Cargo.toml b/lib/Cargo.toml
index 2b70fb9ec..b544d009f 100644
--- a/lib/Cargo.toml
+++ b/lib/Cargo.toml
@@ -12,7 +12,7 @@ repository = "https://github.com/hacspec/hacspec"
[dependencies]
num = { version = "0.4", default-features = false }
secret_integers = { path = "../utils/secret-integers", optional = true, version = "0.1.7" } #FIXME: publish new version
-abstract_integers = { path = "../utils/abstract-integers", version = "0.1.5", default-features = false } #FIXME: publish new version
+abstract_integers = { path = "../utils/abstract-integers", version = "0.1.5" } #FIXME: publish new version
hacspec-attributes = { path = "../utils/attributes", optional = true, version = "0.1.0-beta.1" }
[features]
diff --git a/utils/abstract-integers/Cargo.toml b/utils/abstract-integers/Cargo.toml
index a2c4c07eb..a491e0e2c 100644
--- a/utils/abstract-integers/Cargo.toml
+++ b/utils/abstract-integers/Cargo.toml
@@ -10,7 +10,7 @@ license = "Apache-2.0"
readme = "README.md"
[dependencies]
-num = { version = "0.4", default-features = false }
+num = { version = "0.4" }
num-bigint = { version = "0.3", default-features = false }
[features] It may also be possible to avoid it by building the workspace without the proc-macros (like the derive one). I'm not sure if that will work, though. I did discover that there is a bug in Closing as a duplicate of #8312 |
Thanks a lot for the detailed response! |
Problem
In a project workspace with many examples all having a library crate dependency with default features and a single proc-macro crate with the same dependency, the dependency is built twice.
All examples are using one of the compilations, only the proc macro crate is using the other.
All crates in the workspace are setting edition 2018, but the workspace is setting
resolver = "2"
.This is the PR where the issue can be reproduced: hacspec/hacspec#72
In this case, Hacspec's type checker can't handle the two versions of that library, which is another problem.
BUT, why does the library crate need to be compiled twice even though it is only used with default features?
Steps
cargo clean && cargo build
ls target/debug/deps | grep libhacspec_lib
Observe there are two versions of libhacspec_lib.
Observe there's only one version of libhacspec_lib.
Possible Solution(s)
It seems like the proc macro build ignores all feature settings?
Notes
No response
Version
The text was updated successfully, but these errors were encountered: