-
Notifications
You must be signed in to change notification settings - Fork 91
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
Fix build with musl and older Linux kernel #82
Conversation
The musl libc carries its own copy of Linux system calls. When building with Linux headers older than v3.17, musl provides SYS_getrandom definition, but not GRND_NONBLOCK. This causes build failure for libressl and openntpd: getentropy_linux.c: In function 'getentropy_getrandom': getentropy_linux.c:205:42: error: 'GRND_NONBLOCK' undeclared (first use in this function) ret = syscall(SYS_getrandom, buf, len, GRND_NONBLOCK); ^~~~~~~~~~~~~ Define GRND_NONBLOCK locally when its definition is missing to fix the build. There should be no run-time effect. Older kernels return ENOSYS for unsupported syscall().
@4a6f656c Who will handle this PR? |
Just so I understand, what prevents you from just using newer headers? Musl AFAIK does not actually use Kernel headers itself for enabling features at all, unlike Glibc. |
@busterb When the target system uses older kernel I prefer to use kernel headers of the same version to minimize the risk of breakage. But regardless, the entire function is under the |
OK, I can see that. It's odd if Musl is defining syscall definitions itself that are accessible from userspace software, shadowing the kernel syscall definitions. |
This seems like an issue with the musl headers - defining If we want to support this (somewhat broken) use case, then it probably should be with: #if defined(SYS_getrandom) && defined(GRND_NONBLOCK)
|
That works for me @4a6f656c since we do need both. If you don't have the right kernel for this, you'll get an ENOSYS anyway, so the path will fall through in a suboptimal way. Previously, we wouldn't compile the fall back code path if the syscall was defined. |
Should I post an updated pull request along the lines of @4a6f656c suggestion? |
No need, this will go into upstream CVS. This repo is just a mirror, so git pull requests don't apply anyway. |
…getrandom(2) Based on discussion here #82 Suggested fix from jsing@
Updated upstream, thanks all! |
…getrandom(2) Based on discussion here libressl/openbsd#82 Suggested fix from jsing@
The musl libc carries its own copy of Linux system calls. When building
with Linux headers older than v3.17, musl provides SYS_getrandom
definition, but not GRND_NONBLOCK. This causes build failure for
libressl and openntpd:
getentropy_linux.c: In function 'getentropy_getrandom':
getentropy_linux.c:205:42: error: 'GRND_NONBLOCK' undeclared (first use in this function)
ret = syscall(SYS_getrandom, buf, len, GRND_NONBLOCK);
^~~~~~~~~~~~~
Define GRND_NONBLOCK locally when its definition is missing to fix the
build. There should be no run-time effect. Older kernels return ENOSYS
for unsupported syscall().