From patchwork Mon Nov 28 22:20:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 700175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tSLk633Flz9vDl for ; Tue, 29 Nov 2016 09:21:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7A6372FD82; Mon, 28 Nov 2016 22:21:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i3XiNnVWBTIS; Mon, 28 Nov 2016 22:21:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 299192A224; Mon, 28 Nov 2016 22:21:11 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 438AB1C0057 for ; Mon, 28 Nov 2016 22:21:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4378E2A15B for ; Mon, 28 Nov 2016 22:21:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aPwERaK2eWwP for ; Mon, 28 Nov 2016 22:21:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by silver.osuosl.org (Postfix) with ESMTP id D169426558 for ; Mon, 28 Nov 2016 22:21:00 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 234A3207C2; Mon, 28 Nov 2016 23:20:59 +0100 (CET) Received: from localhost (LFbn-1-6691-76.w90-120.abo.wanadoo.fr [90.120.129.76]) by mail.free-electrons.com (Postfix) with ESMTPSA id E2B1120797; Mon, 28 Nov 2016 23:20:58 +0100 (CET) From: Thomas Petazzoni To: buildroot@buildroot.org Date: Mon, 28 Nov 2016 23:20:58 +0100 Message-Id: <1480371658-31317-1-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 Cc: Thomas Petazzoni Subject: [Buildroot] [PATCH] sysklogd: fix build on musl X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit add a stack of small patches that make sysklogd build fine with the musl C library. Build with uClibc and glibc has been tested with those patches applied as well. The first patch is slightly rework (better description and capital letter to the title) in preparation for upstream submission. Fixes: http://autobuild.buildroot.net/results/8fa2bf73f983330884bce2e5ac31e01dee112ba9/ Signed-off-by: Thomas Petazzoni --- ...01-Replace-deprecated-union-wait-with-int.patch | 28 ++++++++ ...01-replace-deprecated-union-wait-with-int.patch | 25 ------- .../0002-Fix-improper-header-includes.patch | 78 ++++++++++++++++++++++ .../0003-Remove-include-of-linux-time.h.patch | 50 ++++++++++++++ ...s-hand-written-klogctl-syscall-implementa.patch | 38 +++++++++++ .../0005-Add-missing-headers-for-open-flags.patch | 46 +++++++++++++ ...006-syslogd.c-rename-dprintf-to-mydprintf.patch | 39 +++++++++++ 7 files changed, 279 insertions(+), 25 deletions(-) create mode 100644 package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch delete mode 100644 package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch create mode 100644 package/sysklogd/0002-Fix-improper-header-includes.patch create mode 100644 package/sysklogd/0003-Remove-include-of-linux-time.h.patch create mode 100644 package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch create mode 100644 package/sysklogd/0005-Add-missing-headers-for-open-flags.patch create mode 100644 package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch diff --git a/package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch b/package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch new file mode 100644 index 0000000..d3fc0dc --- /dev/null +++ b/package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch @@ -0,0 +1,28 @@ +From 76685540a7882926c54bc0d1a8945b7a6abffe40 Mon Sep 17 00:00:00 2001 +From: Ryan Coe +Date: Fri, 7 Oct 2016 19:42:40 -0700 +Subject: [PATCH] Replace deprecated union wait with int + +This is needed for compatibility with glibc >= 2.24. + +Signed-off-by: Ryan Coe +--- + syslogd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/syslogd.c b/syslogd.c +index ea73ea5..ace96c8 100644 +--- a/syslogd.c ++++ b/syslogd.c +@@ -2094,7 +2094,7 @@ void reapchild() + (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ + wait ((int *)0); + #else +- union wait status; ++ int status; + + while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) + ; +-- +2.7.4 + diff --git a/package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch b/package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch deleted file mode 100644 index c9a30e9..0000000 --- a/package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 86fe87cdf097e6286e76eadcc9c11c79be6258f2 Mon Sep 17 00:00:00 2001 -From: Ryan Coe -Date: Fri, 7 Oct 2016 19:42:40 -0700 -Subject: [PATCH 1/1] replace deprecated union wait with int - -Signed-off-by: Ryan Coe ---- - syslogd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/syslogd.c b/syslogd.c -index ea73ea5da5e935bb8cab328559f950cd3afc2d20..ace96c8be40f50d123120c0586a384a298212245 100644 ---- a/syslogd.c -+++ b/syslogd.c -@@ -2094,7 +2094,7 @@ void reapchild() - (void) signal(SIGCHLD, reapchild); /* reset signal handler -ASP */ - wait ((int *)0); - #else -- union wait status; -+ int status; - - while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0) - ; --- -2.9.3 diff --git a/package/sysklogd/0002-Fix-improper-header-includes.patch b/package/sysklogd/0002-Fix-improper-header-includes.patch new file mode 100644 index 0000000..3518ef0 --- /dev/null +++ b/package/sysklogd/0002-Fix-improper-header-includes.patch @@ -0,0 +1,78 @@ +From 7a043f619a91fbb998863c08e3e5e94a4747b11d Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 28 Nov 2016 23:07:36 +0100 +Subject: [PATCH] Fix improper header includes + +When building with the musl C library, a number of warnings indicate +that sysklogd is directly including headers that are considered internal +to the C library: + + - Instead of including , should be included. + + - Instead of including , should be included. + + - Instead of includeing , should be included. + +Signed-off-by: Thomas Petazzoni +--- + klogd.c | 2 +- + ksym_mod.c | 2 +- + syslog.c | 2 +- + syslogd.c | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/klogd.c b/klogd.c +index 6cc80ed..a173353 100644 +--- a/klogd.c ++++ b/klogd.c +@@ -260,7 +260,7 @@ + #include + #include + #include +-#include ++#include + #include + #if !defined(__GLIBC__) + #include +diff --git a/ksym_mod.c b/ksym_mod.c +index 68cd6b6..2e69d65 100644 +--- a/ksym_mod.c ++++ b/ksym_mod.c +@@ -113,7 +113,7 @@ + #include + #include + #include +-#include ++#include + #include + #include "module.h" + #if !defined(__GLIBC__) +diff --git a/syslog.c b/syslog.c +index bdb3ff2..f96b43c 100644 +--- a/syslog.c ++++ b/syslog.c +@@ -55,7 +55,7 @@ static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90"; + #include + #include + #include +-#include ++#include + #include + #if 0 + #include "syslog.h" +diff --git a/syslogd.c b/syslogd.c +index ace96c8..b5e8054 100644 +--- a/syslogd.c ++++ b/syslogd.c +@@ -521,7 +521,7 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88"; + #define SYSLOG_NAMES + #include + #include +-#include ++#include + #include + #include + #include +-- +2.7.4 + diff --git a/package/sysklogd/0003-Remove-include-of-linux-time.h.patch b/package/sysklogd/0003-Remove-include-of-linux-time.h.patch new file mode 100644 index 0000000..374d89b --- /dev/null +++ b/package/sysklogd/0003-Remove-include-of-linux-time.h.patch @@ -0,0 +1,50 @@ +From f4926a61ba2d3766255dd996bf0315bc8fa0c528 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 28 Nov 2016 23:09:03 +0100 +Subject: [PATCH] Remove include of + +klogd.c and ksym_mod.c currently include if GLIBC is not +defined. Unfortunately, this breaks badly with the musl C library: this +C library is not glibc so it doesn't define GLIBC, but it does have a +definition of "struct timespec" in its header file, which conflict with +the one provided by the Linux kernel headers. + +So, this commit simply gets rid of this header inclusion. + +Signed-off-by: Thomas Petazzoni +--- + klogd.c | 3 --- + ksym_mod.c | 3 --- + 2 files changed, 6 deletions(-) + +diff --git a/klogd.c b/klogd.c +index a173353..6505d96 100644 +--- a/klogd.c ++++ b/klogd.c +@@ -262,9 +262,6 @@ + #include + #include + #include +-#if !defined(__GLIBC__) +-#include +-#endif /* __GLIBC__ */ + #include + #include + #include +diff --git a/ksym_mod.c b/ksym_mod.c +index 2e69d65..6e26da1 100644 +--- a/ksym_mod.c ++++ b/ksym_mod.c +@@ -116,9 +116,6 @@ + #include + #include + #include "module.h" +-#if !defined(__GLIBC__) +-#include +-#endif /* __GLIBC__ */ + #include + #include + #include +-- +2.7.4 + diff --git a/package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch b/package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch new file mode 100644 index 0000000..548f160 --- /dev/null +++ b/package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch @@ -0,0 +1,38 @@ +From fe92a7a8197241f7d6b28ea3c8214bb6d2c7fda4 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 28 Nov 2016 23:10:55 +0100 +Subject: [PATCH] Remove bogus hand-written klogctl() syscall implementation + +The way the hand-written klogctl() syscall is written cannot compile, as +_syscall3() is just a function provided by the C library, so calling it +outside of a function doesn't build. + +Since the musl C library provides a klogctl() function, we don't need +this hand-written system call anyway. + +Signed-off-by: Thomas Petazzoni +--- + klogd.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/klogd.c b/klogd.c +index 6505d96..9219671 100644 +--- a/klogd.c ++++ b/klogd.c +@@ -274,13 +274,8 @@ + + #define __LIBRARY__ + #include +-#if !defined(__GLIBC__) +-# define __NR_ksyslog __NR_syslog +-_syscall3(int,ksyslog,int, type, char *, buf, int, len); +-#else + #include + #define ksyslog klogctl +-#endif + + #define LOG_BUFFER_SIZE 4096 + #define LOG_LINE_LENGTH 1000 +-- +2.7.4 + diff --git a/package/sysklogd/0005-Add-missing-headers-for-open-flags.patch b/package/sysklogd/0005-Add-missing-headers-for-open-flags.patch new file mode 100644 index 0000000..1a7ad84 --- /dev/null +++ b/package/sysklogd/0005-Add-missing-headers-for-open-flags.patch @@ -0,0 +1,46 @@ +From 0dff338a704f4ad11a2b78871e1f2a0b8030b4d2 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 28 Nov 2016 23:12:37 +0100 +Subject: [PATCH] Add missing headers for open() flags + +Both pidfile.c and syslog.c use open() and its flags, but forgets to +include all relevant headers, causing build failures with the musl C +library. + +Signed-off-by: Thomas Petazzoni +--- + pidfile.c | 2 ++ + syslog.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/pidfile.c b/pidfile.c +index e0959a0..14de56f 100644 +--- a/pidfile.c ++++ b/pidfile.c +@@ -26,8 +26,10 @@ + + #include + #include ++#include + #include + #include ++#include + #include + #include + #include +diff --git a/syslog.c b/syslog.c +index f96b43c..d09e7aa 100644 +--- a/syslog.c ++++ b/syslog.c +@@ -57,6 +57,8 @@ static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90"; + #include + #include + #include ++#include ++#include + #if 0 + #include "syslog.h" + #include "pathnames.h" +-- +2.7.4 + diff --git a/package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch b/package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch new file mode 100644 index 0000000..a1fb533 --- /dev/null +++ b/package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch @@ -0,0 +1,39 @@ +From 68213f6902d291d2ba1626fd950fd7d4a1329d33 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 28 Nov 2016 23:13:08 +0100 +Subject: [PATCH] syslogd.c: rename dprintf() to mydprintf() + +There is an existing kludge in syslogd.c to rename all dprintf() +function calls and its definition to mydprintf(). This kludge is only +applied when the glibc C library is used (i.e when GLIBC is defined), +because glibc also provides a dprintf() function, with a different +signature and behavior. + +However, the musl C library also provides the dprintf() function (with +the same signature as the one in glibc, obviously), but does not define +the GLIBC macro, causing a conflicting definition of dprintf. + +This commit fixes that by having the rename kludge used unconditionally. + +Signed-off-by: Thomas Petazzoni +--- + syslogd.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/syslogd.c b/syslogd.c +index b5e8054..22a9ed5 100644 +--- a/syslogd.c ++++ b/syslogd.c +@@ -818,9 +818,7 @@ void doexit(int sig); + void init(); + void cfline(char *line, register struct filed *f); + int decode(char *name, struct code *codetab); +-#if defined(__GLIBC__) + #define dprintf mydprintf +-#endif /* __GLIBC__ */ + static void dprintf(char *, ...); + static void allocate_log(void); + void sighup_handler(); +-- +2.7.4 +