From 74eed2f2a5179f06791a2072e22dc2a211850755 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Mon, 16 Jan 2017 08:15:16 +0100
Subject: [PATCH] patches/buildroot: added stuff to build with musl

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 .../0006-fix-monit-for-libmusl.patch          | 32 +++++++++
 .../0007-fix-gdb-build-with-musl.patch        | 61 +++++++++++++++++
 .../buildroot/0008-fix-gdb-musl-more.patch    | 66 +++++++++++++++++++
 3 files changed, 159 insertions(+)
 create mode 100644 patches/buildroot/0006-fix-monit-for-libmusl.patch
 create mode 100644 patches/buildroot/0007-fix-gdb-build-with-musl.patch
 create mode 100644 patches/buildroot/0008-fix-gdb-musl-more.patch

diff --git a/patches/buildroot/0006-fix-monit-for-libmusl.patch b/patches/buildroot/0006-fix-monit-for-libmusl.patch
new file mode 100644
index 000000000..4f6b03fdb
--- /dev/null
+++ b/patches/buildroot/0006-fix-monit-for-libmusl.patch
@@ -0,0 +1,32 @@
+--- ./package/monit/0002-sysdep_LINUX-avoid-GLOB_ONLYDIR-missin-in-libmusl.patch.orig	2017-01-13 10:56:04.777413556 +0100
++++ ./package/monit/0002-sysdep_LINUX-avoid-GLOB_ONLYDIR-missin-in-libmusl.patch	2017-01-13 10:55:21.384411938 +0100
+@@ -0,0 +1,29 @@
++From de586dd21587d52001635dd6be7c70b85a24800f Mon Sep 17 00:00:00 2001
++From: Alessandro Rubini <rubini@gnudd.com>
++Date: Fri, 13 Jan 2017 10:54:09 +0100
++Subject: [PATCH] sysdep_LINUX: avoid GLOB_ONLYDIR, missin in libmusl
++
++/proc/[0-9]* is onlydir by definition, unless /proc is not  mounted,
++but this means the system is in a bad state anyways.
++
++Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
++---
++ src/process/sysdep_LINUX.c | 2 +-
++ 1 file changed, 1 insertion(+), 1 deletion(-)
++
++diff --git a/src/process/sysdep_LINUX.c b/src/process/sysdep_LINUX.c
++index 949d781..651ea49 100644
++--- a/src/process/sysdep_LINUX.c
+++++ b/src/process/sysdep_LINUX.c
++@@ -205,7 +205,7 @@ int initprocesstree_sysdep(ProcessTree_T ** reference) {
++         ASSERT(reference);
++ 
++         /* Find all processes in the /proc directory */
++-        if ((rv = glob("/proc/[0-9]*", GLOB_ONLYDIR, NULL, &globbuf))) {
+++        if ((rv = glob("/proc/[0-9]*", 0, NULL, &globbuf))) {
++                 LogError("system statistic error -- glob failed: %d (%s)\n", rv, STRERROR);
++                 return 0;
++         }
++-- 
++2.1.4
++
diff --git a/patches/buildroot/0007-fix-gdb-build-with-musl.patch b/patches/buildroot/0007-fix-gdb-build-with-musl.patch
new file mode 100644
index 000000000..374bc756a
--- /dev/null
+++ b/patches/buildroot/0007-fix-gdb-build-with-musl.patch
@@ -0,0 +1,61 @@
+--- ./package/gdb/7.9.1/0007-move-__SIGRTMIN.patch.orig	2017-01-13 12:28:21.690620042 +0100
++++ ./package/gdb/7.9.1/0007-move-__SIGRTMIN.patch	2017-01-13 12:28:10.544619626 +0100
+@@ -0,0 +1,58 @@
++From 682b25469e66ea45b214e95962671373983c118f Mon Sep 17 00:00:00 2001
++From: Doug Evans <dje@google.com>
++Date: Mon, 26 Oct 2015 13:30:57 -0700
++Subject: [PATCH] Move __SIGRTMIN.
++
++gdb/ChangeLog:
++
++	* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.
++
++gdb/gdbserver/ChangeLog:
++
++	* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.
++
++[Arnout: removed the parts that don't apply, including ChangeLog]
++Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
++---
++ gdb/ChangeLog             | 4 ++++
++ gdb/gdbserver/ChangeLog   | 4 ++++
++ gdb/gdbserver/linux-low.c | 6 ------
++ gdb/nat/linux-nat.h       | 5 +++++
++ 4 files changed, 13 insertions(+), 6 deletions(-)
++
++diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
++index 7ed67c7..e778c4c 100644
++--- a/gdb/gdbserver/linux-low.c
+++++ b/gdb/gdbserver/linux-low.c
++@@ -70,12 +70,6 @@
++ #define O_LARGEFILE 0
++ #endif
++ 
++-/* This is the kernel's hard limit.  Not to be confused with
++-   SIGRTMIN.  */
++-#ifndef __SIGRTMIN
++-#define __SIGRTMIN 32
++-#endif
++-
++ /* Some targets did not define these ptrace constants from the start,
++    so gdbserver defines them locally here.  In the future, these may
++    be removed after they are added to asm/ptrace.h.  */
++diff --git a/gdb/nat/linux-nat.h b/gdb/nat/linux-nat.h
++index 0633fa9..70e6274 100644
++--- a/gdb/nat/linux-nat.h
+++++ b/gdb/nat/linux-nat.h
++@@ -25,6 +25,11 @@
++ struct lwp_info;
++ struct arch_lwp_info;
++ 
+++/* This is the kernel's hard limit.  Not to be confused with SIGRTMIN.  */
+++#ifndef __SIGRTMIN
+++#define __SIGRTMIN 32
+++#endif
+++
++ /* Unlike other extended result codes, WSTOPSIG (status) on
++    PTRACE_O_TRACESYSGOOD syscall events doesn't return SIGTRAP, but
++    instead SIGTRAP with bit 7 set.  */
++-- 
++1.9.4
++
diff --git a/patches/buildroot/0008-fix-gdb-musl-more.patch b/patches/buildroot/0008-fix-gdb-musl-more.patch
new file mode 100644
index 000000000..b08caba18
--- /dev/null
+++ b/patches/buildroot/0008-fix-gdb-musl-more.patch
@@ -0,0 +1,66 @@
+--- ./package/gdb/7.9.1/0006-musl-Move-W_STOPCODE-to-common-gdb_wait-h.patch.orig	2017-01-16 09:24:23.097874596 +0100
++++ ./package/gdb/7.9.1/0006-musl-Move-W_STOPCODE-to-common-gdb_wait-h.patch	2016-10-18 02:43:07.221913059 +0200
+@@ -0,0 +1,63 @@
++From 963843d4d07aef6caa296dacf191f8adc9518596 Mon Sep 17 00:00:00 2001
++From: Doug Evans <dje@google.com>
++Date: Mon, 26 Oct 2015 13:24:01 -0700
++Subject: [PATCH] musl: Move W_STOPCODE to common/gdb_wait.h.
++
++gdb/ChangeLog:
++
++	* common/gdb_wait.h (W_STOPCODE): Define, moved here from
++	gdbserver/linux-low.c.
++	(WSETSTOP): Simplify.
++
++gdb/gdbserver/ChangeLog:
++
++	* linux-low.c (W_STOPCODE): Moved to common/gdb_wait.h.
++
++[Arnout: removed the parts that don't apply, including ChangeLog]
++Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
++---
++ gdb/ChangeLog             | 6 ++++++
++ gdb/common/gdb_wait.h     | 8 ++++----
++ gdb/gdbserver/ChangeLog   | 4 ++++
++ gdb/gdbserver/linux-low.c | 4 ----
++ 4 files changed, 14 insertions(+), 8 deletions(-)
++
++diff --git a/gdb/common/gdb_wait.h b/gdb/common/gdb_wait.h
++index 9b250d2..412f813 100644
++--- a/gdb/common/gdb_wait.h
+++++ b/gdb/common/gdb_wait.h
++@@ -85,12 +85,12 @@
++ # endif
++ #endif
++ 
+++#ifndef W_STOPCODE
+++#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
+++#endif
+++
++ #ifndef	WSETSTOP
++-# ifdef	W_STOPCODE
++ #define	WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
++-# else
++-#define WSETSTOP(w,sig)	   ((w) = (0177 | ((sig) << 8)))
++-# endif
++ #endif
++ 
++ /* For native GNU/Linux we may use waitpid and the __WCLONE option.
++diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
++index 0c552b8..7ed67c7 100644
++--- a/gdb/gdbserver/linux-low.c
+++++ b/gdb/gdbserver/linux-low.c
++@@ -70,10 +70,6 @@
++ #define O_LARGEFILE 0
++ #endif
++ 
++-#ifndef W_STOPCODE
++-#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
++-#endif
++-
++ /* This is the kernel's hard limit.  Not to be confused with
++    SIGRTMIN.  */
++ #ifndef __SIGRTMIN
++-- 
++1.9.4
++
-- 
GitLab