ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/package/devel/gdb/patches/110-shared_libgcc.patch b/package/devel/gdb/patches/110-shared_libgcc.patch
new file mode 100644
index 0000000..d9dcafe
--- /dev/null
+++ b/package/devel/gdb/patches/110-shared_libgcc.patch
@@ -0,0 +1,76 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -1401,13 +1401,13 @@ if test -z "$LD"; then
+   fi
+ fi
+ 
+-# Check whether -static-libstdc++ -static-libgcc is supported.
++# Check whether -static-libstdc++ is supported.
+ have_static_libs=no
+ if test "$GCC" = yes; then
+   saved_LDFLAGS="$LDFLAGS"
+ 
+-  LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
+-  AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
++  LDFLAGS="$LDFLAGS -static-libstdc++"
++  AC_MSG_CHECKING([whether g++ accepts -static-libstdc++])
+   AC_LANG_PUSH(C++)
+   AC_LINK_IFELSE([AC_LANG_SOURCE([
+ #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+@@ -1837,7 +1837,7 @@ AC_ARG_WITH(stage1-ldflags,
+  # trust that they are doing what they want.
+  if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
+      -a "$have_static_libs" = yes; then
+-   stage1_ldflags="-static-libstdc++ -static-libgcc"
++   stage1_ldflags="-static-libstdc++"
+  fi])
+ AC_SUBST(stage1_ldflags)
+ 
+@@ -1866,7 +1866,7 @@ AC_ARG_WITH(boot-ldflags,
+  # statically.  But if the user explicitly specified the libraries to
+  # use, trust that they are doing what they want.
+  if test "$poststage1_libs" = ""; then
+-   poststage1_ldflags="-static-libstdc++ -static-libgcc"
++   poststage1_ldflags="-static-libstdc++"
+  fi])
+ case $target in
+   *-darwin2* | *-darwin1[[56789]]*)
+--- a/configure
++++ b/configure
+@@ -5414,14 +5414,14 @@ if test -z "$LD"; then
+   fi
+ fi
+ 
+-# Check whether -static-libstdc++ -static-libgcc is supported.
++# Check whether -static-libstdc++ is supported.
+ have_static_libs=no
+ if test "$GCC" = yes; then
+   saved_LDFLAGS="$LDFLAGS"
+ 
+-  LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether g++ accepts -static-libstdc++ -static-libgcc" >&5
+-$as_echo_n "checking whether g++ accepts -static-libstdc++ -static-libgcc... " >&6; }
++  LDFLAGS="$LDFLAGS -static-libstdc++"
++  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether g++ accepts -static-libstdc++" >&5
++$as_echo_n "checking whether g++ accepts -static-libstdc++... " >&6; }
+   ac_ext=cpp
+ ac_cpp='$CXXCPP $CPPFLAGS'
+ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+@@ -8465,7 +8465,7 @@ else
+  # trust that they are doing what they want.
+  if test "$with_static_standard_libraries" = yes -a "$stage1_libs" = "" \
+      -a "$have_static_libs" = yes; then
+-   stage1_ldflags="-static-libstdc++ -static-libgcc"
++   stage1_ldflags="-static-libstdc++"
+  fi
+ fi
+ 
+@@ -8501,7 +8501,7 @@ else
+  # statically.  But if the user explicitly specified the libraries to
+  # use, trust that they are doing what they want.
+  if test "$poststage1_libs" = ""; then
+-   poststage1_ldflags="-static-libstdc++ -static-libgcc"
++   poststage1_ldflags="-static-libstdc++"
+  fi
+ fi
+ 
diff --git a/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch b/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch
new file mode 100644
index 0000000..0796c34
--- /dev/null
+++ b/package/devel/gdb/patches/120-sigprocmask-invalid-call.patch
@@ -0,0 +1,38 @@
+From 56893a61aa4f0270fa8d1197b9848247f90fce0d Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Fri, 24 Mar 2017 10:36:03 +0800
+Subject: [PATCH] Fix invalid sigprocmask call
+
+The POSIX document says
+
+    The pthread_sigmask() and sigprocmask() functions shall fail if:
+
+    [EINVAL]
+    The value of the how argument is not equal to one of the defined values.
+
+and this is how musl-libc is currently doing.  Fix the call to be safe
+and correct
+
+ [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html
+
+gdb/ChangeLog:
+2017-03-24  Yousong Zhou  <yszhou4tech@gmail.com>
+
+    * common/signals-state-save-restore.c (save_original_signals_state):
+    Fix invalid sigprocmask call.
+---
+ gdb/ChangeLog                           | 5 +++++
+ gdb/common/signals-state-save-restore.c | 2 +-
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+--- a/gdbsupport/signals-state-save-restore.cc
++++ b/gdbsupport/signals-state-save-restore.cc
+@@ -37,7 +37,7 @@ save_original_signals_state (bool quiet)
+   int i;
+   int res;
+ 
+-  res = gdb_sigmask (0,  NULL, &original_signal_mask);
++  res = gdb_sigmask (SIG_BLOCK,  NULL, &original_signal_mask);
+   if (res == -1)
+     perror_with_name (("sigprocmask"));
+ 
diff --git a/package/devel/gdb/patches/140-sgidefs.patch b/package/devel/gdb/patches/140-sgidefs.patch
new file mode 100644
index 0000000..1753e9b
--- /dev/null
+++ b/package/devel/gdb/patches/140-sgidefs.patch
@@ -0,0 +1,30 @@
+From 677b5b56135141c0d259e370aacd0e11c810aa15 Mon Sep 17 00:00:00 2001
+From: Andre McCurdy <armccurdy@gmail.com>
+Date: Fri, 5 Feb 2016 14:00:00 -0800
+Subject: [PATCH] use <asm/sgidefs.h>
+
+Build fix for MIPS with musl libc
+
+The MIPS specific header <sgidefs.h> is provided by glibc and uclibc
+but not by musl. Regardless of the libc, the kernel headers provide
+<asm/sgidefs.h> which provides the same definitions, so use that
+instead.
+
+Upstream-Status: Pending
+
+Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
+---
+ gdb/mips-linux-nat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/gdb/mips-linux-nat.c
++++ b/gdb/mips-linux-nat.c
+@@ -30,7 +30,7 @@
+ #include "gdb_proc_service.h"
+ #include "gregset.h"
+ 
+-#include <sgidefs.h>
++#include <asm/sgidefs.h>
+ #include "nat/gdb_ptrace.h"
+ #include <asm/ptrace.h>
+ #include "inf-ptrace.h"
diff --git a/package/devel/gdb/patches/150-mips64.patch b/package/devel/gdb/patches/150-mips64.patch
new file mode 100644
index 0000000..41c267b
--- /dev/null
+++ b/package/devel/gdb/patches/150-mips64.patch
@@ -0,0 +1,32 @@
+From e92f8932ef488de2a56db4299131ce6a4eb170bd Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+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 <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ gdb/mips-linux-nat.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/gdb/mips-linux-nat.c
++++ b/gdb/mips-linux-nat.c
+@@ -41,6 +41,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
++
+ class mips_linux_nat_target final : public linux_nat_trad_target
+ {
+ public: