Polish getrandom() backwards compatibility shim (#10757)

* Add changelog entry for the `getrandom()` backwards compatibility shim

* Comment message pragma of the `getrandom()` backwards compatibility shim
This commit is contained in:
Elias Batek 2025-04-22 00:32:45 +02:00 committed by GitHub
parent 40ffbb3641
commit 4ea5c352da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -0,0 +1,19 @@
`getrandom()` backwards compatibility shim
To restore compatibility with older Linux platforms where `getrandom()` is
unavailable either due to an outdated kernel or a legacy C library, Phobos now
ships with a shim that emulates a limited subset of `getrandom()`s behavior
by reading random bytes from `/dev/urandom`.
To enable the shim, build DMD and Phobos with the environment variable
`LINUX_LEGACY_EMULATE_GETRANDOM` set to `1`.
```
cd phobos
LINUX_LEGACY_EMULATE_GETRANDOM=1 make
```
This functionality is a temporary fix and expected to be removed again soon
by an upcoming release (approx. v2.112.0 or v2.113.0).
The expected change is to replace the current “binding or shim” solution with
a syscall wrapper and automatic `/dev/urandom` fallback.

View file

@ -1782,7 +1782,6 @@ version (linux)
`getrandom()` was added to the GNU C Library in v2.25.
+/
pragma(msg, "`getrandom()` emulation for legacy Linux targets is enabled.");
/+
On modern kernels (5.6+), `/dev/random` would behave more similar