From patchwork Thu Jan 18 12:51:21 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: 862880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMkNq1Tt2z9s81 for ; Thu, 18 Jan 2018 23:51:38 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D6D71891DE; Thu, 18 Jan 2018 12:51:35 +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 3nWe5BFcqe0B; Thu, 18 Jan 2018 12:51:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 5194A891AC; Thu, 18 Jan 2018 12:51:34 +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 CCC781C12D6 for ; Thu, 18 Jan 2018 12:51:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C729D891AC for ; Thu, 18 Jan 2018 12:51:31 +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 cNugKr6HxTXx for ; Thu, 18 Jan 2018 12:51:30 +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 79A8989152 for ; Thu, 18 Jan 2018 12:51:30 +0000 (UTC) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id D1DC420FAC for ; Thu, 18 Jan 2018 13:51:27 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 3zMkNX4B6zz9rxV for ; Thu, 18 Jan 2018 13:51:24 +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 xoE9T24sM9Th; Thu, 18 Jan 2018 13:51:23 +0100 (CET) Received: from nzxt.fritz.box (port-92-195-223-191.dynamic.qsc.de [92.195.223.191]) (Authenticated sender: joerg.krause@embedded.rocks) by mail.embedded.rocks (Postfix) with ESMTPSA; Thu, 18 Jan 2018 13:51:23 +0100 (CET) From: =?utf-8?q?J=C3=B6rg_Krause?= To: buildroot@buildroot.org Date: Thu, 18 Jan 2018 13:51:21 +0100 Message-Id: <20180118125121.28953-1-joerg.krause@embedded.rocks> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] swupdate: add upstream patch to fix musl build issue 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: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Add upstream patch to fix build issue with the musl C library, as musl does not provide the GNU extension `strndupa()` breaking the build with an undefined reference: ``` ipc/lib.a(network_ipc.o): In function `ipc_postupdate': network_ipc.c:(.text.ipc_postupdate+0x39): undefined reference to `strndupa' ``` The upstream patch provides a compatibility header file adding a definition of `strndupa` if it is not already defined. Backported from: https://github.com/sbabic/swupdate/commit/9867a9d6a21e6b0b9bcba57c3e2398fe671cea17 Fixes: http://autobuild.buildroot.net/results/f674219225d0b67d0bc78fd10b47a865250746f4/ http://autobuild.buildroot.net/results/d2b0cfcfec583d203af1b26152f14ded3ebd3eee/ http://autobuild.buildroot.net/results/1d0cbd1eb9b1b70bd9f4d1c4fae431baee9d105c/ Signed-off-by: Jörg Krause --- ...1-compat.h-introduce-compatibility-header.patch | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 package/swupdate/0001-compat.h-introduce-compatibility-header.patch diff --git a/package/swupdate/0001-compat.h-introduce-compatibility-header.patch b/package/swupdate/0001-compat.h-introduce-compatibility-header.patch new file mode 100644 index 0000000000..5e3bfb0f49 --- /dev/null +++ b/package/swupdate/0001-compat.h-introduce-compatibility-header.patch @@ -0,0 +1,87 @@ +From 9867a9d6a21e6b0b9bcba57c3e2398fe671cea17 Mon Sep 17 00:00:00 2001 +From: Christian Storm +Date: Tue, 16 Jan 2018 10:34:52 +0100 +Subject: [PATCH] compat.h: introduce compatibility header +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Introduce a compat.h housing compatibility definitions +and macros along the lines of commit 7b49b8d having +introduced a compatibility mechanism for Lua. + +First use case (and motivation) is the support for +musl (https://www.musl-libc.org/) which doesn't +bother to provide + char *strndupa(const char *s, size_t n) + +Backported from: 9867a9d6a21e6b0b9bcba57c3e2398fe671cea17 + +Reviewed-by: Stefano Babic +Reported-by: Jörg Krause +Signed-off-by: Christian Storm +Signed-off-by: Jörg Krause +--- + include/compat.h | 24 ++++++++++++++++++++++++ + include/util.h | 1 + + ipc/network_ipc.c | 1 + + 3 files changed, 26 insertions(+) + create mode 100644 include/compat.h + +diff --git a/include/compat.h b/include/compat.h +new file mode 100644 +index 0000000..29d7af1 +--- /dev/null ++++ b/include/compat.h +@@ -0,0 +1,24 @@ ++/* ++ * Author: Christian Storm ++ * Copyright (C) 2018, Siemens AG ++ * ++ * SPDX-License-Identifier: GPL-2.0-or-later ++ */ ++ ++#pragma once ++ ++#ifndef strndupa ++/* ++ * Define char *strndupa(const char *s, size_t n) ++ * for, e.g., musl (https://www.musl-libc.org/) ++ * which does not bother to implement this function. ++ */ ++#define strndupa(s, n) \ ++ (__extension__({ \ ++ const char *__in = (s); \ ++ size_t __len = strnlen(__in, (n)) + 1; \ ++ char *__out = (char *)alloca(__len); \ ++ __out[__len - 1] = '\0'; \ ++ (char *)memcpy(__out, __in, __len - 1); \ ++ })) ++#endif +diff --git a/include/util.h b/include/util.h +index bec2975..d43cd8c 100644 +--- a/include/util.h ++++ b/include/util.h +@@ -12,6 +12,7 @@ + #include + #include "swupdate.h" + #include "swupdate_status.h" ++#include "compat.h" + + #define NOTIFY_BUF_SIZE 2048 + #define ENOMEM_ASPRINTF -1 +diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c +index 3f197c7..48f6fcc 100644 +--- a/ipc/network_ipc.c ++++ b/ipc/network_ipc.c +@@ -27,6 +27,7 @@ + #include + + #include "network_ipc.h" ++#include "compat.h" + + #ifdef CONFIG_SOCKET_CTRL_PATH + static char* SOCKET_CTRL_PATH = (char*)CONFIG_SOCKET_CTRL_PATH; +-- +2.15.1 +