Skip to content

make ahash optional - #17

Closed
Qix- wants to merge 2 commits into
RegexSolver:mainfrom
Qix-:opt-ahash
Closed

Qix- wants to merge 2 commits into
RegexSolver:mainfrom
Qix-:opt-ahash

Conversation

@Qix-

@Qix- Qix- commented Sep 10, 2026

Copy link
Copy Markdown

What this changes

This PR makes the ahash dependency optional.

ahash uses getrandom under the hood, which has a long-standing history of annoyances when building under WASM. If there are multiple crates that use varying versions of getrandom as transitive dependencies, it makes things impossible to build under WASM.

In our case regexsolver doesn't need to be particularly fast or hardened under WASM, so disabling it (and by proxy, getrandom) and using std::collections::HashMap is the solution here.

Totally understandable if you don't want to accept these changes; I figured it'd probably be helpful to someone else out there, and I was hoping not to have to maintain a fork of regexsolver.

Thank you for the amazing crate by the way.

Checklist

  • cargo fmt --all --check and cargo clippy --all-targets -- -D warnings pass
  • cargo test and cargo test --no-default-features pass
  • New public items are documented (N/A)
  • A test covers the change (N/A)
  • CHANGELOG.md is updated under ## [Unreleased]
  • The change builds on Rust 1.88, or the MSRV bump is intentional and noted

@alexvbrdn

alexvbrdn commented Sep 14, 2026

Copy link
Copy Markdown
Member

Hello,

Thank you very much for your contribution and your kind words!

I hadn't checked WASM compilation for RegexSolver before, so I am very grateful you identified this gap. I will take some time to add a new GitHub Action to test this going forward.

Regarding the implementation, putting ahash behind a feature flag seems a bit overkill. ahash actually has its own feature flag (compile-time-rng) that removes the reliance on getrandom. I will look into whether we can just leverage that instead to keep the codebase simpler.

Since I'll be implementing this alternative approach directly alongside the CI changes, I am going to close this PR. Thank you again for pointing me in the right direction and helping improve the project!

Just out of curiosity, which specific WASM target are you trying to build for?

@Qix-

Qix- commented Sep 14, 2026

Copy link
Copy Markdown
Author

Hi there, whatever works is alright - just as long as it doesn't require getrandom because the different versions as transitive dependencies cause issues.

The target is typically wasm32-unknown-unknown. If you compile with cargo build --target wasm32-unknown-unknown it should work.

@alexvbrdn alexvbrdn mentioned this pull request Sep 14, 2026
6 tasks
@alexvbrdn

Copy link
Copy Markdown
Member

v1.0.2 has just been released on crates.io.

Thanks again for your contribution.

Do not hesitate in the future if you have any feedback or any improvement idea.

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.

2 participants