openntpd: fix musl build with older kernel headers
PATCH 1/2 openntpd: fix musl build with older kernel headers
musl provides its own SYS_getrandom definition, but not GRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition of GRND_NONBLOCK to fix the build.
The getentropy_linux.c file is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.
Fixes:
http://autobuild.buildroot.net/results/623/6235ddc095bc1984439e7339d590b11581a3e257/
http://autobuild.buildroot.net/results/648/648e7c91edcf893fa780de9bb44c05f5f842a2e8/
http://autobuild.buildroot.net/results/7da/7da71263a6e9b780031f1f6185c760d11dfc994e/
--- package/openntpd/0002-fix-musl.patch | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/openntpd/0002-fix-musl.patch
package/openntpd/0002-fix-musl.patch new file +38 -0
@@ -0,0 +1,38 @@ +From: Baruch Siach <[email protected]> +Date: Fri, 29 Sep 2017 10:06:52 +0300 +Subject: [PATCH] Fix build with musl and older Linux kernel + +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(). + +[ from upstream pull request with file location changed ] +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/libressl-portable/openbsd/pull/82 + +diff -Nuar openntpd-6.2p2-orig/compat/getentropy_linux.c openntpd-6.2p2/compat/getentropy_linux.c +--- openntpd-6.2p2-orig/compat/getentropy_linux.c 2017-09-07 22:12:02.000000000 +0300 ++++ openntpd-6.2p2/compat/getentropy_linux.c 2017-09-29 11:54:54.856245770 +0300 +@@ -194,6 +194,11 @@ + } + + #ifdef SYS_getrandom ++ ++#ifndef GRND_NONBLOCK ++#define GRND_NONBLOCK 0x0001 ++#endif ++ + static int + getentropy_getrandom(void *buf, size_t len) + {
Signature · 1 line
2.14.2
PATCH 2/2 libressl: fix musl build with older kernel headers
musl provides its own SYS_getrandom definition, but not GRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition of GRND_NONBLOCK to fix the build.
The following defconfig reproduces the build failure:
BR2_x86_pentium_mmx=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_KERNEL_HEADERS_3_12=y
BR2_PACKAGE_LIBRESSL=y
The getentropy_linux.c file is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.
--- package/libressl/0002-fix-musl.patch | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/libressl/0002-fix-musl.patch
package/libressl/0002-fix-musl.patch new file +38 -0
@@ -0,0 +1,38 @@ +From: Baruch Siach <[email protected]> +Date: Fri, 29 Sep 2017 10:06:52 +0300 +Subject: [PATCH] Fix build with musl and older Linux kernel + +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(). + +[ from upstream pull request with file location changed ] +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/libressl-portable/openbsd/pull/82 + +diff -Nuar libressl-2.5.5-orig/crypto/compat/getentropy_linux.c libressl-2.5.5/crypto/compat/getentropy_linux.c +--- libressl-2.5.5-orig/crypto/compat/getentropy_linux.c 2017-07-09 13:59:48.000000000 +0300 ++++ libressl-2.5.5/crypto/compat/getentropy_linux.c 2017-09-29 10:03:32.447958829 +0300 +@@ -194,6 +194,11 @@ + } + + #ifdef SYS_getrandom ++ ++#ifndef GRND_NONBLOCK ++#define GRND_NONBLOCK 0x0001 ++#endif ++ + static int + getentropy_getrandom(void *buf, size_t len) + {
Signature · 1 line
2.14.2
Arnout Vandecappelle
AppliedPATCH 2/2 libressl: fix musl build with older kernel headers
Quoted 11 lines · Baruch Siach
musl provides its own
SYS_getrandomdefinition, but notGRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition ofGRND_NONBLOCKto fix the build.The following defconfig reproduces the build failure:
BR2_x86_pentium_mmx=y
BR2_TOOLCHAIN_BUILDROOT_MUSL=y
BR2_KERNEL_HEADERS_3_12=y
BR2_PACKAGE_LIBRESSL=y
Quoted 6 lines
The
getentropy_linux.cfile is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.Cc Adam Duskett <[email protected]>Signed-off-by Baruch Siach <[email protected]>
Applied to master, thanks.
package/libressl/0002-fix-musl.patch
Quoted 6 lines
--- package/libressl/0002-fix-musl.patch | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/libressl/0002-fix-musl.patchpackage/libressl/0002-fix-musl.patch +0
-0
But I changed the name to correspond to the subject line.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Arnout Vandecappelle
AppliedPATCH 1/2 openntpd: fix musl build with older kernel headers
In reply to Baruch SiachQuoted 8 lines · Baruch Siach
musl provides its own
SYS_getrandomdefinition, but notGRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition ofGRND_NONBLOCKto fix the build.The
getentropy_linux.cfile is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.
Quoted 6 lines
Fixes:
http://autobuild.buildroot.net/results/623/6235ddc095bc1984439e7339d590b11581a3e257/
http://autobuild.buildroot.net/results/648/648e7c91edcf893fa780de9bb44c05f5f842a2e8/
http://autobuild.buildroot.net/results/7da/7da71263a6e9b780031f1f6185c760d11dfc994e/Signed-off-by Baruch Siach <[email protected]>
Applied to master, thanks, after fixing a small typo in the commit log.
Regards,
Arnout
Quoted 50 lines
--- package/openntpd/0002-fix-musl.patch | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/openntpd/0002-fix-musl.patchpackage/openntpd/0002-fix-musl.patch new file +38
-0@@ -0,0 +1,38 @@ +From: Baruch Siach <[email protected]> +Date: Fri, 29 Sep 2017 10:06:52 +0300 +Subject: [PATCH] Fix build with musl and older Linux kernel + +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(). + +[ from upstream pull request with file location changed ] +Signed-off-by: Baruch Siach <[email protected]> +--- +Upstream status: https://github.com/libressl-portable/openbsd/pull/82 + +diff -Nuar openntpd-6.2p2-orig/compat/getentropy_linux.c openntpd-6.2p2/compat/getentropy_linux.c +--- openntpd-6.2p2-orig/compat/getentropy_linux.c 2017-09-07 22:12:02.000000000 +0300 ++++ openntpd-6.2p2/compat/getentropy_linux.c 2017-09-29 11:54:54.856245770 +0300 +@@ -194,6 +194,11 @@ + } + + #ifdef SYS_getrandom ++ ++#ifndef GRND_NONBLOCK ++#define GRND_NONBLOCK 0x0001 ++#endif ++ + static int + getentropy_getrandom(void *buf, size_t len) + {
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/2 openntpd: fix musl build with older kernel headers
In reply to Baruch SiachQuoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Baruch" == Baruch Siach <[email protected]> writes:
musl provides its own
SYS_getrandomdefinition, but notGRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition ofGRND_NONBLOCKto fix the build.The
getentropy_linux.cfile is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.
FYI, I believe upstream openntpd development only supports openbsd, similar to E.G. openssh, and the linux specific code is in openntpd-portable:
https://github.com/openntpd-portable/openntpd-portable
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/2 openntpd: fix musl build with older kernel headers
Hi Peter,
Quoted 10 lines · Peter Korsgaard
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Baruch" == Baruch Siach <[email protected]> writes:
musl provides its own
SYS_getrandomdefinition, but notGRND_NONBLOCK. This breaks the build with kernel headers older than v3.17. Add a patch adding a local definition ofGRND_NONBLOCKto fix the build.The
getentropy_linux.cfile is in upstream tarball, but not in its git repository. It originates form OpenBSD. For this reason the patch is against the tarball, but not git formatted.
Quoted 5 lines
FYI, I believe upstream openntpd development only supports openbsd, similar to E.G. openssh, and the linux specific code is in openntpd-portable:
The getentropy_linux.c file is not in the openntpd-portable git repo:
https://github.com/openntpd-portable/openntpd-portable/tree/master/compat
It is apparently copied when generating the tarball from the code openbsd libressl:
The same goes for libressl-portable, the target of the second patch in this series. For that reason the upstream pull request is against the openbsd tree, the real upstream for that file.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -PATCH 1/2 openntpd: fix musl build with older kernel headers
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Baruch" == Baruch Siach <[email protected]> writes:
Hi,
Quoted 9 lines
Quoted 5 lines
FYI, I believe upstream openntpd development only supports openbsd, similar to E.G. openssh, and the linux specific code is in openntpd-portable:
The
getentropy_linux.cfile is not in the openntpd-portable git repo:https://github.com/openntpd-portable/openntpd-portable/tree/master/compat
Sorry - You're right, I must have been tired yesterday evening.
Quoted 4 lines
It is apparently copied when generating the tarball from the code openbsd libressl:
What a mess :/
Quoted 3 lines
The same goes for libressl-portable, the target of the second patch in this series. For that reason the upstream pull request is against the openbsd tree, the real upstream for that file.
Ok, thanks.
Signature · 1 line
Bye, Peter Korsgaard