From patchwork Wed Mar 14 19:43:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B6rg_Krause?= X-Patchwork-Id: 886013 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=embedded.rocks Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 401hxR0Vyrz9sT6 for ; Thu, 15 Mar 2018 06:44:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E32A387BE9; Wed, 14 Mar 2018 19:44:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ESUXs7DGr1cH; Wed, 14 Mar 2018 19:44:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1B84387C5B; Wed, 14 Mar 2018 19:44:07 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 970471BF20D for ; Wed, 14 Mar 2018 19:44:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 93B3387CA9 for ; Wed, 14 Mar 2018 19:44:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 77u4MSBoGiM3 for ; Wed, 14 Mar 2018 19:44:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) by whitealder.osuosl.org (Postfix) with ESMTPS id 1567587CE7 for ; Wed, 14 Mar 2018 19:44:03 +0000 (UTC) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 3DEFD20FF2 for ; Wed, 14 Mar 2018 20:44:01 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 401hxD385Yz9rxb; Wed, 14 Mar 2018 20:44:00 +0100 (CET) Received: from mail.embedded.rocks ([127.0.0.1]) by localhost (mail.embedded.rocks [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id ltfyjCJ-KGoa; Wed, 14 Mar 2018 20:43:59 +0100 (CET) Received: from nzxt.fritz.box (port-92-195-29-234.dynamic.qsc.de [92.195.29.234]) (Authenticated sender: joerg.krause@embedded.rocks) by mail.embedded.rocks (Postfix) with ESMTPSA; Wed, 14 Mar 2018 20:43:59 +0100 (CET) From: =?utf-8?q?J=C3=B6rg_Krause?= To: buildroot@buildroot.org Date: Wed, 14 Mar 2018 20:43:56 +0100 Message-Id: <20180314194356.15839-1-joerg.krause@embedded.rocks> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] package/libbsd: enable for non-glibc toolchains X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E . MORIN" Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 Signed-off-by: Jörg Krause --- ...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 +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 +Signed-off-by: Guillem Jover +Signed-off-by: Jörg Krause +--- + 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