package/libbsd: enable for non-glibc toolchains
PATCH 1/1 package/libbsd: enable for non-glibc toolchains
libbsd builds now almost fine with a musl or uClibc toolchain, except for one issue introduced in the latest version bump. Upstream commit 22fbd62368c39de8ac5e249d1502d5ac0ffdef30 [1] uses the glibc-only macro __GLIBC_PREREQ. The issue is fixed by the attached patch from upstream, which fixes the use of __GLIBC_PREREQ on non-glibc toolchains.
Backported from:
https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490
netcat-openbsd is the only package selecting libbsd. However, building it still needs a glibc toolchain, as it uses b64_ntop which is not available in musl or uClibc.
Build has been successfully tested with:
* armv7-eabihf--glibc--bleeding-edge-2017.11-1
* armv7-eabihf--musl--bleeding-edge-2018.02-1
* armv7-eabihf--uclibc--bleeding-edge-2018.02-1
[1] https://cgit.freedesktop.org/libbsd/commit/?id=22fbd62368c39de8ac5e249d1502d5ac0ffdef30
--- ...n-declaration-protection-for-glibc-alread.patch | 80 ++++++++++++++++++++++ package/libbsd/Config.in | 5 +- 2 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch
package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch new file +80 -0
@@ -0,0 +1,80 @@ +From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001 +From: Guillem Jover <[email protected]> +Date: Tue, 6 Mar 2018 01:39:45 +0100 +Subject: [PATCH] Fix function declaration protection for glibc already + providing them +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On non-glibc based systems we cannot unconditionally use the +__GLIBC_PREREQ macro as it gets expanded before evaluation. Instead, +if it is undefined, define it to 0. + +We should also always declare these functions on non-glibc based +systems. And on systems with a new enough glibc, which provides these +functions, we should still provide the declarations if _GNU_SOURCE +is *not* defined. + +Backported from: +https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490 + +Reported-by: J?rg Krause <[email protected]> +Signed-off-by: Guillem Jover <[email protected]> +Signed-off-by: J?rg Krause <[email protected]> +--- + include/bsd/stdlib.h | 3 ++- + include/bsd/string.h | 3 ++- + include/bsd/sys/cdefs.h | 8 ++++++++ + 3 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h +index 8d33d1f..a5b063c 100644 +--- a/include/bsd/stdlib.h ++++ b/include/bsd/stdlib.h +@@ -71,7 +71,8 @@ int sradixsort(const unsigned char **base, int nmemb, + const unsigned char *table, unsigned endbyte); + + void *reallocf(void *ptr, size_t size); +-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26) ++#if !defined(__GLIBC__) || \ ++ (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE))) + void *reallocarray(void *ptr, size_t nmemb, size_t size); + #endif + +diff --git a/include/bsd/string.h b/include/bsd/string.h +index 29097f6..f987fee 100644 +--- a/include/bsd/string.h ++++ b/include/bsd/string.h +@@ -46,7 +46,8 @@ size_t strlcat(char *dst, const char *src, size_t siz); + char *strnstr(const char *str, const char *find, size_t str_len); + void strmode(mode_t mode, char *str); + +-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25) ++#if !defined(__GLIBC__) || \ ++ (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE))) + void explicit_bzero(void *buf, size_t len); + #endif + __END_DECLS +diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h +index b4c8f30..d1cc419 100644 +--- a/include/bsd/sys/cdefs.h ++++ b/include/bsd/sys/cdefs.h +@@ -58,6 +58,14 @@ + #endif + #endif + ++/* ++ * On non-glibc based systems, we cannot unconditionally use the ++ * __GLIBC_PREREQ macro as it gets expanded before evaluation. ++ */ ++#ifndef __GLIBC_PREREQ ++#define __GLIBC_PREREQ(maj, min) 0 ++#endif ++ + /* + * Some kFreeBSD headers expect those macros to be set for sanity checks. + */ +-- +2.16.2 +
package/libbsd/Config.in +2 -3
@@ -9,7 +9,6 @@ config BR2_PACKAGE_LIBBSD bool "libbsd" depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS depends on BR2_TOOLCHAIN_HAS_THREADS - depends on BR2_TOOLCHAIN_USES_GLIBC help This library provides useful functions commonly found on BSD systems, and lacking on others like GNU systems, thus making
@@ -19,6 +18,6 @@ config BR2_PACKAGE_LIBBSD http://libbsd.freedesktop.org/ -comment "libbsd needs a glibc toolchain w/ threads" +comment "libbsd needs a toolchain w/ threads" depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS - depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC + depends on !BR2_TOOLCHAIN_HAS_THREADS
Signature · 1 line
2.16.2
PATCH 1/1 package/libbsd: enable for non-glibc toolchains
Hello J?rg,
Quoted 18 lines · J?rg Krause
libbsd builds now almost fine with a musl or uClibc toolchain, except for one issue introduced in the latest version bump. Upstream commit
22fbd62368c39de8ac5e249d1502d5ac0ffdef30[1] uses the glibc-only macro__GLIBC_PREREQ. The issue is fixed by the attached patch from upstream, which fixes the use of__GLIBC_PREREQon non-glibc toolchains.Backported from:
https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490netcat-openbsd is the only package selecting libbsd. However, building it still needs a glibc toolchain, as it uses
b64_ntopwhich is not available in musl or uClibc.Build has been successfully tested with:
* armv7-eabihf--glibc--bleeding-edge-2017.11-1
* armv7-eabihf--musl--bleeding-edge-2018.02-1
* armv7-eabihf--uclibc--bleeding-edge-2018.02-1
Quoted 6 lines
[1] https://cgit.freedesktop.org/libbsd/commit/?id=22fbd62368c39de8ac5e249d1502d5ac0ffdef30
Signed-off-by J?rg Krause <[email protected]>--- ...n-declaration-protection-for-glibc-alread.patch | 80 ++++++++++++++++++++++ package/libbsd/Config.in | 5 +-
Does this allows to enable netcat-openbsd on uclibc and musl ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com
PATCH 1/1 package/libbsd: enable for non-glibc toolchains
Quoted 21 lines · Thomas Petazzoni
Hello J?rg,
Quoted 18 lines · J?rg Krause
libbsd builds now almost fine with a musl or uClibc toolchain, except for one issue introduced in the latest version bump. Upstream commit
22fbd62368c39de8ac5e249d1502d5ac0ffdef30[1] uses the glibc-only macro__GLIBC_PREREQ. The issue is fixed by the attached patch from upstream, which fixes the use of__GLIBC_PREREQon non-glibc toolchains.Backported from:
https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490netcat-openbsd is the only package selecting libbsd. However, building it still needs a glibc toolchain, as it uses
b64_ntopwhich is not available in musl or uClibc.Build has been successfully tested with:
* armv7-eabihf--glibc--bleeding-edge-2017.11-1
* armv7-eabihf--musl--bleeding-edge-2018.02-1
* armv7-eabihf--uclibc--bleeding-edge-2018.02-1
Quoted 8 lines
Quoted 6 lines
[1] https://cgit.freedesktop.org/libbsd/commit/?id=22fbd62368c39de8ac5e249d1502d5ac0ffdef30
Signed-off-by J?rg Krause <[email protected]>--- ...n-declaration-protection-for-glibc-alread.patch | 80 ++++++++++++++++++++++ package/libbsd/Config.in | 5 +-Does this allows to enable netcat-openbsd on uclibc and musl ?
No. You find the reason why in the commit log :-)
Best regards,
J?rg Krause
PATCH 1/1 package/libbsd: enable for non-glibc toolchains
Hello,
Quoted 3 lines · J?rg Krause
Quoted 1 line
Does this allows to enable netcat-openbsd on uclibc and musl ?
No. You find the reason why in the commit log :-)
Gaah sorry, I should have read the commit log entirely instead of just looking at the patch. Sorry about that.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com
Thomas Petazzoni
AppliedPATCH 1/1 package/libbsd: enable for non-glibc toolchains
In reply to Jörg KrauseHello,
Quoted 18 lines · J?rg Krause
libbsd builds now almost fine with a musl or uClibc toolchain, except for one issue introduced in the latest version bump. Upstream commit
22fbd62368c39de8ac5e249d1502d5ac0ffdef30[1] uses the glibc-only macro__GLIBC_PREREQ. The issue is fixed by the attached patch from upstream, which fixes the use of__GLIBC_PREREQon non-glibc toolchains.Backported from:
https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490netcat-openbsd is the only package selecting libbsd. However, building it still needs a glibc toolchain, as it uses
b64_ntopwhich is not available in musl or uClibc.Build has been successfully tested with:
* armv7-eabihf--glibc--bleeding-edge-2017.11-1
* armv7-eabihf--musl--bleeding-edge-2018.02-1
* armv7-eabihf--uclibc--bleeding-edge-2018.02-1
Quoted 8 lines
[1] https://cgit.freedesktop.org/libbsd/commit/?id=22fbd62368c39de8ac5e249d1502d5ac0ffdef30
Signed-off-by J?rg Krause <[email protected]>--- ...n-declaration-protection-for-glibc-alread.patch | 80 ++++++++++++++++++++++ package/libbsd/Config.in | 5 +- 2 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/libbsd: enable for non-glibc toolchains
In reply to Jörg KrauseJ?rg, All,
On 2018-03-14 20:43 +0100, J?rg Krause spake thusly:
Quoted 1 line
libbsd builds now almost fine with a musl or uClibc toolchain, except
"almost" being the right word to use, as it it is still broken:
bfin | libbsd-0.8.7 | http://autobuild.buildroot.net/results/46deb0a042c63430f539cd52e6210aeb69bd625d bfin | libbsd-0.8.7 | http://autobuild.buildroot.net/results/2a86e978d071a22075f8d5c4dcc614dc65f71cf3 powerpc | libbsd-0.8.7 | http://autobuild.buildroot.net/results/ee3ad5172d6a218dfde4cf3e9fecf1906b0fc642 powerpc | libbsd-0.8.7 | http://autobuild.buildroot.net/results/2e6f144f875d873001ba4fd61951f7f213ab5c10 xtensa | libbsd-0.8.7 | http://autobuild.buildroot.net/results/626d7c0237594052e40f81f8969169bfeba96bcf xtensa | libbsd-0.8.7 | http://autobuild.buildroot.net/results/cc87f1c8b0b1c5872df92c4653dbeccaa5e5de13
Could have a look?
Regards,
Yann E. MORIN.
Quoted 136 lines
for one issue introduced in the latest version bump. Upstream commit
22fbd62368c39de8ac5e249d1502d5ac0ffdef30[1] uses the glibc-only macro__GLIBC_PREREQ. The issue is fixed by the attached patch from upstream, which fixes the use of__GLIBC_PREREQon non-glibc toolchains.Backported from:
https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490netcat-openbsd is the only package selecting libbsd. However, building it still needs a glibc toolchain, as it uses
b64_ntopwhich is not available in musl or uClibc.Build has been successfully tested with:
* armv7-eabihf--glibc--bleeding-edge-2017.11-1
* armv7-eabihf--musl--bleeding-edge-2018.02-1
* armv7-eabihf--uclibc--bleeding-edge-2018.02-1[1] https://cgit.freedesktop.org/libbsd/commit/?id=22fbd62368c39de8ac5e249d1502d5ac0ffdef30
Signed-off-by J?rg Krause <[email protected]>--- ...n-declaration-protection-for-glibc-alread.patch | 80 ++++++++++++++++++++++ package/libbsd/Config.in | 5 +- 2 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patchpackage/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch new file +80
-0@@ -0,0 +1,80 @@ +From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001 +From: Guillem Jover <[email protected]> +Date: Tue, 6 Mar 2018 01:39:45 +0100 +Subject: [PATCH] Fix function declaration protection for glibc already + providing them +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On non-glibc based systems we cannot unconditionally use the +__GLIBC_PREREQ macro as it gets expanded before evaluation. Instead, +if it is undefined, define it to 0. + +We should also always declare these functions on non-glibc based +systems. And on systems with a new enough glibc, which provides these +functions, we should still provide the declarations if _GNU_SOURCE +is *not* defined. + +Backported from: +https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490 + +Reported-by: J?rg Krause <[email protected]> +Signed-off-by: Guillem Jover <[email protected]> +Signed-off-by: J?rg Krause <[email protected]> +--- + include/bsd/stdlib.h | 3 ++- + include/bsd/string.h | 3 ++- + include/bsd/sys/cdefs.h | 8 ++++++++ + 3 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h +index 8d33d1f..a5b063c 100644 +--- a/include/bsd/stdlib.h ++++ b/include/bsd/stdlib.h +@@ -71,7 +71,8 @@ int sradixsort(const unsigned char **base, int nmemb, + const unsigned char *table, unsigned endbyte); + + void *reallocf(void *ptr, size_t size); +-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26) ++#if !defined(__GLIBC__) || \ ++ (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE))) + void *reallocarray(void *ptr, size_t nmemb, size_t size); + #endif + +diff --git a/include/bsd/string.h b/include/bsd/string.h +index 29097f6..f987fee 100644 +--- a/include/bsd/string.h ++++ b/include/bsd/string.h +@@ -46,7 +46,8 @@ size_t strlcat(char *dst, const char *src, size_t siz); + char *strnstr(const char *str, const char *find, size_t str_len); + void strmode(mode_t mode, char *str); + +-#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25) ++#if !defined(__GLIBC__) || \ ++ (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE))) + void explicit_bzero(void *buf, size_t len); + #endif + __END_DECLS +diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h +index b4c8f30..d1cc419 100644 +--- a/include/bsd/sys/cdefs.h ++++ b/include/bsd/sys/cdefs.h +@@ -58,6 +58,14 @@ + #endif + #endif + ++/* ++ * On non-glibc based systems, we cannot unconditionally use the ++ * __GLIBC_PREREQ macro as it gets expanded before evaluation. ++ */ ++#ifndef __GLIBC_PREREQ ++#define __GLIBC_PREREQ(maj, min) 0 ++#endif ++ + /* + * Some kFreeBSD headers expect those macros to be set for sanity checks. + */ +-- +2.16.2 +package/libbsd/Config.in +2
-3@@ -9,7 +9,6 @@ config BR2_PACKAGE_LIBBSD bool "libbsd" depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS depends on BR2_TOOLCHAIN_HAS_THREADS - depends on BR2_TOOLCHAIN_USES_GLIBC help This library provides useful functions commonly found on BSD systems, and lacking on others like GNU systems, thus making@@ -19,6 +18,6 @@ config BR2_PACKAGE_LIBBSD http://libbsd.freedesktop.org/ -comment "libbsd needs a glibc toolchain w/ threads" +comment "libbsd needs a toolchain w/ threads" depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS - depends on !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_USES_GLIBC + depends on !BR2_TOOLCHAIN_HAS_THREADSSignature · 1 line
2.16.2
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'