Skip to content

Add support for getrandom v0.3.3#2

Open
jason-nitro wants to merge 433 commits intosp1-patches:0.1-zkvmfrom
nitro-svm:v0.3.3-zkvm-final
Open

Add support for getrandom v0.3.3#2
jason-nitro wants to merge 433 commits intosp1-patches:0.1-zkvmfrom
nitro-svm:v0.3.3-zkvm-final

Conversation

@jason-nitro
Copy link

getrandom v0.3.3 (which is used by Agave 3.0) changed their backend interface, so this is an updated version of the code needed to use this within an SP1 proof. There are a lot of commits because it includes the whole update to the new version, but there are two commits at the end which are this zkvm change.

Before this is merged, Succinct needs to create a new v0.3.3-zkvm branch from 0.1-zkvm and retarget this PR to it.

josephlr and others added 30 commits October 31, 2022 00:09
Currently this is the same as `windows-latest` so this is not a
functional change.

Signed-off-by: Joe Richey <joerichey@google.com>
This is necessary to get Firefox to work.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
glibc is providing open64 and other lfs64 functions but musl aliases
them to normal equivalents since off_t is always 64-bit on musl,
therefore check for target env along when target OS is linux before
using open64, this is more available. Latest Musl has made these
namespace changes [1]

There is no need for using LFS64 open explicitly as we are only using it
for opening device files and not real files

[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Signed-off-by: Khem Raj <raj.khem@gmail.com>
NetBSD supports the getrandom system call since version 10.0 [1].
Use it if available, otherwise fall back to kern.arandom like on FreeBSD.

[1] https://man.netbsd.org/getrandom.2
Followup to rust-random#331, we don't need the condidtional compilation anymore,
because this file is only used if
`any(target_os = "freebsd", target_os = "netbsd")` anyway.

Also cleans up `use` statements and type declarations to look like those
in macos.rs

Signed-off-by: Joe Richey <joerichey@google.com>
The flag name is +rdrand not +rdrnd

Signed-off-by: Joe Richey <joerichey@google.com>
Also makes rdrand() return an integer instead of an array of bytes. This
will make the self-test implementation easier. As we can just return a
`usize` we no longer need the `WORD_SIZE` constant.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
We could use core::usize::MAX, but that is deprecated.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test
My not caching the build results, we should hopefuly prevent the linking
errors we were seeing before.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
Reenable cross build/link tests and update cross
* Hermit: use sys_read_entropy syscall

* Add doc link
* Add in a RtlGenRandom fallback for non-UWP Windows

In some instances BCryptRandom will fail when RtlGenRandom will work.
On UWP, we might be unable to actually use RtlGenRandom.

Thread the needle and use RtlGenRandom when we have to, when we're able.

See also rust-lang/rust#108060

Fixes rust-random#314

* style suggestion

Co-authored-by: Artyom Pavlov <newpavlov@gmail.com>

* appease clippy

---------

Co-authored-by: Artyom Pavlov <newpavlov@gmail.com>
I think the caching isn't interacting well with the libc build script.

Lets see if this fixes things.

Signed-off-by: Joe Richey <joerichey@google.com>
Window's `msedgedriver` seems to be unreliable, as port binding will
occasionally fail. Instead of wasting time trying to debug this, just
let the tests fail.

We take a similar approch for Safari's webdriver, we will allow the
tests to fail, but will hopefully see when they start succeeding (when
Safari fixes the COOP bug).

Signed-off-by: Joe Richey <joerichey@google.com>
The target triple name was changed in rust-lang/rust#106429

While `rustc` known the old spelling of the triple, `rustup` does not,
so the toolchain download was not working.

Signed-off-by: Joe Richey <joerichey@google.com>
dependabot bot and others added 30 commits April 28, 2025 21:17
Bumps the all-deps group with 2 updates:
[compiler_builtins](https://github.com/rust-lang/compiler-builtins) and
[cc](https://github.com/rust-lang/cc-rs).

Updates `compiler_builtins` from 0.1.156 to 0.1.157
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/rust-lang/compiler-builtins/releases">compiler_builtins's
releases</a>.</em></p>
<blockquote>
<h2>compiler_builtins-v0.1.157</h2>
<h3>Other</h3>
<ul>
<li>Use runtime feature detection for fma routines on x86</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/257dd4808950ec85ed9ecffb8116c550079684f7"><code>257dd48</code></a>
chore: release</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/a2f64407618e95bc8767d6dbabfa7ac0348f5bc8"><code>a2f6440</code></a>
Use runtime feature detection for fma routines on x86</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/6e4255a71258534d70167b8942c7bd8a5c0005dc"><code>6e4255a</code></a>
Rename the i686 module to x86</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/f83962ed9a1f850876860e04d552c5e43ed888f8"><code>f83962e</code></a>
update-api-list: Match subdirectories within arch</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/725484ee6758e7a647df30c4661e356504e222e6"><code>725484e</code></a>
fmaf: Add a test case from a MinGW failure</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/7ccb126f88de3330eb6472036e269c8b73c0b94e"><code>7ccb126</code></a>
builtins-test: Remove <code>no_mangle</code> from
<code>eh_personality</code></li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/f456aa8baf0b108208332dc4bed63b6e70639b67"><code>f456aa8</code></a>
Refactor the fma modules</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/91963f59b3d2b03e947707da15ee4aa19e3d214d"><code>91963f5</code></a>
Move <code>fma</code> implementations to <code>mod generic</code></li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/99b4c195918149b632a061cf1ef56c313b13b396"><code>99b4c19</code></a>
Resolve <code>unnecessary_transmutes</code> lints</li>
<li><a
href="https://github.com/rust-lang/compiler-builtins/commit/fdbefb39d5bb0b95b29b821247044c8aaf436160"><code>fdbefb3</code></a>
Warn on <code>unsafe_op_in_unsafe_fn</code> by default</li>
<li>Additional commits viewable in <a
href="https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.156...compiler_builtins-v0.1.157">compare
view</a></li>
</ul>
</details>
<br />

Updates `cc` from 1.2.20 to 1.2.21
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/rust-lang/cc-rs/releases">cc's
releases</a>.</em></p>
<blockquote>
<h2>cc-v1.2.21</h2>
<h3>Other</h3>
<ul>
<li>Fix wasm32-unknown-unknown by passing -c (<a
href="https://redirect.github.com/rust-lang/cc-rs/pull/1424">#1424</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md">cc's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/rust-lang/cc-rs/compare/cc-v1.2.20...cc-v1.2.21">1.2.21</a>
- 2025-05-02</h2>
<h3>Other</h3>
<ul>
<li>Fix wasm32-unknown-unknown by passing -c (<a
href="https://redirect.github.com/rust-lang/cc-rs/pull/1424">#1424</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/rust-lang/cc-rs/commit/0342d854e1823db9e903c93cea82adaf1e00af33"><code>0342d85</code></a>
chore: release v1.2.21 (<a
href="https://redirect.github.com/rust-lang/cc-rs/issues/1464">#1464</a>)</li>
<li><a
href="https://github.com/rust-lang/cc-rs/commit/e93b7059453f1cbe01cde0e48797974c3853fe73"><code>e93b705</code></a>
Fix wasm32-unknown-unknown by passing -c (<a
href="https://redirect.github.com/rust-lang/cc-rs/issues/1424">#1424</a>)</li>
<li>See full diff in <a
href="https://github.com/rust-lang/cc-rs/compare/cc-v1.2.20...cc-v1.2.21">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
### Changed
- Doc improvements [rust-random#632] [rust-random#634] [rust-random#635]
- Add crate version to docs.rs links used in `compile_error!`s [rust-random#639]

## Fixed
- Error handling in WASI p1 [rust-random#661]

[rust-random#632]: rust-random#632
[rust-random#634]: rust-random#634
[rust-random#635]: rust-random#635
[rust-random#639]: rust-random#639
[rust-random#661]: rust-random#661
This release (instead of rust-random#663) will be what we tag as v0.3.3

Signed-off-by: Joe Richey <joerichey@google.com>
- Re-enable Warnings for web tests
- Add `RUSTDOCFLAGS` when using custom backends
- Replace broken PowerPC target with RISC-V target
The backend always returns `Err(Error::UNSUPPORTED)`.
Address a Nightly Clippy complaint and update to the nightly-2025-06-01
toolchain. This allows us to validate upcoming changes. This will help
with filing issues against rust-lang/rust for recent Nightly releases
that affect us.
Avoid masking bugs in backends that return `Ok` without writing the
entire output buffer. For built-in backends, this makes MSAN useful for
validating the correctness of the control flow of each backend. For
custom backends in particular, this makes MSAN useful for validating
that a custom backend actually filled the entire output buffer when it
returned `Ok`.

When MSAN is enabled, this is a breaking change for a custom backend
that is implemented in a way that avoids built-in unpoisoning provided
by Rust/libc/MSAN.. Since MSAN support is unstable in Rust anyway, I
think this is acceptable breakage.

As a side effect, this minimizes the number of configurations that
reference the `__msan_unpoison` symbol unnecessarily.
`asm_const` was stabilized only in Rust 1.82, so inlining the constant
relaxes MSRV for the `linux_raw` backend on ARM targets.
The source code didn't mention the x32 ABI by name. Give
`__X32_SYSCALL_BIT` its rightful name so readers can understand what
we're doing. Explain why we're not using `cfg(target_abi)`.

For other ILP32 ABIs, it seems like they use the same syscall numbers.
The feature was initially added for potential use of `getrandom` in
`std`. Unfortunately, the proposal did not get traction, so the feature
is effectively useless. Before reviving this feature we should resolve
rust-random#365 at the very least and even with that it's unlikely that `getrandom`
will be used by `std` considering the proposals to properly expose
entropy sources in `std`.

Closes rust-random#693
Minimum kernel needed on RISCV is fairly new (4.15+) so we are sure to
have getrandom syscall, on glibc there is mimimal ABI kernel to denote
it but musl does not have any other way to indicate it, so add it as a
condition here to choose getrandom backend for rv32/rv64 on linux when
using musl.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
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.