Skip to content

Commit 4ea5c35

Browse files
authored
Polish getrandom() backwards compatibility shim (#10757)
* Add changelog entry for the `getrandom()` backwards compatibility shim * Comment message pragma of the `getrandom()` backwards compatibility shim
1 parent 40ffbb3 commit 4ea5c35

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

changelog/emulate_getrandom.dd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
`getrandom()` backwards compatibility shim
2+
3+
To restore compatibility with older Linux platforms where `getrandom()` is
4+
unavailable either due to an outdated kernel or a legacy C library, Phobos now
5+
ships with a shim that emulates a limited subset of `getrandom()`’s behavior
6+
by reading random bytes from `/dev/urandom`.
7+
8+
To enable the shim, build DMD and Phobos with the environment variable
9+
`LINUX_LEGACY_EMULATE_GETRANDOM` set to `1`.
10+
11+
```
12+
cd phobos
13+
LINUX_LEGACY_EMULATE_GETRANDOM=1 make
14+
```
15+
16+
This functionality is a temporary fix and expected to be removed again soon
17+
by an upcoming release (approx. v2.112.0 or v2.113.0).
18+
The expected change is to replace the current “binding or shim” solution with
19+
a syscall wrapper and automatic `/dev/urandom` fallback.

std/random.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,6 @@ version (linux)
17821782
17831783
`getrandom()` was added to the GNU C Library in v2.25.
17841784
+/
1785-
pragma(msg, "`getrandom()` emulation for legacy Linux targets is enabled.");
17861785

17871786
/+
17881787
On modern kernels (5.6+), `/dev/random` would behave more similar

0 commit comments

Comments
 (0)