Skip to contentSkip to conversation

libunwind: Fix build on mips/mips64 for musl targets

PATCH New Khem Raj 1 participant 2 messages Mar 23, 2016

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 libunwind: Fix build on mips/mips64 for musl targets

---
 .../0001-Fix-build-on-mips-musl.patch              | 90 ++++++++++++++++++++++
 meta/recipes-support/libunwind/libunwind_1.1.bb    |  1 +
 2 files changed, 91 insertions(+)
 create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/0001-Fix-build-on-mips-musl.patch
meta/recipes-support/libunwind/libunwind-1.1/0001-Fix-build-on-mips-musl.patch new file +90 -0
new file mode 100644
index 0000000..5426fcc
@@ -0,0 +1,90 @@
+From e623c7703945a5eb6c9a30586ec5e23b2f7396f6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 23 Mar 2016 06:08:59 +0000
+Subject: [PATCH] Fix build on mips/musl
+
+Do not include endian.h on musl it includes
+further headers which can not be compiled in __ASSEMBLER__
+ mode
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+Upstream-Status: Pending
+
+ src/coredump/_UCD_internal.h | 34 ++++++++++++++++++++++++++++++++++
+ src/mips/getcontext.S        |  3 +--
+ 2 files changed, 35 insertions(+), 2 deletions(-)
+
+diff --git a/src/coredump/_UCD_internal.h b/src/coredump/_UCD_internal.h
+index 3c95a2a..80acc15 100644
+--- a/src/coredump/_UCD_internal.h
++++ b/src/coredump/_UCD_internal.h
+@@ -34,6 +34,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ #ifdef HAVE_SYS_PROCFS_H
+ #include <sys/procfs.h> /* struct elf_prstatus */
+ #endif
++#include <sys/reg.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <limits.h>
+@@ -44,6 +45,39 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ 
+ #include "libunwind_i.h"
+ 
++#ifndef __GLIBC__
++#define EF_REG0			6
++#define EF_REG1			7
++#define EF_REG2			8
++#define EF_REG3			9
++#define EF_REG4			10
++#define EF_REG5			11
++#define EF_REG6			12
++#define EF_REG7			13
++#define EF_REG8			14
++#define EF_REG9			15
++#define EF_REG10		16
++#define EF_REG11		17
++#define EF_REG12		18
++#define EF_REG13		19
++#define EF_REG14		20
++#define EF_REG15		21
++#define EF_REG16		22
++#define EF_REG17		23
++#define EF_REG18		24
++#define EF_REG19		25
++#define EF_REG20		26
++#define EF_REG21		27
++#define EF_REG22		28
++#define EF_REG23		29
++#define EF_REG24		30
++#define EF_REG25		31
++#define EF_REG28		34
++#define EF_REG29		35
++#define EF_REG30		36
++#define EF_REG31		37
++#endif
++
+ 
+ #if SIZEOF_OFF_T == 4
+ typedef uint32_t uoff_t;
+diff --git a/src/mips/getcontext.S b/src/mips/getcontext.S
+index d1dbd57..de9b681 100644
+--- a/src/mips/getcontext.S
++++ b/src/mips/getcontext.S
+@@ -24,12 +24,11 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ 
+ #include "offsets.h"
+-#include <endian.h>
+ 
+ 	.text
+ 
+ #if _MIPS_SIM == _ABIO32
+-# if __BYTE_ORDER == __BIG_ENDIAN
++# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #  define OFFSET 4
+ # else
+ #  define OFFSET 0
+-- 
+1.8.3.1
+
meta/recipes-support/libunwind/libunwind_1.1.bb +1 -0
index 1ed525f..aff8409 100644
@@ -12,6 +12,7 @@ SRC_URI = "${SAVANNAH_NONGNU_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
 SRC_URI_append_libc-musl = "\
            file://0001-x86-Stub-out-x86_local_resume.patch \
            file://0001-disable-tests.patch \
+           file://0001-Fix-build-on-mips-musl.patch \
 "
 SRC_URI[md5sum] = "fb4ea2f6fbbe45bf032cd36e586883ce"
 SRC_URI[sha256sum] = "9dfe0fcae2a866de9d3942c66995e4b460230446887dbdab302d41a8aee8d09a"
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 2/2 gdb: Fix build on mips64/musl

Define _ABIO32 if not already defined
heps in fixing gdb for mips64

---
 meta/recipes-devtools/gdb/gdb.inc                  |  1 +
 ...s-linux-nat-Define-_ABIO32-if-not-defined.patch | 37 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-devtools/gdb/gdb/0001-mips-linux-nat-Define-_ABIO32-if-not-defined.patch
meta/recipes-devtools/gdb/gdb.inc +1 -0
index 507f274..d9c864d 100644
@@ -8,6 +8,7 @@ SRC_URI += "file://0002-Change-order-of-CFLAGS.patch \
             file://0001-include-sys-types.h-for-mode_t.patch \
             file://0001-use-asm-sgidefs.h.patch \
             file://force-readline-static.patch \
+            file://0001-mips-linux-nat-Define-_ABIO32-if-not-defined.patch \
            "
 #LDFLAGS_append = " -s"
 #export CFLAGS_append=" -L${STAGING_LIBDIR}"
meta/recipes-devtools/gdb/gdb/0001-mips-linux-nat-Define-_ABIO32-if-not-defined.patch new file +37 -0
new file mode 100644
index 0000000..3173952
@@ -0,0 +1,37 @@
+From e92f8932ef488de2a56db4299131ce6a4eb170bd Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 23 Mar 2016 06:30:09 +0000
+Subject: [PATCH] mips-linux-nat: Define _ABIO32 if not defined
+
+This helps building gdb on mips64 on musl, since
+musl does not provide sgidefs.h this define is
+only defined when GCC is using o32 ABI, in that
+case gcc emits it as built-in define and hence
+it works ok for mips32
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+Upstream-Status: Pending
+
+ gdb/mips-linux-nat.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
+index fd5c705..753f29d 100644
+--- a/gdb/mips-linux-nat.c
++++ b/gdb/mips-linux-nat.c
+@@ -46,6 +46,11 @@
+ #define PTRACE_GET_THREAD_AREA 25
+ #endif
+ 
++/* musl does not define and relies on compiler built-in macros for it   */
++#ifndef _ABIO32
++#define _ABIO32 1
++#endif
++
+ /* Assume that we have PTRACE_GETREGS et al. support.  If we do not,
+    we'll clear this and use PTRACE_PEEKUSER instead.  */
+ static int have_ptrace_regsets = 1;
+-- 
+1.8.3.1
+
Signature · 1 line
1.8.3.1