getrandom() backwards compatibility shim#10741
Conversation
|
Thanks for your pull request, @0xEAB! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + phobos#10741" |
|
Changelog entry? |
|
|
||
| `getrandom()` was added to the GNU C Library in v2.25. | ||
| +/ | ||
| pragma(msg, "`getrandom()` emulation for legacy Linux targets is enabled."); |
There was a problem hiding this comment.
This is obviously a bit spammy. Maybe we should comment it out?
| version (linux) | ||
| { | ||
| // `getrandom()` was introduced in Linux 3.17. | ||
| version (linux_legacy_emulate_getrandom) |
There was a problem hiding this comment.
import gcc.config;
static if (Have_Getrandom)
There was a problem hiding this comment.
@ibuclaw Is this something you’d like me to incorporate?
Or was it more like a note to yourself?
There was a problem hiding this comment.
It would have been nice if this was an enum, as that can survive in the installed sources after the library has been built, and there's already other tests whose results get written to this module at configure time.
version (GNU)
{
import gcc.config;
}
else version (linux_legacy_emulate_getrandom)
{
enum Have_Getrandom = false;
}
else
{
enum Have_Getrandom = true;
}Have added this, though minor annoyance that it's its own thing rather than using the existing "features" module.
There was a problem hiding this comment.
Fortunately, this is a function, and not a template. Otherwise this shim would be a non-starter.
There was a problem hiding this comment.
Anything urgent here?
Otherwise I’d rather wait to see this getting hopefully replaced by something like #10748 in the near future anyway.
People have been unhappy about the new
getrandom()dependency.unpredictableSeedusegetrandom(syscall) on Linux #10623 (comment)Instead of reverting the whole thing, we could supply a compatibility mode to users stuck with legacy systems.