Skip to content
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

Add no no_std support #55

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add no no_std support #55

wants to merge 2 commits into from

Conversation

ogxd
Copy link
Owner

@ogxd ogxd commented Dec 30, 2023

No description provided.

@ogxd ogxd mentioned this pull request Dec 30, 2023
@notsatvrn
Copy link
Contributor

notsatvrn commented Dec 31, 2023

It would be possible to get the hasher module working if rand was swapped out for rand_chacha in GxBuildHasher and if it was given a constant seed in no_std environments.

const-random could be used, or the seed could be generated in the build script.

@notsatvrn
Copy link
Contributor

I got this working, generating the seed using the latter method here. I wanted to avoid drawing in more dependencies, and this actually reduces the number of dependencies, as rand depends on all of these.

@ogxd
Copy link
Owner Author

ogxd commented Jan 1, 2024

Interesting, so if I understand correctly, with your changes, the Hasher remains even in no std builds, but with the following subtleties:

  • When std feature, it creates a seed using a ChaCha12 rng, that is itself seeded using getrandom (from OS)
  • When no std
    • When possible, getrandom will use rdrand
    • When not, hardcode a seed but a build time (so it's less dynamic, but still better than completely hardcoded seeds)

The author of ahash has done something similar, but making a separate crate for the build time random. Maybe we can reuse it to avoid the complexity introduced in build.rs

@notsatvrn
Copy link
Contributor

Switched over to const-random here (also fixed the entopy issue here :p)

@ogxd
Copy link
Owner Author

ogxd commented Jan 2, 2024

Nice! I have just cherry-picked your changes. Next step is to have this covered by tests/CI and add a few lines about it in the readme. I can do it when I have some time this week.

@ogxd
Copy link
Owner Author

ogxd commented May 27, 2024

Hello! I'm sorry I haven't provided any update here. The no_std is still very relevant. Since there might be some changes regarding the Hasher construction and the dependencies, I've cherry-picked the first commit of this PR, even if the no_std removes the Hasher. This can be done as a second step once we have figured out what's best for the Hasher seeds generation.

#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants