-
Notifications
You must be signed in to change notification settings - Fork 133
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
aes: feature flags are not additive #245
Comments
This would be a breaking change, so if we were to try to implement something like this, it would be in I'll let @newpavlov speak to the rationale for Regarding |
Another dimension to this problem would be potentially adding support for compact round keys in addition to semi-fixslicing: #191 Should that be gated under something like |
Regarding This could have the following behavior:
|
aes
feature flags are not additive
I do not support this interpretation. In my opinion features MUST be additive only in the sense of public API and MUST NOT cause compilation errors if several features are enabled simultaneously. Meanwhile adding the under the hood functionality as in our case at best is SHOULD (yeah, I see that the quote uses "should", but I am not sure if it was done with the RFC in mind). As mentioned in the IRLO thread, unfortunately, Cargo does not have proper tools to handle such use-cases (i.e. mutually exclusive features and features which must be toggled only by an end app, not libraries), so we have to work with what we got. In other words, it boils down to matter of defaults. Most users want for AES-NI intrinsics to be used if CPU supports them, after all Yes, we could state that To summarize: I think the current approach is the most practical one at the moment and should not be changed until Cargo will improve support of such use cases. |
Cargo does have such a feature via non-
I'm a bit confused. The primary feature in question is |
Between the AES-NI backend, ARMv8 backend, and 32-bit and 64-bit fixsliced backends, and trying to support various combinations of software-only and autodetected intrinsics+software-only fallback, the I think it might be worth trying to PR using an additive |
I'm not sure I follow why there should be a difference. You'll need a
Yes, this would assuage my concern. What kind of improvement are you referring to? |
The cited text is about the proposed
It could work in theory, but it has the same problems with discoverability. Also enabling it is a bit annoying with the current tooling (IIUC you either have to edit Ideally we would declare such "non-features" in a crate's P.S.: BTW |
I've reinterpreted your comments in this light and offer my commentary below.
The idea would be that
The presence of a non-
You can do this yourself using #[cfg(all(force_soft, not_force_soft))]
compile_error!("`force_soft` and `not_force_soft` are mutually exclusive `cfg`s: enable one or the other, but not both");
Sure, but using an older version of the crate accomplishes the same thing without the impossible to surmount downsides. Further, if enough crates do use the feature, then eventually no crate with any significant dependencies will benefit from AES-NI. |
You do not address the
Yes, but none of the higher-level crates in this org enable this feature by default. And there is a very little incentive to do so (unlike with the
As I've said in the previous comment, I do find the
You are missing the point about discoverability and convenience of the declarative approach. The
No, the older |
I am not proposing one approach xor the other, I'm proposing both.
It's not about crates in this org, it's about the crates in an arbitrary dependency graph. For instance, @tarcieri enabled
No, I don't think I am. Features and Or perhaps I'm misunderstanding you completely. Why would a deep dependency, or any dependency at all, use non-
I'm not sure how this is relevant? You'd clearly need to match up your dependencies, but this is orthogonal to the issue at hand. |
Checking in. Any chance of moving forward? |
I'm personally for it in general, but probably not for making another breaking release for awhile. Just for refactoring the internals I'd like to go to 1.51 and use const generics (as I've done in the nightly-only ARMv8 backend), but that's probably a bit of an aggressive version bump in the interim. |
The
aes
crate has two feature flags, both of which remove functionality:block-ciphers/aes/Cargo.toml
Lines 29 to 31 in f68ad0d
This is an incorrect use of Cargo feature flags. From my comments at rwf2/cookie-rs#176 (comment), which focus on
force-soft
:The same reasoning applies to the
compact
feature. If it must exist at all, a non-feature--cfg aes_compact
is the correct approach. This restores control of expected performance to the top-level binary as opposed to any crate in the transitive closure of dependencies.See also the full comment thread in rwf2/cookie-rs#176.
The text was updated successfully, but these errors were encountered: