Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] package/libbsd: enable for non-glibc toolchains
Date: Mon, 2 Apr 2018 14:34:25 +0200	[thread overview]
Message-ID: <20180402123425.GK3625@scaer> (raw)
In-Reply-To: <20180314194356.15839-1-joerg.krause@embedded.rocks>

J?rg, All,

On 2018-03-14 20:43 +0100, J?rg Krause spake thusly:
> 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.

> 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
> 
> Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
> ---
>  ...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
> 
> diff --git a/package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch b/package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch
> new file mode 100644
> index 0000000000..fdf45bdef6
> --- /dev/null
> +++ b/package/libbsd/0001-Fix-function-declaration-protection-for-glibc-alread.patch
> @@ -0,0 +1,80 @@
> +From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001
> +From: Guillem Jover <guillem@hadrons.org>
> +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 <joerg.krause@embedded.rocks>
> +Signed-off-by: Guillem Jover <guillem@hadrons.org>
> +Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
> +---
> + 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
> +
> diff --git a/package/libbsd/Config.in b/package/libbsd/Config.in
> index 11e4c4d974..f6c2e4be4b 100644
> --- a/package/libbsd/Config.in
> +++ b/package/libbsd/Config.in
> @@ -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
> -- 
> 2.16.2
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'

      parent reply	other threads:[~2018-04-02 12:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 19:43 [Buildroot] [PATCH] package/libbsd: enable for non-glibc toolchains Jörg Krause
2018-03-14 21:09 ` Thomas Petazzoni
2018-03-14 21:13   ` Jörg Krause
2018-03-15  2:57     ` Thomas Petazzoni
2018-03-31 20:52 ` Thomas Petazzoni
2018-04-02 12:34 ` Yann E. MORIN [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180402123425.GK3625@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox