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

Make the macros deterministic, using BTreeMap instead of HashMap #662

Merged

Conversation

cormacrelf
Copy link
Contributor

@cormacrelf cormacrelf commented Dec 5, 2024

This fixes compile errors in non-cargo build systems, which rely on the rustc crate hash being the same between two compiles (i.e. build with/without codegen).

HashMap order is nondeterministic due to SipHasher initialization, so macro-generated code would change between compiles (in this case, the order of the generated match statement branches).

Can confirm buck2 can now build and link leafwing-input-manager.

@alice-i-cecile
Copy link
Contributor

TIL this could be a problem. Sensible fix, thanks.

This fixes compile errors in non-cargo build systems, which rely on the
rustc crate hash being the same between two compiles.

HashMap order is nondeterministic due to SipHasher initialization, so
macro-generated code would change between compiles.
auto-merge was automatically disabled December 6, 2024 04:49

Head branch was pushed to by a user without write access

@cormacrelf cormacrelf force-pushed the hotfix/macro-determinism branch from cc5045d to 196bc02 Compare December 6, 2024 04:49
@alice-i-cecile alice-i-cecile merged commit 212ff69 into Leafwing-Studios:main Dec 6, 2024
4 checks passed
cormacrelf added a commit to cormacrelf/leafwing-input-manager that referenced this pull request Dec 10, 2024
…fwing-Studios#662)

This fixes compile errors in non-cargo build systems, which rely on the
rustc crate hash being the same between two compiles.

HashMap order is nondeterministic due to SipHasher initialization, so
macro-generated code would change between compiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants