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

rdrand: Avoid assuming usize is the native word size. #442

Merged
merged 1 commit into from
May 31, 2024

Conversation

briansmith
Copy link
Contributor

@briansmith briansmith commented May 31, 2024

x86_64-unknown-linux-gnux32 has target_pointer_width = "32", so usize is 32-bits. In this case, we were throwing away half of each RDRAND result and doing twice as many RDRAND invocations as necessary. This wasn't noticed because as silently does a lossy conversion.

Add x86_64-unknown-linux-gnux32 to the test matrix. [Edit: Ubuntu doesn't support x32 by policy; see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1994516/comments/21].

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think we should remove the x32 testing for now.

Copy link
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I don't know if any of the Linux GitHub actions runners support x32. It turns out they don't, I think it's fine to jsut check that x32 builds.

`x86_64-unknown-linux-gnux32` has target_pointer_width = "32", so
usize is 32-bits. In this case, we were throwing away half of each
RDRAND result and doing twice as many RDRAND invocations as
necessary. This wasn't noticed because `as` silently does a lossy
conversion.
@briansmith
Copy link
Contributor Author

I removed the CI changes because we don't have a way of testing this on an x32 target, and the code built and ran correctly (but suboptimally) before and after this change on all these targets

@newpavlov newpavlov merged commit b2bca0f into rust-random:master May 31, 2024
52 checks passed
@newpavlov newpavlov mentioned this pull request Oct 11, 2024
newpavlov added a commit that referenced this pull request Oct 11, 2024
Tweak the breaking changes section and add entries for #415, #440, #442,
#448, #504, and #512.
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.

3 participants