-
Notifications
You must be signed in to change notification settings - Fork 294
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
[Request] Update documentation to mention potential no_std
problem.
#124
Comments
I'm happy to allow disabling |
0ndorio
added a commit
to 0ndorio/hashbrown
that referenced
this issue
Oct 30, 2019
Disables the default features of `ahash` and reintroduces them through a new feature called `ahash-compile-time-rng`, which is enabled by default. The new feature makes it possible for depended crates to rely on `hashbrown` with `ahash` as default hasher and to disable the `compile-time-rng` at the same time. This might be useful for any dependend crate targeting `no_std`, which contains `rand` or `rand_core` somewhere inside the dependency tree as a bug in cargo accidently enables the underlying `getrandom` feature if `compile-time-rng` is enabled [1]. ... fixes rust-lang#124 [1] rust-lang/cargo#5760
0ndorio
added a commit
to 0ndorio/hashbrown
that referenced
this issue
Oct 30, 2019
Disables the default features of `ahash` and reintroduces them through a new feature called `ahash-compile-time-rng`, which is enabled by default. The new feature makes it possible for depended crates to rely on `hashbrown` with `ahash` as default hasher and to disable the `compile-time-rng` at the same time. This might be useful for any dependent crate targeting `no_std`, which contains `rand` or `rand_core` somewhere inside the dependency tree as a bug in cargo accidentally enables the underlying `getrandom` feature if `compile-time-rng` is enabled [1]. ... fixes rust-lang#124 [1] rust-lang/cargo#5760
bors
added a commit
that referenced
this issue
Oct 31, 2019
Introduce `ahash-compile-time-rng` feature. **Content** Disables the default features of `ahash` and reintroduces them through a new feature called `ahash-compile-time-rng`, which is enabled by default. The new feature makes it possible for depended crates to rely on `hashbrown` with `ahash` as default hasher and to disable the `compile-time-rng` at the same time. This might be useful for any depended crate targeting `no_std`, which contains `rand` or `rand_core` somewhere inside the dependency tree as a bug in cargo accidentally enables the underlying `getrandom` feature if `compile-time-rng` is enabled [1]. ... fixes #124 [1] rust-lang/cargo#5760 --- **Warnings** (1) Compiling `ahash` with disabled `compile-time-rng` feature is currently broken and requires tkaitchuck/aHash#25 to be merged in advance. (2) This introduces a hidden behavior change for all dependent crates, using hashbrown with `default-features = false` and `features = 'ahash'`. This happens as the `ahash` feature no longer implicitly enables the `compile-time-rng` feature of `ahash`. --- Is the naming of the feature okay? Do I need to add any additional changes?
This was referenced Nov 16, 2019
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: This is actually not an issue with
hashbrown
but withcargo
.Topic: no_std support
While
hashbrown
itself is able to compile successfully forno_std
targets, and even uses the CI pipeline to verify its compatibility to thethumbv6m-none-eabi
target, it might still trigger issues if used with other dependencies when the defaultahash
feature is enabled.Issue
The dependency tree of
ahash
injects thegetrandom
crate if the default feature set is enabled. This crate is heavily platform dependent and does not support targets like thethumbv6
orthumbv7
families.How does this happen?
The underlying issue is an a long standing and well known cargo bug (rust-lang/cargo#5760) which automatically calculates a required feature set for each (sub-)dependency inside the dependency tree regardless of the dependency origin.
If
ahash
- with default feature set - is used, it will include theconst-random
crate and therefore the proc macro crateconst-random-macro
into the dependency tree. This will request thegetrandom
feature for the cratesrand v^0.7
and indirectly alsorand_core v^0.5.1
.As dependencies of proc macros are compiled for the host and not the target architecture this works fine as long as the host architecture is contained in the following list and the
no_std
build should be successful (as you can see inside the CI).But it is going to fail as soon as one of the following two conditions are true:
The host architecture is not supported.
The target architecture is not supported and the dependency tree contains at least one non proc macro dependency, which requires either
rand v^0.7
orrand_core v^0.5.1
, because than the underlyingcargo
issue kicks in. Cargo is going to inject thegetrandom
feature requirement for these crates, originating from the dependency list ofconst-random-macro
, into the other dependency so that cargo is trying to compilegetrandom
not only for the host architecture but also for the target architecture.Request
As long as rust-lang/cargo#5760 is still a thing it would be great if at least the
hashbrown
documentation could get a warning paragraph explaining this topic including how to work around this issue.Potential workarounds I can see:
hashbrown
could introduce a way to disable thecompile-time-rng
feature ofahash
if default features are disabled.The relying crate could disable the
ahash
feature ofhashbrown
and reintroduce another hasher orahash
withoutcompile-time-rng
feature.Both might result in
ahash
losing the compile time random seed for the hash values.The text was updated successfully, but these errors were encountered: