Skip to content

Add getrandom() bindings on Linux #1399

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

Merged
merged 6 commits into from
Jun 17, 2019
Merged

Add getrandom() bindings on Linux #1399

merged 6 commits into from
Jun 17, 2019

Conversation

josephlr
Copy link
Contributor

Closes #659

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@josephlr
Copy link
Contributor Author

@gnzlbg I initially also added bindings for Android, but it looks like their libc doesn't have the getrandom() function even though it has the getrandom(2) syscall. See this LWN article on why this split exists.

@josephlr josephlr changed the title Add getrandom() bindings on linux and android Add getrandom() bindings on Linux Jun 14, 2019
@josephlr
Copy link
Contributor Author

@gnzlbg this seems to be working on glibc and musl. However, I'm getting failures, but only on 32 MIPS musl targets (here and here). Any idea why this is happening? Are we using an older version of musl for mips32?

@josephlr josephlr changed the title Add getrandom() bindings on Linux Add getrandom() bindings on Linux (glibc only) Jun 14, 2019
@josephlr
Copy link
Contributor Author

So I decided to just remove musl support for the time being. While getrandom() was added to glibc in version 2.25 (Feb 2017), musl only added such an interface in version 1.1.20 (Sept 2018). So it might be too new for us to support it.

However, I'm getting failures, but only on 32 MIPS musl targets (here and here).

This was happening because the the libc CI uses a new musl for all targets except for mips/mipsel, where it uses an older OpenWRT toolchain hosted in an AWS bucket. However, OpenWRT's archive only seems to have musl 1.1.16. So unless there's a way to get a new musl toolchain for mips, we won't be able to support getrandom() for musl on mips.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 14, 2019

We won't be able to support getrandom() for musl on mips.

We should support this for glibc, and for the musl targets that currently use a newer musl version. The OpenWRT toolchains for the mips targets don't get updated very often, but it does not make sense to penalize other musl users because of this.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 14, 2019

but it does not make sense to penalize other musl users because of this.

To be more specific, could you add this to each of the musl/b32/... and musl/b64/... modules, and remove it only from those for which CI fails due to an old musl version ?

@josephlr
Copy link
Contributor Author

To be more specific, could you add this to each of the musl/b32/... and musl/b64/... modules, and remove it only from those for which CI fails due to an old musl version ?

Done

@gnzlbg gnzlbg self-requested a review June 14, 2019 09:29
Copy link
Contributor

@gnzlbg gnzlbg left a comment

Choose a reason for hiding this comment

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

Thanks, this LGTM, please ping me when CI is green in case I don't get notified.

@josephlr josephlr changed the title Add getrandom() bindings on Linux (glibc only) Add getrandom() bindings on Linux Jun 14, 2019
@josephlr
Copy link
Contributor Author

@gnzlbg Everything is green

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 14, 2019 via email

@josephlr
Copy link
Contributor Author

@gnzlbg It looks like @bors didn't hear you.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 17, 2019

@bors: r+

@bors
Copy link
Contributor

bors commented Jun 17, 2019

📌 Commit 14b22c1 has been approved by gnzlbg

@bors
Copy link
Contributor

bors commented Jun 17, 2019

⌛ Testing commit 14b22c1 with merge 5bbba03...

bors added a commit that referenced this pull request Jun 17, 2019
Add getrandom() bindings on Linux

Closes #659
@bors
Copy link
Contributor

bors commented Jun 17, 2019

☀️ Test successful - checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-travis, status-appveyor
Approved by: gnzlbg
Pushing 5bbba03 to master...

@bors bors merged commit 14b22c1 into rust-lang:master Jun 17, 2019
@josephlr josephlr deleted the getrandom branch June 18, 2019 11:07
tamird added a commit to tamird/libc that referenced this pull request Mar 20, 2025
The existing bindings were added in rust-lang#1399 and limited to targets where
rustc used musl version >= 1.1.20 which was not all musl targets at that
time. Since rust-lang/rust#107129 all musl
targets use musl 1.2.3. Hence, move the binding to the module root so it
is available for all musl targets.
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Apr 3, 2025
The existing bindings were added in rust-lang#1399 and limited to targets where
rustc used musl version >= 1.1.20 which was not all musl targets at that
time. Since rust-lang/rust#107129 all musl
targets use musl 1.2.3. Hence, move the binding to the module root so it
is available for all musl targets.

(backport <rust-lang#4346>)
(cherry picked from commit 77d3011)
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.

getrandom(2) is missing from the bindings
4 participants