From 79452344feffbe2944c196b602790ed8451ea44c Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Tue, 17 Nov 2015 12:38:32 +0000
Subject: [PATCH] gdb: use separate patches for upstream and ARC gdb

With bump of upstream GDB from 7.9 to 7.10 at least
100-no_extern_inline.patch became incompatible with
ARC gdb (which is still based on upstream 7.9 branch).

So until ARC support is not completely upstreamed
(which we expect to happen in coming months) we'll need to have
separate patches for ARC gdb.

This time clean build-tested for Netgear WNDRMAC & AXS101.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: John Crispin <blogic@openwrt.org>
Cc: Jonas Gorski <jogo@openwrt.org>

SVN-Revision: 47491
---
 toolchain/gdb/Makefile                        |  2 ++
 .../{ => 7.10}/100-no_extern_inline.patch     |  0
 .../patches/{ => 7.10}/110-no_testsuite.patch |  0
 .../120-fix-compile-flag-mismatch.patch       |  0
 .../100-no_extern_inline.patch                | 32 +++++++++++++++++++
 .../arc-2015.06-gdb/110-no_testsuite.patch    | 21 ++++++++++++
 .../120-fix-compile-flag-mismatch.patch       | 11 +++++++
 7 files changed, 66 insertions(+)
 rename toolchain/gdb/patches/{ => 7.10}/100-no_extern_inline.patch (100%)
 rename toolchain/gdb/patches/{ => 7.10}/110-no_testsuite.patch (100%)
 rename toolchain/gdb/patches/{ => 7.10}/120-fix-compile-flag-mismatch.patch (100%)
 create mode 100644 toolchain/gdb/patches/arc-2015.06-gdb/100-no_extern_inline.patch
 create mode 100644 toolchain/gdb/patches/arc-2015.06-gdb/110-no_testsuite.patch
 create mode 100644 toolchain/gdb/patches/arc-2015.06-gdb/120-fix-compile-flag-mismatch.patch

diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile
index 38ffb0b77f0..f74b64ed94b 100644
--- a/toolchain/gdb/Makefile
+++ b/toolchain/gdb/Makefile
@@ -24,6 +24,8 @@ PKG_MD5SUM:=2a35bac41fa8e10bf04f3a0dd7f7f363
 GDB_DIR:=$(PKG_NAME)-$(PKG_VERSION)
 endif
 
+PATCH_DIR:=./patches/$(PKG_VERSION)
+
 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GDB_DIR)
 
 HOST_BUILD_PARALLEL:=1
diff --git a/toolchain/gdb/patches/100-no_extern_inline.patch b/toolchain/gdb/patches/7.10/100-no_extern_inline.patch
similarity index 100%
rename from toolchain/gdb/patches/100-no_extern_inline.patch
rename to toolchain/gdb/patches/7.10/100-no_extern_inline.patch
diff --git a/toolchain/gdb/patches/110-no_testsuite.patch b/toolchain/gdb/patches/7.10/110-no_testsuite.patch
similarity index 100%
rename from toolchain/gdb/patches/110-no_testsuite.patch
rename to toolchain/gdb/patches/7.10/110-no_testsuite.patch
diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/7.10/120-fix-compile-flag-mismatch.patch
similarity index 100%
rename from toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch
rename to toolchain/gdb/patches/7.10/120-fix-compile-flag-mismatch.patch
diff --git a/toolchain/gdb/patches/arc-2015.06-gdb/100-no_extern_inline.patch b/toolchain/gdb/patches/arc-2015.06-gdb/100-no_extern_inline.patch
new file mode 100644
index 00000000000..bbae1d774d4
--- /dev/null
+++ b/toolchain/gdb/patches/arc-2015.06-gdb/100-no_extern_inline.patch
@@ -0,0 +1,32 @@
+--- a/sim/common/sim-arange.c
++++ b/sim/common/sim-arange.c
+@@ -280,11 +280,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, a
+   build_search_tree (ar);
+ }
+ 
+-#endif /* DEFINE_NON_INLINE_P */
+-
+-#if DEFINE_INLINE_P
+-
+-SIM_ARANGE_INLINE int
++int
+ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
+ {
+   ADDR_RANGE_TREE *t = ar->range_tree;
+@@ -301,4 +297,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, ad
+   return 0;
+ }
+ 
+-#endif /* DEFINE_INLINE_P */
++#endif /* DEFINE_NON_INLINE_P */
+--- a/sim/common/sim-arange.h
++++ b/sim/common/sim-arange.h
+@@ -62,7 +62,7 @@ extern void sim_addr_range_delete (ADDR_
+ 
+ /* Return non-zero if ADDR is in range AR, traversing the entire tree.
+    If no range is specified, that is defined to mean "everything".  */
+-extern INLINE int
++extern int
+ sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/);
+ #define ADDR_RANGE_HIT_P(ar, addr) \
+   ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr)))
diff --git a/toolchain/gdb/patches/arc-2015.06-gdb/110-no_testsuite.patch b/toolchain/gdb/patches/arc-2015.06-gdb/110-no_testsuite.patch
new file mode 100644
index 00000000000..5c5d15c5b8c
--- /dev/null
+++ b/toolchain/gdb/patches/arc-2015.06-gdb/110-no_testsuite.patch
@@ -0,0 +1,21 @@
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -855,8 +855,7 @@ MAKEINFOFLAGS
+ YACC
+ YFLAGS
+ XMKMF'
+-ac_subdirs_all='testsuite
+-gdbtk
++ac_subdirs_all='gdbtk
+ multi-ice
+ gdbserver'
+ 
+@@ -5168,7 +5167,7 @@ $as_echo "$with_auto_load_safe_path" >&6
+ 
+ 
+ 
+-subdirs="$subdirs testsuite"
++subdirs="$subdirs"
+ 
+ 
+ # Check whether to support alternative target configurations
diff --git a/toolchain/gdb/patches/arc-2015.06-gdb/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/arc-2015.06-gdb/120-fix-compile-flag-mismatch.patch
new file mode 100644
index 00000000000..ce34c95b199
--- /dev/null
+++ b/toolchain/gdb/patches/arc-2015.06-gdb/120-fix-compile-flag-mismatch.patch
@@ -0,0 +1,11 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -2183,7 +2183,7 @@ $as_echo "$as_me: error: \`$ac_var' was
+       ac_cache_corrupted=: ;;
+     ,);;
+     *)
+-      if test "x$ac_old_val" != "x$ac_new_val"; then
++      if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ 	# differences in whitespace do not lead to failure.
+ 	ac_old_val_w=`echo x $ac_old_val`
+ 	ac_new_val_w=`echo x $ac_new_val`