From d354bfde174514973309e788e11c286f1667c2f5 Mon Sep 17 00:00:00 2001
From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Date: Thu, 19 May 2016 08:20:33 +0300
Subject: toolchain: Bump ARC tools to arc-2016.03

This change switches ARC tools to the most recent arc-2016.03
version.

ARC GNU tools of version arc-2016.03 bring some quite significant
changes like:
 * Binutils v2.26+ (upstream commit id 202ac19 with additional ARC
 * patches)
 * GCC v4.8.5
 * GDB 7.10

More about changes, improvements and fixes could be found here:
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/tag/arc-2016.03

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
 toolchain/gcc/Config.version                       |   2 +-
 toolchain/gcc/common.mk                            |   8 +-
 .../001-revert_register_mode_search.patch          |  65 ------
 .../patches/arc-2015.06/002-weak_data_fix.patch    |  42 ----
 .../arc-2015.06/003-universal_initializer.patch    |  94 --------
 .../patches/arc-2015.06/004-case_insensitive.patch |  14 --
 .../patches/arc-2015.06/010-documentation.patch    |  23 --
 .../patches/arc-2015.06/020-no-plt-backport.patch  |  28 ---
 .../gcc/patches/arc-2015.06/100-uclibc-conf.patch  |  33 ---
 .../210-disable_libsanitizer_off_t_check.patch     |  11 -
 .../arc-2015.06/800-arc-disablelibgmon.patch       |  18 --
 .../gcc/patches/arc-2015.06/820-libgcc_pic.patch   |  36 ---
 .../arc-2015.06/850-use_shared_libgcc.patch        |  47 ----
 .../patches/arc-2015.06/851-libgcc_no_compat.patch |  12 -
 .../gcc/patches/arc-2015.06/860-use_eh_frame.patch |  42 ----
 .../patches/arc-2015.06/870-ppc_no_crtsavres.patch |  11 -
 .../patches/arc-2015.06/880-no_java_section.patch  |  11 -
 .../gcc/patches/arc-2015.06/910-mbsd_multi.patch   | 253 ---------------------
 .../arc-2015.06/920-specs_nonfatal_getenv.patch    |  14 --
 .../arc-2015.06/940-no-clobber-stamp-bits.patch    |  11 -
 .../001-revert_register_mode_search.patch          |  65 ++++++
 .../patches/arc-2016.03/002-weak_data_fix.patch    |  42 ++++
 .../arc-2016.03/003-universal_initializer.patch    |  94 ++++++++
 .../patches/arc-2016.03/004-case_insensitive.patch |  14 ++
 .../patches/arc-2016.03/010-documentation.patch    |  23 ++
 .../patches/arc-2016.03/020-no-plt-backport.patch  |  28 +++
 .../gcc/patches/arc-2016.03/100-uclibc-conf.patch  |  33 +++
 .../210-disable_libsanitizer_off_t_check.patch     |  11 +
 .../arc-2016.03/800-arc-disablelibgmon.patch       |  18 ++
 .../gcc/patches/arc-2016.03/820-libgcc_pic.patch   |  36 +++
 .../arc-2016.03/850-use_shared_libgcc.patch        |  47 ++++
 .../patches/arc-2016.03/851-libgcc_no_compat.patch |  12 +
 .../gcc/patches/arc-2016.03/860-use_eh_frame.patch |  42 ++++
 .../patches/arc-2016.03/870-ppc_no_crtsavres.patch |  11 +
 .../patches/arc-2016.03/880-no_java_section.patch  |  11 +
 .../gcc/patches/arc-2016.03/910-mbsd_multi.patch   | 253 +++++++++++++++++++++
 .../arc-2016.03/920-specs_nonfatal_getenv.patch    |  14 ++
 .../arc-2016.03/940-no-clobber-stamp-bits.patch    |  11 +
 38 files changed, 770 insertions(+), 770 deletions(-)
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/001-revert_register_mode_search.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/002-weak_data_fix.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/003-universal_initializer.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/004-case_insensitive.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/010-documentation.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/020-no-plt-backport.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/100-uclibc-conf.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/210-disable_libsanitizer_off_t_check.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/800-arc-disablelibgmon.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/820-libgcc_pic.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/850-use_shared_libgcc.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/851-libgcc_no_compat.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/860-use_eh_frame.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/870-ppc_no_crtsavres.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/880-no_java_section.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/910-mbsd_multi.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/920-specs_nonfatal_getenv.patch
 delete mode 100644 toolchain/gcc/patches/arc-2015.06/940-no-clobber-stamp-bits.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/010-documentation.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/100-uclibc-conf.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch
 create mode 100644 toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch

(limited to 'toolchain/gcc')

diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version
index 5d393c54d0..f9e8c47c6f 100644
--- a/toolchain/gcc/Config.version
+++ b/toolchain/gcc/Config.version
@@ -5,7 +5,7 @@ config GCC_VERSION_4_8_ARC
 config GCC_VERSION
 	string
 	default "4.8-linaro"    if GCC_VERSION_4_8_LINARO
-	default "arc-2015.06"   if GCC_VERSION_4_8_ARC
+	default "arc-2016.03"   if GCC_VERSION_4_8_ARC
 	default "5.3.0"
 
 config GCC_VERSION_4_8
diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
index e6b5c8ea4b..c3546f545b 100644
--- a/toolchain/gcc/common.mk
+++ b/toolchain/gcc/common.mk
@@ -33,11 +33,11 @@ ifeq ($(PKG_VERSION),5.3.0)
 endif
 
 ifneq ($(CONFIG_GCC_VERSION_4_8_ARC),)
-    PKG_VERSION:=4.8.4
-    PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/arc-2015.06
+    PKG_VERSION:=4.8.5
+    PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/arc-2016.03
     PKG_SOURCE:=$(PKG_NAME)-$(GCC_VERSION).tar.gz
-    PKG_MD5SUM:=25007ebb02a5f6c32532b103bb5984a0
-    PKG_REV:=2015.06
+    PKG_MD5SUM:=ca59c8140d6efd07b97a18869bddbb53
+    PKG_REV:=2016.03
     GCC_DIR:=gcc-arc-$(PKG_REV)
     HOST_BUILD_DIR = $(BUILD_DIR_HOST)/$(PKG_NAME)-$(GCC_VERSION)
 endif
diff --git a/toolchain/gcc/patches/arc-2015.06/001-revert_register_mode_search.patch b/toolchain/gcc/patches/arc-2015.06/001-revert_register_mode_search.patch
deleted file mode 100644
index 162d651394..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/001-revert_register_mode_search.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-Revert of:
-
-commit 275035b56823b26d5fb7e90fad945b998648edf2
-Author: bergner <bergner@138bc75d-0d04-0410-961f-82ee72b054a4>
-Date:   Thu Sep 5 14:09:07 2013 +0000
-
-        PR target/58139
-        * reginfo.c (choose_hard_reg_mode): Scan through all mode classes
-        looking for widest mode.
-
-
-    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202286 138bc75d-0d04-0410-961f-82ee72b054a4
-
-
---- a/gcc/reginfo.c
-+++ b/gcc/reginfo.c
-@@ -620,35 +620,40 @@ choose_hard_reg_mode (unsigned int regno
-        mode = GET_MODE_WIDER_MODE (mode))
-     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
- 	&& HARD_REGNO_MODE_OK (regno, mode)
--	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
--	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
-+	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
-       found_mode = mode;
- 
-+  if (found_mode != VOIDmode)
-+    return found_mode;
-+
-   for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
-        mode != VOIDmode;
-        mode = GET_MODE_WIDER_MODE (mode))
-     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
- 	&& HARD_REGNO_MODE_OK (regno, mode)
--	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
--	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
-+	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
-       found_mode = mode;
- 
-+  if (found_mode != VOIDmode)
-+    return found_mode;
-+
-   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
-        mode != VOIDmode;
-        mode = GET_MODE_WIDER_MODE (mode))
-     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
- 	&& HARD_REGNO_MODE_OK (regno, mode)
--	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
--	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
-+	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
-       found_mode = mode;
- 
-+  if (found_mode != VOIDmode)
-+    return found_mode;
-+
-   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
-        mode != VOIDmode;
-        mode = GET_MODE_WIDER_MODE (mode))
-     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
- 	&& HARD_REGNO_MODE_OK (regno, mode)
--	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
--	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
-+	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
-       found_mode = mode;
- 
-   if (found_mode != VOIDmode)
diff --git a/toolchain/gcc/patches/arc-2015.06/002-weak_data_fix.patch b/toolchain/gcc/patches/arc-2015.06/002-weak_data_fix.patch
deleted file mode 100644
index a740b4ce9e..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/002-weak_data_fix.patch
+++ /dev/null
@@ -1,42 +0,0 @@
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/visibility-21.c
-@@ -0,0 +1,14 @@
-+/* PR target/32219 */
-+/* { dg-do run } */
-+/* { dg-require-visibility "" } */
-+/* { dg-options "-fPIC" { target fpic } } */
-+
-+extern void f() __attribute__((weak,visibility("hidden")));
-+extern int puts( char const* );
-+int main()
-+{
-+	if (f)
-+		f();
-+	return 0;
-+}
-+
---- a/gcc/varasm.c
-+++ b/gcc/varasm.c
-@@ -6677,6 +6677,10 @@ default_binds_local_p_1 (const_tree exp,
-   /* Static variables are always local.  */
-   else if (! TREE_PUBLIC (exp))
-     local_p = true;
-+  /* hidden weak can't be overridden by something non-local, all
-+     that is possible is that it is not defined at all. */
-+  else if (DECL_WEAK (exp))
-+    local_p = false;
-   /* A variable is local if the user has said explicitly that it will
-      be.  */
-   else if ((DECL_VISIBILITY_SPECIFIED (exp)
-@@ -6690,11 +6694,6 @@ default_binds_local_p_1 (const_tree exp,
-      local.  */
-   else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
-     local_p = true;
--  /* Default visibility weak data can be overridden by a strong symbol
--     in another module and so are not local.  */
--  else if (DECL_WEAK (exp)
--	   && !resolved_locally)
--    local_p = false;
-   /* If PIC, then assume that any global name can be overridden by
-      symbols resolved from other modules.  */
-   else if (shlib)
diff --git a/toolchain/gcc/patches/arc-2015.06/003-universal_initializer.patch b/toolchain/gcc/patches/arc-2015.06/003-universal_initializer.patch
deleted file mode 100644
index 1b9a5b3081..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/003-universal_initializer.patch
+++ /dev/null
@@ -1,94 +0,0 @@
---- a/gcc/c/c-typeck.c
-+++ b/gcc/c/c-typeck.c
-@@ -62,9 +62,9 @@ int in_typeof;
-    if expr.original_code == SIZEOF_EXPR.  */
- tree c_last_sizeof_arg;
- 
--/* Nonzero if we've already printed a "missing braces around initializer"
--   message within this initializer.  */
--static int missing_braces_mentioned;
-+/* Nonzero if we might need to print a "missing braces around
-+   initializer" message within this initializer.  */
-+static int found_missing_braces;
- 
- static int require_constant_value;
- static int require_constant_elements;
-@@ -6363,6 +6363,9 @@ static int constructor_nonconst;
- /* 1 if this constructor is erroneous so far.  */
- static int constructor_erroneous;
- 
-+/* 1 if this constructor is the universal zero initializer { 0 }.  */
-+static int constructor_zeroinit;
-+
- /* Structure for managing pending initializer elements, organized as an
-    AVL tree.  */
- 
-@@ -6524,7 +6527,7 @@ start_init (tree decl, tree asmspec_tree
-   constructor_stack = 0;
-   constructor_range_stack = 0;
- 
--  missing_braces_mentioned = 0;
-+  found_missing_braces = 0;
- 
-   spelling_base = 0;
-   spelling_size = 0;
-@@ -6619,6 +6622,7 @@ really_start_incremental_init (tree type
-   constructor_type = type;
-   constructor_incremental = 1;
-   constructor_designated = 0;
-+  constructor_zeroinit = 1;
-   designator_depth = 0;
-   designator_erroneous = 0;
- 
-@@ -6816,11 +6820,8 @@ push_init_level (int implicit, struct ob
- 	set_nonincremental_init (braced_init_obstack);
-     }
- 
--  if (implicit == 1 && warn_missing_braces && !missing_braces_mentioned)
--    {
--      missing_braces_mentioned = 1;
--      warning_init (OPT_Wmissing_braces, "missing braces around initializer");
--    }
-+  if (implicit == 1)
-+    found_missing_braces = 1;
- 
-   if (TREE_CODE (constructor_type) == RECORD_TYPE
- 	   || TREE_CODE (constructor_type) == UNION_TYPE)
-@@ -6953,16 +6954,23 @@ pop_init_level (int implicit, struct obs
- 	}
-     }
- 
-+  if (vec_safe_length (constructor_elements) != 1)
-+    constructor_zeroinit = 0;
-+
-+  /* Warn when some structs are initialized with direct aggregation.  */
-+  if (!implicit && found_missing_braces && warn_missing_braces
-+      && !constructor_zeroinit)
-+    {
-+      warning_init (OPT_Wmissing_braces,
-+		    "missing braces around initializer");
-+    }
-+
-   /* Warn when some struct elements are implicitly initialized to zero.  */
-   if (warn_missing_field_initializers
-       && constructor_type
-       && TREE_CODE (constructor_type) == RECORD_TYPE
-       && constructor_unfilled_fields)
-     {
--	bool constructor_zeroinit =
--	 (vec_safe_length (constructor_elements) == 1
--	  && integer_zerop ((*constructor_elements)[0].value));
--
- 	/* Do not warn for flexible array members or zero-length arrays.  */
- 	while (constructor_unfilled_fields
- 	       && (!DECL_SIZE (constructor_unfilled_fields)
-@@ -8077,6 +8085,9 @@ process_init_element (struct c_expr valu
-   designator_depth = 0;
-   designator_erroneous = 0;
- 
-+  if (!implicit && value.value && !integer_zerop (value.value))
-+    constructor_zeroinit = 0;
-+
-   /* Handle superfluous braces around string cst as in
-      char x[] = {"foo"}; */
-   if (string_flag
diff --git a/toolchain/gcc/patches/arc-2015.06/004-case_insensitive.patch b/toolchain/gcc/patches/arc-2015.06/004-case_insensitive.patch
deleted file mode 100644
index b3d2dbe291..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/004-case_insensitive.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/include/filenames.h
-+++ b/include/filenames.h
-@@ -43,11 +43,6 @@ extern "C" {
- #  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
- #  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
- #else /* not DOSish */
--#  if defined(__APPLE__)
--#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
--#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
--#    endif
--#  endif /* __APPLE__ */
- #  define HAS_DRIVE_SPEC(f) (0)
- #  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
- #  define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
diff --git a/toolchain/gcc/patches/arc-2015.06/010-documentation.patch b/toolchain/gcc/patches/arc-2015.06/010-documentation.patch
deleted file mode 100644
index 5548069d1b..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/010-documentation.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/gcc/Makefile.in
-+++ b/gcc/Makefile.in
-@@ -4327,18 +4327,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
- doc/gccint.info: $(TEXI_GCCINT_FILES)
- doc/cppinternals.info: $(TEXI_CPPINT_FILES)
- 
--doc/%.info: %.texi
--	if [ x$(BUILD_INFO) = xinfo ]; then \
--		$(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
--			-I $(gcc_docdir)/include -o $@ $<; \
--	fi
-+doc/%.info:
- 
- # Duplicate entry to handle renaming of gccinstall.info
--doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
--	if [ x$(BUILD_INFO) = xinfo ]; then \
--		$(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
--			-I $(gcc_docdir)/include -o $@ $<; \
--	fi
-+doc/gccinstall.info:
- 
- doc/cpp.dvi: $(TEXI_CPP_FILES)
- doc/gcc.dvi: $(TEXI_GCC_FILES)
diff --git a/toolchain/gcc/patches/arc-2015.06/020-no-plt-backport.patch b/toolchain/gcc/patches/arc-2015.06/020-no-plt-backport.patch
deleted file mode 100644
index b225376865..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/020-no-plt-backport.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- a/gcc/calls.c
-+++ b/gcc/calls.c
-@@ -176,6 +176,12 @@ prepare_call_address (tree fndecl, rtx f
- 	       && targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
- 	      ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
- 	      : memory_address (FUNCTION_MODE, funexp));
-+  else if (flag_pic && !flag_plt && fndecl
-+	   && TREE_CODE (fndecl) == FUNCTION_DECL
-+	   && !targetm.binds_local_p (fndecl))
-+    {
-+      funexp = force_reg (Pmode, funexp);
-+    }
-   else if (! sibcallp)
-     {
- #ifndef NO_FUNCTION_CSE
---- a/gcc/common.opt
-+++ b/gcc/common.opt
-@@ -1617,6 +1617,10 @@ fpie
- Common Report Var(flag_pie,1) Negative(fPIC)
- Generate position-independent code for executables if possible (small mode)
- 
-+fplt
-+Common Report Var(flag_plt) Init(1)
-+Use PLT for PIC calls (-fno-plt: load the address from GOT at call site)
-+
- fplugin=
- Common Joined RejectNegative Var(common_deferred_options) Defer
- Specify a plugin to load
diff --git a/toolchain/gcc/patches/arc-2015.06/100-uclibc-conf.patch b/toolchain/gcc/patches/arc-2015.06/100-uclibc-conf.patch
deleted file mode 100644
index ff9ad94f62..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/100-uclibc-conf.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/contrib/regression/objs-gcc.sh
-+++ b/contrib/regression/objs-gcc.sh
-@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
-  then
-   make all-gdb all-dejagnu all-ld || exit 1
-   make install-gdb install-dejagnu install-ld || exit 1
-+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
-+ then
-+  make all-gdb all-dejagnu all-ld || exit 1
-+  make install-gdb install-dejagnu install-ld || exit 1
- elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
-   make bootstrap || exit 1
-   make install || exit 1
---- a/libjava/classpath/ltconfig
-+++ b/libjava/classpath/ltconfig
-@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
- 
- # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
- case $host_os in
--linux-gnu*) ;;
-+linux-gnu*|linux-uclibc*) ;;
- linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
- esac
- 
-@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux
-   ;;
- 
- # This must be Linux ELF.
--linux-gnu*)
-+linux*)
-   version_type=linux
-   need_lib_prefix=no
-   need_version=no
diff --git a/toolchain/gcc/patches/arc-2015.06/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/arc-2015.06/210-disable_libsanitizer_off_t_check.patch
deleted file mode 100644
index 56084692a1..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/210-disable_libsanitizer_off_t_check.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/libsanitizer/interception/interception_type_test.cc
-+++ b/libsanitizer/interception/interception_type_test.cc
-@@ -31,7 +31,7 @@ COMPILER_CHECK(sizeof(OFF64_T) == sizeof
- // rest (they depend on _FILE_OFFSET_BITS setting when building an application).
- # if defined(__ANDROID__) || !defined _FILE_OFFSET_BITS || \
-   _FILE_OFFSET_BITS != 64
--COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
-+// COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
- # endif
- 
- #endif
diff --git a/toolchain/gcc/patches/arc-2015.06/800-arc-disablelibgmon.patch b/toolchain/gcc/patches/arc-2015.06/800-arc-disablelibgmon.patch
deleted file mode 100644
index 612883c98c..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/800-arc-disablelibgmon.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/libgcc/config.host b/libgcc/config.host
-index e768389..aec10c7 100644
---- a/libgcc/config.host
-+++ b/libgcc/config.host
-@@ -320,11 +320,11 @@ alpha*-dec-*vms*)
- 	;;
- arc*-*-elf*)
- 	tmake_file="arc/t-arc-newlib arc/t-arc"
--	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o crttls_r25.o crttls_r30.o"
-+	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o crttls_r25.o crttls_r30.o"
- 	;;
- arc*-*-linux-uclibc*)
- 	tmake_file="${tmake_file} t-slibgcc-libgcc t-slibgcc-nolc-override arc/t-arc700-uClibc arc/t-arc"
--	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o"
-+	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o"
- 	;;
- arm-wrs-vxworks)
- 	tmake_file="$tmake_file arm/t-arm arm/t-vxworks t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
diff --git a/toolchain/gcc/patches/arc-2015.06/820-libgcc_pic.patch b/toolchain/gcc/patches/arc-2015.06/820-libgcc_pic.patch
deleted file mode 100644
index 7a0ac7353e..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/820-libgcc_pic.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- a/libgcc/Makefile.in
-+++ b/libgcc/Makefile.in
-@@ -865,11 +865,12 @@ $(libgcov-objects): %$(objext): $(srcdir
- 
- # Static libraries.
- libgcc.a: $(libgcc-objects)
-+libgcc_pic.a: $(libgcc-s-objects)
- libgcov.a: $(libgcov-objects)
- libunwind.a: $(libunwind-objects)
- libgcc_eh.a: $(libgcc-eh-objects)
- 
--libgcc.a libgcov.a libunwind.a libgcc_eh.a:
-+libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
- 	-rm -f $@
- 
- 	objects="$(objects)";					\
-@@ -891,7 +892,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E
- endif
- 
- ifeq ($(enable_shared),yes)
--all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
-+all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
- ifneq ($(LIBUNWIND),)
- all: libunwind$(SHLIB_EXT)
- endif
-@@ -1058,6 +1059,10 @@ install-shared:
- 	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
- 	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
- 
-+	$(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
-+	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
-+	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
-+
- 	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
- 		@shlib_base_name@,libgcc_s,$(subst \
- 		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
diff --git a/toolchain/gcc/patches/arc-2015.06/850-use_shared_libgcc.patch b/toolchain/gcc/patches/arc-2015.06/850-use_shared_libgcc.patch
deleted file mode 100644
index 6934bc97f6..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/850-use_shared_libgcc.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/gcc/config/arm/linux-eabi.h
-+++ b/gcc/config/arm/linux-eabi.h
-@@ -131,10 +131,6 @@
- #define ENDFILE_SPEC \
-   LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
- 
--/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
--   do not use -lfloat.  */
--#undef LIBGCC_SPEC
--
- /* Clear the instruction cache from `beg' to `end'.  This is
-    implemented in lib1funcs.S, so ensure an error if this definition
-    is used.  */
---- a/gcc/config/linux.h
-+++ b/gcc/config/linux.h
-@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTI
- 	builtin_assert ("system=posix");			\
-     } while (0)
- 
-+#ifndef LIBGCC_SPEC
-+#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
-+#endif
-+
- /* Determine which dynamic linker to use depending on whether GLIBC or
-    uClibc or Bionic is the default C library and whether
-    -muclibc or -mglibc or -mbionic has been passed to change the default.  */
---- a/libgcc/mkmap-symver.awk
-+++ b/libgcc/mkmap-symver.awk
-@@ -132,5 +132,5 @@ function output(lib) {
-   else if (inherit[lib])
-     printf("} %s;\n", inherit[lib]);
-   else
--    printf ("\n  local:\n\t*;\n};\n");
-+    printf ("\n\t*;\n};\n");
- }
---- a/gcc/config/rs6000/linux.h
-+++ b/gcc/config/rs6000/linux.h
-@@ -61,6 +61,9 @@
- #undef  CPLUSPLUS_CPP_SPEC
- #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
- 
-+#undef LIBGCC_SPEC
-+#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
-+
- #undef  LINK_SHLIB_SPEC
- #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
- 
diff --git a/toolchain/gcc/patches/arc-2015.06/851-libgcc_no_compat.patch b/toolchain/gcc/patches/arc-2015.06/851-libgcc_no_compat.patch
deleted file mode 100644
index 80c3476841..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/851-libgcc_no_compat.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- a/libgcc/config/t-libunwind
-+++ b/libgcc/config/t-libunwind
-@@ -2,8 +2,7 @@
- 
- HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER
- 
--LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \
--  $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c
-+LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
- LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
- 
- # Override the default value from t-slibgcc-elf-ver and mention -lunwind
diff --git a/toolchain/gcc/patches/arc-2015.06/860-use_eh_frame.patch b/toolchain/gcc/patches/arc-2015.06/860-use_eh_frame.patch
deleted file mode 100644
index 1ac83fe4dc..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/860-use_eh_frame.patch
+++ /dev/null
@@ -1,42 +0,0 @@
---- a/libgcc/unwind-dw2-fde-dip.c
-+++ b/libgcc/unwind-dw2-fde-dip.c
-@@ -46,33 +46,13 @@
- #include "unwind-compat.h"
- #include "gthr.h"
- 
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
--    && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
--	|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
--    && defined(__BIONIC__)
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
--    && defined(__FreeBSD__) && __FreeBSD__ >= 7
--# define ElfW __ElfN
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
--    && defined(__OpenBSD__)
--# define ElfW(type) Elf_##type
--# define USE_PT_GNU_EH_FRAME
--#endif
--
--#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
--    && defined(TARGET_DL_ITERATE_PHDR) \
--    && defined(__sun__) && defined(__svr4__)
-+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR)
- # define USE_PT_GNU_EH_FRAME
-+# ifdef __OpenBSD__
-+#  define ElfW(type) Elf_##type
-+# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
-+#  define ElfW __ElfN
-+# endif
- #endif
- 
- #if defined(USE_PT_GNU_EH_FRAME)
diff --git a/toolchain/gcc/patches/arc-2015.06/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/arc-2015.06/870-ppc_no_crtsavres.patch
deleted file mode 100644
index 4b7fcbd5e1..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/870-ppc_no_crtsavres.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/gcc/config/rs6000/rs6000.c
-+++ b/gcc/config/rs6000/rs6000.c
-@@ -17662,7 +17662,7 @@ rs6000_savres_strategy (rs6000_stack_t *
-   /* Define cutoff for using out-of-line functions to save registers.  */
-   if (DEFAULT_ABI == ABI_V4 || TARGET_ELF)
-     {
--      if (!optimize_size)
-+      if (1)
- 	{
- 	  strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
- 	  strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
diff --git a/toolchain/gcc/patches/arc-2015.06/880-no_java_section.patch b/toolchain/gcc/patches/arc-2015.06/880-no_java_section.patch
deleted file mode 100644
index def6c9f4a0..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/880-no_java_section.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/gcc/defaults.h
-+++ b/gcc/defaults.h
-@@ -380,7 +380,7 @@ see the files COPYING3 and COPYING.RUNTI
- /* If we have named section and we support weak symbols, then use the
-    .jcr section for recording java classes which need to be registered
-    at program start-up time.  */
--#if defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
-+#if 0 && defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
- #ifndef JCR_SECTION_NAME
- #define JCR_SECTION_NAME ".jcr"
- #endif
diff --git a/toolchain/gcc/patches/arc-2015.06/910-mbsd_multi.patch b/toolchain/gcc/patches/arc-2015.06/910-mbsd_multi.patch
deleted file mode 100644
index 5387f8e86f..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/910-mbsd_multi.patch
+++ /dev/null
@@ -1,253 +0,0 @@
-
-	This patch brings over a few features from MirBSD:
-	* -fhonour-copts
-	  If this option is not given, it's warned (depending
-	  on environment variables). This is to catch errors
-	  of misbuilt packages which override CFLAGS themselves.
-	* -Werror-maybe-reset
-	  Has the effect of -Wno-error if GCC_NO_WERROR is
-	  set and not '0', a no-operation otherwise. This is
-	  to be able to use -Werror in "make" but prevent
-	  GNU autoconf generated configure scripts from
-	  freaking out.
-	* Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
-	  the default for -O2/-Os, because they trigger gcc bugs
-	  and can delete code with security implications.
-
-	This patch was authored by Thorsten Glaser <tg at mirbsd.de>
-	with copyright assignment to the FSF in effect.
-
---- a/gcc/c-family/c-opts.c
-+++ b/gcc/c-family/c-opts.c
-@@ -104,6 +104,9 @@ static size_t include_cursor;
- /* Whether any standard preincluded header has been preincluded.  */
- static bool done_preinclude;
- 
-+/* Check if a port honours COPTS.  */
-+static int honour_copts = 0;
-+
- static void handle_OPT_d (const char *);
- static void set_std_cxx98 (int);
- static void set_std_cxx11 (int);
-@@ -383,6 +386,9 @@ c_common_handle_option (size_t scode, co
-       cpp_opts->warn_endif_labels = value;
-       break;
- 
-+    case OPT_Werror_maybe_reset:
-+      break;
-+
-     case OPT_Winvalid_pch:
-       cpp_opts->warn_invalid_pch = value;
-       break;
-@@ -491,6 +497,12 @@ c_common_handle_option (size_t scode, co
-       flag_no_builtin = !value;
-       break;
- 
-+    case OPT_fhonour_copts:
-+      if (c_language == clk_c) {
-+        honour_copts++;
-+      }
-+      break;
-+
-     case OPT_fconstant_string_class_:
-       constant_string_class_name = arg;
-       break;
-@@ -1027,6 +1039,47 @@ c_common_init (void)
-       return false;
-     }
- 
-+  if (c_language == clk_c) {
-+    char *ev = getenv ("GCC_HONOUR_COPTS");
-+    int evv;
-+    if (ev == NULL)
-+      evv = -1;
-+    else if ((*ev == '0') || (*ev == '\0'))
-+      evv = 0;
-+    else if (*ev == '1')
-+      evv = 1;
-+    else if (*ev == '2')
-+      evv = 2;
-+    else if (*ev == 's')
-+      evv = -1;
-+    else {
-+      warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
-+      evv = 1; /* maybe depend this on something like MIRBSD_NATIVE?  */
-+    }
-+    if (evv == 1) {
-+      if (honour_copts == 0) {
-+        error ("someone does not honour COPTS at all in lenient mode");
-+        return false;
-+      } else if (honour_copts != 1) {
-+        warning (0, "someone does not honour COPTS correctly, passed %d times",
-+         honour_copts);
-+      }
-+    } else if (evv == 2) {
-+      if (honour_copts == 0) {
-+        error ("someone does not honour COPTS at all in strict mode");
-+        return false;
-+      } else if (honour_copts != 1) {
-+        error ("someone does not honour COPTS correctly, passed %d times",
-+         honour_copts);
-+        return false;
-+      }
-+    } else if (evv == 0) {
-+      if (honour_copts != 1)
-+        inform (0, "someone does not honour COPTS correctly, passed %d times",
-+         honour_copts);
-+    }
-+  }
-+
-   return true;
- }
- 
---- a/gcc/c-family/c.opt
-+++ b/gcc/c-family/c.opt
-@@ -379,6 +379,10 @@ Werror-implicit-function-declaration
- C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
- This switch is deprecated; use -Werror=implicit-function-declaration instead
- 
-+Werror-maybe-reset
-+C ObjC C++ ObjC++
-+; Documented in common.opt
-+
- Wfloat-equal
- C ObjC C++ ObjC++ Var(warn_float_equal) Warning
- Warn if testing floating point numbers for equality
-@@ -949,6 +953,9 @@ C++ ObjC++ Optimization Alias(fexception
- fhonor-std
- C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
- 
-+fhonour-copts
-+C ObjC C++ ObjC++ RejectNegative
-+
- fhosted
- C ObjC
- Assume normal C execution environment
---- a/gcc/common.opt
-+++ b/gcc/common.opt
-@@ -541,6 +541,10 @@ Werror=
- Common Joined
- Treat specified warning as error
- 
-+Werror-maybe-reset
-+Common
-+If environment variable GCC_NO_WERROR is set, act as -Wno-error
-+
- Wextra
- Common Var(extra_warnings) Warning
- Print extra (possibly unwanted) warnings
-@@ -1242,6 +1246,9 @@ fguess-branch-probability
- Common Report Var(flag_guess_branch_prob) Optimization
- Enable guessing of branch probabilities
- 
-+fhonour-copts
-+Common RejectNegative
-+
- ; Nonzero means ignore `#ident' directives.  0 means handle them.
- ; Generate position-independent code for executables if possible
- ; On SVR4 targets, it also controls whether or not to emit a
---- a/gcc/opts.c
-+++ b/gcc/opts.c
-@@ -468,8 +468,6 @@ static const struct default_options defa
-     { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
- #endif
-     { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
--    { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
--    { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
-     { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
-     { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
-     { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
-@@ -489,6 +487,8 @@ static const struct default_options defa
-     { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
- 
-     /* -O3 optimizations.  */
-+    { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
-+    { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
-     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
-     { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
-     /* Inlining of functions reducing size is a good idea with -Os
-@@ -1435,6 +1435,17 @@ common_handle_option (struct gcc_options
- 			       opts, opts_set, loc, dc);
-       break;
- 
-+    case OPT_Werror_maybe_reset:
-+      {
-+        char *ev = getenv ("GCC_NO_WERROR");
-+        if ((ev != NULL) && (*ev != '0'))
-+          warnings_are_errors = 0;
-+      }
-+      break;
-+
-+    case OPT_fhonour_copts:
-+      break;
-+
-     case OPT_Wlarger_than_:
-       opts->x_larger_than_size = value;
-       opts->x_warn_larger_than = value != -1;
---- a/gcc/doc/cppopts.texi
-+++ b/gcc/doc/cppopts.texi
-@@ -163,6 +163,11 @@ in older programs.  This warning is on b
- Make all warnings into hard errors.  Source code which triggers warnings
- will be rejected.
- 
-+ at item -Werror-maybe-reset
-+ at opindex Werror-maybe-reset
-+Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
-+variable is set to anything other than 0 or empty.
-+
- @item -Wsystem-headers
- @opindex Wsystem-headers
- Issue warnings for code in system headers.  These are normally unhelpful
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}.
- -Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
- -Wno-deprecated-declarations -Wdisabled-optimization  @gol
- -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
---Wno-endif-labels -Werror  -Werror=* @gol
-+-Wno-endif-labels -Werror  -Werror=* -Werror-maybe-reset @gol
- -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
- -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
- -Wformat-security  -Wformat-y2k @gol
-@@ -4817,6 +4817,22 @@ This option is only supported for C and 
- @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
- @option{-Wno-pointer-sign}.
- 
-+ at item -Werror-maybe-reset
-+ at opindex Werror-maybe-reset
-+Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
-+variable is set to anything other than 0 or empty.
-+
-+ at item -fhonour-copts
-+ at opindex fhonour-copts
-+If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
-+given at least once, and warn if it is given more than once.
-+If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
-+given exactly once.
-+If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
-+is not given exactly once.
-+The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
-+This flag and environment variable only affect the C language.
-+
- @item -Wstack-protector
- @opindex Wstack-protector
- @opindex Wno-stack-protector
-@@ -6928,7 +6944,7 @@ so, the first branch is redirected to ei
- second branch or a point immediately following it, depending on whether
- the condition is known to be true or false.
- 
--Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
-+Enabled at levels @option{-O3}.
- 
- @item -fsplit-wide-types
- @opindex fsplit-wide-types
---- a/gcc/java/jvspec.c
-+++ b/gcc/java/jvspec.c
-@@ -626,6 +626,7 @@ lang_specific_pre_link (void)
-      class name.  Append dummy `.c' that can be stripped by set_input so %b
-      is correct.  */ 
-   set_input (concat (main_class_name, "main.c", NULL));
-+  putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack!  */
-   err = do_spec (jvgenmain_spec);
-   if (err == 0)
-     {
diff --git a/toolchain/gcc/patches/arc-2015.06/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/arc-2015.06/920-specs_nonfatal_getenv.patch
deleted file mode 100644
index 09768f525b..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/920-specs_nonfatal_getenv.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -8029,7 +8029,10 @@ getenv_spec_function (int argc, const ch
- 
-   value = getenv (argv[0]);
-   if (!value)
--    fatal_error ("environment variable %qs not defined", argv[0]);
-+    {
-+      warning (0, "environment variable %qs not defined", argv[0]);
-+      value = "";
-+    }
- 
-   /* We have to escape every character of the environment variable so
-      they are not interpreted as active spec characters.  A
diff --git a/toolchain/gcc/patches/arc-2015.06/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/arc-2015.06/940-no-clobber-stamp-bits.patch
deleted file mode 100644
index dbecef2d57..0000000000
--- a/toolchain/gcc/patches/arc-2015.06/940-no-clobber-stamp-bits.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/libstdc++-v3/include/Makefile.in
-+++ b/libstdc++-v3/include/Makefile.in
-@@ -1342,7 +1342,7 @@
- 	@$(STAMP) stamp-bits
- 
- stamp-bits-sup: stamp-bits ${bits_sup_headers}
--	@-cd ${bits_builddir} && $(LN_S) $? . 2>/dev/null
-+	@-cd ${bits_builddir} && $(LN_S) $(filter-out stamp-bits,$?) . 2>/dev/null
- 	@$(STAMP) stamp-bits-sup
- 
- stamp-c_base: ${c_base_headers}
diff --git a/toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch b/toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch
new file mode 100644
index 0000000000..162d651394
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/001-revert_register_mode_search.patch
@@ -0,0 +1,65 @@
+Revert of:
+
+commit 275035b56823b26d5fb7e90fad945b998648edf2
+Author: bergner <bergner@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date:   Thu Sep 5 14:09:07 2013 +0000
+
+        PR target/58139
+        * reginfo.c (choose_hard_reg_mode): Scan through all mode classes
+        looking for widest mode.
+
+
+    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202286 138bc75d-0d04-0410-961f-82ee72b054a4
+
+
+--- a/gcc/reginfo.c
++++ b/gcc/reginfo.c
+@@ -620,35 +620,40 @@ choose_hard_reg_mode (unsigned int regno
+        mode = GET_MODE_WIDER_MODE (mode))
+     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ 	&& HARD_REGNO_MODE_OK (regno, mode)
+-	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+-	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+       found_mode = mode;
+ 
++  if (found_mode != VOIDmode)
++    return found_mode;
++
+   for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
+        mode != VOIDmode;
+        mode = GET_MODE_WIDER_MODE (mode))
+     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ 	&& HARD_REGNO_MODE_OK (regno, mode)
+-	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+-	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+       found_mode = mode;
+ 
++  if (found_mode != VOIDmode)
++    return found_mode;
++
+   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
+        mode != VOIDmode;
+        mode = GET_MODE_WIDER_MODE (mode))
+     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ 	&& HARD_REGNO_MODE_OK (regno, mode)
+-	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+-	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+       found_mode = mode;
+ 
++  if (found_mode != VOIDmode)
++    return found_mode;
++
+   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
+        mode != VOIDmode;
+        mode = GET_MODE_WIDER_MODE (mode))
+     if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ 	&& HARD_REGNO_MODE_OK (regno, mode)
+-	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+-	&& GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++	&& (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+       found_mode = mode;
+ 
+   if (found_mode != VOIDmode)
diff --git a/toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch b/toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch
new file mode 100644
index 0000000000..a740b4ce9e
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/002-weak_data_fix.patch
@@ -0,0 +1,42 @@
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/visibility-21.c
+@@ -0,0 +1,14 @@
++/* PR target/32219 */
++/* { dg-do run } */
++/* { dg-require-visibility "" } */
++/* { dg-options "-fPIC" { target fpic } } */
++
++extern void f() __attribute__((weak,visibility("hidden")));
++extern int puts( char const* );
++int main()
++{
++	if (f)
++		f();
++	return 0;
++}
++
+--- a/gcc/varasm.c
++++ b/gcc/varasm.c
+@@ -6677,6 +6677,10 @@ default_binds_local_p_1 (const_tree exp,
+   /* Static variables are always local.  */
+   else if (! TREE_PUBLIC (exp))
+     local_p = true;
++  /* hidden weak can't be overridden by something non-local, all
++     that is possible is that it is not defined at all. */
++  else if (DECL_WEAK (exp))
++    local_p = false;
+   /* A variable is local if the user has said explicitly that it will
+      be.  */
+   else if ((DECL_VISIBILITY_SPECIFIED (exp)
+@@ -6690,11 +6694,6 @@ default_binds_local_p_1 (const_tree exp,
+      local.  */
+   else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
+     local_p = true;
+-  /* Default visibility weak data can be overridden by a strong symbol
+-     in another module and so are not local.  */
+-  else if (DECL_WEAK (exp)
+-	   && !resolved_locally)
+-    local_p = false;
+   /* If PIC, then assume that any global name can be overridden by
+      symbols resolved from other modules.  */
+   else if (shlib)
diff --git a/toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch b/toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch
new file mode 100644
index 0000000000..1b9a5b3081
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/003-universal_initializer.patch
@@ -0,0 +1,94 @@
+--- a/gcc/c/c-typeck.c
++++ b/gcc/c/c-typeck.c
+@@ -62,9 +62,9 @@ int in_typeof;
+    if expr.original_code == SIZEOF_EXPR.  */
+ tree c_last_sizeof_arg;
+ 
+-/* Nonzero if we've already printed a "missing braces around initializer"
+-   message within this initializer.  */
+-static int missing_braces_mentioned;
++/* Nonzero if we might need to print a "missing braces around
++   initializer" message within this initializer.  */
++static int found_missing_braces;
+ 
+ static int require_constant_value;
+ static int require_constant_elements;
+@@ -6363,6 +6363,9 @@ static int constructor_nonconst;
+ /* 1 if this constructor is erroneous so far.  */
+ static int constructor_erroneous;
+ 
++/* 1 if this constructor is the universal zero initializer { 0 }.  */
++static int constructor_zeroinit;
++
+ /* Structure for managing pending initializer elements, organized as an
+    AVL tree.  */
+ 
+@@ -6524,7 +6527,7 @@ start_init (tree decl, tree asmspec_tree
+   constructor_stack = 0;
+   constructor_range_stack = 0;
+ 
+-  missing_braces_mentioned = 0;
++  found_missing_braces = 0;
+ 
+   spelling_base = 0;
+   spelling_size = 0;
+@@ -6619,6 +6622,7 @@ really_start_incremental_init (tree type
+   constructor_type = type;
+   constructor_incremental = 1;
+   constructor_designated = 0;
++  constructor_zeroinit = 1;
+   designator_depth = 0;
+   designator_erroneous = 0;
+ 
+@@ -6816,11 +6820,8 @@ push_init_level (int implicit, struct ob
+ 	set_nonincremental_init (braced_init_obstack);
+     }
+ 
+-  if (implicit == 1 && warn_missing_braces && !missing_braces_mentioned)
+-    {
+-      missing_braces_mentioned = 1;
+-      warning_init (OPT_Wmissing_braces, "missing braces around initializer");
+-    }
++  if (implicit == 1)
++    found_missing_braces = 1;
+ 
+   if (TREE_CODE (constructor_type) == RECORD_TYPE
+ 	   || TREE_CODE (constructor_type) == UNION_TYPE)
+@@ -6953,16 +6954,23 @@ pop_init_level (int implicit, struct obs
+ 	}
+     }
+ 
++  if (vec_safe_length (constructor_elements) != 1)
++    constructor_zeroinit = 0;
++
++  /* Warn when some structs are initialized with direct aggregation.  */
++  if (!implicit && found_missing_braces && warn_missing_braces
++      && !constructor_zeroinit)
++    {
++      warning_init (OPT_Wmissing_braces,
++		    "missing braces around initializer");
++    }
++
+   /* Warn when some struct elements are implicitly initialized to zero.  */
+   if (warn_missing_field_initializers
+       && constructor_type
+       && TREE_CODE (constructor_type) == RECORD_TYPE
+       && constructor_unfilled_fields)
+     {
+-	bool constructor_zeroinit =
+-	 (vec_safe_length (constructor_elements) == 1
+-	  && integer_zerop ((*constructor_elements)[0].value));
+-
+ 	/* Do not warn for flexible array members or zero-length arrays.  */
+ 	while (constructor_unfilled_fields
+ 	       && (!DECL_SIZE (constructor_unfilled_fields)
+@@ -8077,6 +8085,9 @@ process_init_element (struct c_expr valu
+   designator_depth = 0;
+   designator_erroneous = 0;
+ 
++  if (!implicit && value.value && !integer_zerop (value.value))
++    constructor_zeroinit = 0;
++
+   /* Handle superfluous braces around string cst as in
+      char x[] = {"foo"}; */
+   if (string_flag
diff --git a/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch b/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch
new file mode 100644
index 0000000000..b3d2dbe291
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/004-case_insensitive.patch
@@ -0,0 +1,14 @@
+--- a/include/filenames.h
++++ b/include/filenames.h
+@@ -43,11 +43,6 @@ extern "C" {
+ #  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
+ #  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
+ #else /* not DOSish */
+-#  if defined(__APPLE__)
+-#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+-#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
+-#    endif
+-#  endif /* __APPLE__ */
+ #  define HAS_DRIVE_SPEC(f) (0)
+ #  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
+ #  define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
diff --git a/toolchain/gcc/patches/arc-2016.03/010-documentation.patch b/toolchain/gcc/patches/arc-2016.03/010-documentation.patch
new file mode 100644
index 0000000000..5548069d1b
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4327,18 +4327,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
+ doc/gccint.info: $(TEXI_GCCINT_FILES)
+ doc/cppinternals.info: $(TEXI_CPPINT_FILES)
+ 
+-doc/%.info: %.texi
+-	if [ x$(BUILD_INFO) = xinfo ]; then \
+-		$(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
+-			-I $(gcc_docdir)/include -o $@ $<; \
+-	fi
++doc/%.info:
+ 
+ # Duplicate entry to handle renaming of gccinstall.info
+-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+-	if [ x$(BUILD_INFO) = xinfo ]; then \
+-		$(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+-			-I $(gcc_docdir)/include -o $@ $<; \
+-	fi
++doc/gccinstall.info:
+ 
+ doc/cpp.dvi: $(TEXI_CPP_FILES)
+ doc/gcc.dvi: $(TEXI_GCC_FILES)
diff --git a/toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch b/toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch
new file mode 100644
index 0000000000..b225376865
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/020-no-plt-backport.patch
@@ -0,0 +1,28 @@
+--- a/gcc/calls.c
++++ b/gcc/calls.c
+@@ -176,6 +176,12 @@ prepare_call_address (tree fndecl, rtx f
+ 	       && targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
+ 	      ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
+ 	      : memory_address (FUNCTION_MODE, funexp));
++  else if (flag_pic && !flag_plt && fndecl
++	   && TREE_CODE (fndecl) == FUNCTION_DECL
++	   && !targetm.binds_local_p (fndecl))
++    {
++      funexp = force_reg (Pmode, funexp);
++    }
+   else if (! sibcallp)
+     {
+ #ifndef NO_FUNCTION_CSE
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -1617,6 +1617,10 @@ fpie
+ Common Report Var(flag_pie,1) Negative(fPIC)
+ Generate position-independent code for executables if possible (small mode)
+ 
++fplt
++Common Report Var(flag_plt) Init(1)
++Use PLT for PIC calls (-fno-plt: load the address from GOT at call site)
++
+ fplugin=
+ Common Joined RejectNegative Var(common_deferred_options) Defer
+ Specify a plugin to load
diff --git a/toolchain/gcc/patches/arc-2016.03/100-uclibc-conf.patch b/toolchain/gcc/patches/arc-2016.03/100-uclibc-conf.patch
new file mode 100644
index 0000000000..ff9ad94f62
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/100-uclibc-conf.patch
@@ -0,0 +1,33 @@
+--- a/contrib/regression/objs-gcc.sh
++++ b/contrib/regression/objs-gcc.sh
+@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
+  then
+   make all-gdb all-dejagnu all-ld || exit 1
+   make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++  make all-gdb all-dejagnu all-ld || exit 1
++  make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+   make bootstrap || exit 1
+   make install || exit 1
+--- a/libjava/classpath/ltconfig
++++ b/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+ 
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+ 
+@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux
+   ;;
+ 
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+   version_type=linux
+   need_lib_prefix=no
+   need_version=no
diff --git a/toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch
new file mode 100644
index 0000000000..56084692a1
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/210-disable_libsanitizer_off_t_check.patch
@@ -0,0 +1,11 @@
+--- a/libsanitizer/interception/interception_type_test.cc
++++ b/libsanitizer/interception/interception_type_test.cc
+@@ -31,7 +31,7 @@ COMPILER_CHECK(sizeof(OFF64_T) == sizeof
+ // rest (they depend on _FILE_OFFSET_BITS setting when building an application).
+ # if defined(__ANDROID__) || !defined _FILE_OFFSET_BITS || \
+   _FILE_OFFSET_BITS != 64
+-COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
++// COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
+ # endif
+ 
+ #endif
diff --git a/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch b/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch
new file mode 100644
index 0000000000..612883c98c
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/800-arc-disablelibgmon.patch
@@ -0,0 +1,18 @@
+diff --git a/libgcc/config.host b/libgcc/config.host
+index e768389..aec10c7 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -320,11 +320,11 @@ alpha*-dec-*vms*)
+ 	;;
+ arc*-*-elf*)
+ 	tmake_file="arc/t-arc-newlib arc/t-arc"
+-	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o crttls_r25.o crttls_r30.o"
++	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o crttls_r25.o crttls_r30.o"
+ 	;;
+ arc*-*-linux-uclibc*)
+ 	tmake_file="${tmake_file} t-slibgcc-libgcc t-slibgcc-nolc-override arc/t-arc700-uClibc arc/t-arc"
+-	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o libgmon.a crtg.o crtgend.o"
++	extra_parts="crti.o crtn.o crtend.o crtbegin.o crtendS.o crtbeginS.o crtg.o crtgend.o"
+ 	;;
+ arm-wrs-vxworks)
+ 	tmake_file="$tmake_file arm/t-arm arm/t-vxworks t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
diff --git a/toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch b/toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch
new file mode 100644
index 0000000000..7a0ac7353e
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -865,11 +865,12 @@ $(libgcov-objects): %$(objext): $(srcdir
+ 
+ # Static libraries.
+ libgcc.a: $(libgcc-objects)
++libgcc_pic.a: $(libgcc-s-objects)
+ libgcov.a: $(libgcov-objects)
+ libunwind.a: $(libunwind-objects)
+ libgcc_eh.a: $(libgcc-eh-objects)
+ 
+-libgcc.a libgcov.a libunwind.a libgcc_eh.a:
++libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
+ 	-rm -f $@
+ 
+ 	objects="$(objects)";					\
+@@ -891,7 +892,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E
+ endif
+ 
+ ifeq ($(enable_shared),yes)
+-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
++all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
+ ifneq ($(LIBUNWIND),)
+ all: libunwind$(SHLIB_EXT)
+ endif
+@@ -1058,6 +1059,10 @@ install-shared:
+ 	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+ 	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+ 
++	$(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
++	chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++	$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++
+ 	$(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ 		@shlib_base_name@,libgcc_s,$(subst \
+ 		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
diff --git a/toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch b/toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch
new file mode 100644
index 0000000000..6934bc97f6
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/850-use_shared_libgcc.patch
@@ -0,0 +1,47 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -131,10 +131,6 @@
+ #define ENDFILE_SPEC \
+   LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
+ 
+-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
+-   do not use -lfloat.  */
+-#undef LIBGCC_SPEC
+-
+ /* Clear the instruction cache from `beg' to `end'.  This is
+    implemented in lib1funcs.S, so ensure an error if this definition
+    is used.  */
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTI
+ 	builtin_assert ("system=posix");			\
+     } while (0)
+ 
++#ifndef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
++#endif
++
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+    uClibc or Bionic is the default C library and whether
+    -muclibc or -mglibc or -mbionic has been passed to change the default.  */
+--- a/libgcc/mkmap-symver.awk
++++ b/libgcc/mkmap-symver.awk
+@@ -132,5 +132,5 @@ function output(lib) {
+   else if (inherit[lib])
+     printf("} %s;\n", inherit[lib]);
+   else
+-    printf ("\n  local:\n\t*;\n};\n");
++    printf ("\n\t*;\n};\n");
+ }
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -61,6 +61,9 @@
+ #undef  CPLUSPLUS_CPP_SPEC
+ #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
+ 
++#undef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
++
+ #undef  LINK_SHLIB_SPEC
+ #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
+ 
diff --git a/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch b/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch
new file mode 100644
index 0000000000..80c3476841
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/851-libgcc_no_compat.patch
@@ -0,0 +1,12 @@
+--- a/libgcc/config/t-libunwind
++++ b/libgcc/config/t-libunwind
+@@ -2,8 +2,7 @@
+ 
+ HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER
+ 
+-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \
+-  $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c
++LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ 
+ # Override the default value from t-slibgcc-elf-ver and mention -lunwind
diff --git a/toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch b/toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch
new file mode 100644
index 0000000000..1ac83fe4dc
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/860-use_eh_frame.patch
@@ -0,0 +1,42 @@
+--- a/libgcc/unwind-dw2-fde-dip.c
++++ b/libgcc/unwind-dw2-fde-dip.c
+@@ -46,33 +46,13 @@
+ #include "unwind-compat.h"
+ #include "gthr.h"
+ 
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+-    && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+-	|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+-    && defined(__BIONIC__)
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+-    && defined(__FreeBSD__) && __FreeBSD__ >= 7
+-# define ElfW __ElfN
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+-    && defined(__OpenBSD__)
+-# define ElfW(type) Elf_##type
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+-    && defined(TARGET_DL_ITERATE_PHDR) \
+-    && defined(__sun__) && defined(__svr4__)
++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR)
+ # define USE_PT_GNU_EH_FRAME
++# ifdef __OpenBSD__
++#  define ElfW(type) Elf_##type
++# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
++#  define ElfW __ElfN
++# endif
+ #endif
+ 
+ #if defined(USE_PT_GNU_EH_FRAME)
diff --git a/toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000000..4b7fcbd5e1
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/870-ppc_no_crtsavres.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -17662,7 +17662,7 @@ rs6000_savres_strategy (rs6000_stack_t *
+   /* Define cutoff for using out-of-line functions to save registers.  */
+   if (DEFAULT_ABI == ABI_V4 || TARGET_ELF)
+     {
+-      if (!optimize_size)
++      if (1)
+ 	{
+ 	  strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
+ 	  strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
diff --git a/toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch b/toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch
new file mode 100644
index 0000000000..def6c9f4a0
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/880-no_java_section.patch
@@ -0,0 +1,11 @@
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -380,7 +380,7 @@ see the files COPYING3 and COPYING.RUNTI
+ /* If we have named section and we support weak symbols, then use the
+    .jcr section for recording java classes which need to be registered
+    at program start-up time.  */
+-#if defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
++#if 0 && defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
+ #ifndef JCR_SECTION_NAME
+ #define JCR_SECTION_NAME ".jcr"
+ #endif
diff --git a/toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch b/toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch
new file mode 100644
index 0000000000..5387f8e86f
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/910-mbsd_multi.patch
@@ -0,0 +1,253 @@
+
+	This patch brings over a few features from MirBSD:
+	* -fhonour-copts
+	  If this option is not given, it's warned (depending
+	  on environment variables). This is to catch errors
+	  of misbuilt packages which override CFLAGS themselves.
+	* -Werror-maybe-reset
+	  Has the effect of -Wno-error if GCC_NO_WERROR is
+	  set and not '0', a no-operation otherwise. This is
+	  to be able to use -Werror in "make" but prevent
+	  GNU autoconf generated configure scripts from
+	  freaking out.
+	* Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
+	  the default for -O2/-Os, because they trigger gcc bugs
+	  and can delete code with security implications.
+
+	This patch was authored by Thorsten Glaser <tg at mirbsd.de>
+	with copyright assignment to the FSF in effect.
+
+--- a/gcc/c-family/c-opts.c
++++ b/gcc/c-family/c-opts.c
+@@ -104,6 +104,9 @@ static size_t include_cursor;
+ /* Whether any standard preincluded header has been preincluded.  */
+ static bool done_preinclude;
+ 
++/* Check if a port honours COPTS.  */
++static int honour_copts = 0;
++
+ static void handle_OPT_d (const char *);
+ static void set_std_cxx98 (int);
+ static void set_std_cxx11 (int);
+@@ -383,6 +386,9 @@ c_common_handle_option (size_t scode, co
+       cpp_opts->warn_endif_labels = value;
+       break;
+ 
++    case OPT_Werror_maybe_reset:
++      break;
++
+     case OPT_Winvalid_pch:
+       cpp_opts->warn_invalid_pch = value;
+       break;
+@@ -491,6 +497,12 @@ c_common_handle_option (size_t scode, co
+       flag_no_builtin = !value;
+       break;
+ 
++    case OPT_fhonour_copts:
++      if (c_language == clk_c) {
++        honour_copts++;
++      }
++      break;
++
+     case OPT_fconstant_string_class_:
+       constant_string_class_name = arg;
+       break;
+@@ -1027,6 +1039,47 @@ c_common_init (void)
+       return false;
+     }
+ 
++  if (c_language == clk_c) {
++    char *ev = getenv ("GCC_HONOUR_COPTS");
++    int evv;
++    if (ev == NULL)
++      evv = -1;
++    else if ((*ev == '0') || (*ev == '\0'))
++      evv = 0;
++    else if (*ev == '1')
++      evv = 1;
++    else if (*ev == '2')
++      evv = 2;
++    else if (*ev == 's')
++      evv = -1;
++    else {
++      warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
++      evv = 1; /* maybe depend this on something like MIRBSD_NATIVE?  */
++    }
++    if (evv == 1) {
++      if (honour_copts == 0) {
++        error ("someone does not honour COPTS at all in lenient mode");
++        return false;
++      } else if (honour_copts != 1) {
++        warning (0, "someone does not honour COPTS correctly, passed %d times",
++         honour_copts);
++      }
++    } else if (evv == 2) {
++      if (honour_copts == 0) {
++        error ("someone does not honour COPTS at all in strict mode");
++        return false;
++      } else if (honour_copts != 1) {
++        error ("someone does not honour COPTS correctly, passed %d times",
++         honour_copts);
++        return false;
++      }
++    } else if (evv == 0) {
++      if (honour_copts != 1)
++        inform (0, "someone does not honour COPTS correctly, passed %d times",
++         honour_copts);
++    }
++  }
++
+   return true;
+ }
+ 
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -379,6 +379,10 @@ Werror-implicit-function-declaration
+ C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
+ This switch is deprecated; use -Werror=implicit-function-declaration instead
+ 
++Werror-maybe-reset
++C ObjC C++ ObjC++
++; Documented in common.opt
++
+ Wfloat-equal
+ C ObjC C++ ObjC++ Var(warn_float_equal) Warning
+ Warn if testing floating point numbers for equality
+@@ -949,6 +953,9 @@ C++ ObjC++ Optimization Alias(fexception
+ fhonor-std
+ C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
+ 
++fhonour-copts
++C ObjC C++ ObjC++ RejectNegative
++
+ fhosted
+ C ObjC
+ Assume normal C execution environment
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -541,6 +541,10 @@ Werror=
+ Common Joined
+ Treat specified warning as error
+ 
++Werror-maybe-reset
++Common
++If environment variable GCC_NO_WERROR is set, act as -Wno-error
++
+ Wextra
+ Common Var(extra_warnings) Warning
+ Print extra (possibly unwanted) warnings
+@@ -1242,6 +1246,9 @@ fguess-branch-probability
+ Common Report Var(flag_guess_branch_prob) Optimization
+ Enable guessing of branch probabilities
+ 
++fhonour-copts
++Common RejectNegative
++
+ ; Nonzero means ignore `#ident' directives.  0 means handle them.
+ ; Generate position-independent code for executables if possible
+ ; On SVR4 targets, it also controls whether or not to emit a
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -468,8 +468,6 @@ static const struct default_options defa
+     { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
+ #endif
+     { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
+-    { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
+-    { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
+     { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
+     { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
+     { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
+@@ -489,6 +487,8 @@ static const struct default_options defa
+     { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
+ 
+     /* -O3 optimizations.  */
++    { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
++    { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
+     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+     { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
+     /* Inlining of functions reducing size is a good idea with -Os
+@@ -1435,6 +1435,17 @@ common_handle_option (struct gcc_options
+ 			       opts, opts_set, loc, dc);
+       break;
+ 
++    case OPT_Werror_maybe_reset:
++      {
++        char *ev = getenv ("GCC_NO_WERROR");
++        if ((ev != NULL) && (*ev != '0'))
++          warnings_are_errors = 0;
++      }
++      break;
++
++    case OPT_fhonour_copts:
++      break;
++
+     case OPT_Wlarger_than_:
+       opts->x_larger_than_size = value;
+       opts->x_warn_larger_than = value != -1;
+--- a/gcc/doc/cppopts.texi
++++ b/gcc/doc/cppopts.texi
+@@ -163,6 +163,11 @@ in older programs.  This warning is on b
+ Make all warnings into hard errors.  Source code which triggers warnings
+ will be rejected.
+ 
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
+ @item -Wsystem-headers
+ @opindex Wsystem-headers
+ Issue warnings for code in system headers.  These are normally unhelpful
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}.
+ -Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
+ -Wno-deprecated-declarations -Wdisabled-optimization  @gol
+ -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
+--Wno-endif-labels -Werror  -Werror=* @gol
++-Wno-endif-labels -Werror  -Werror=* -Werror-maybe-reset @gol
+ -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
+ -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
+ -Wformat-security  -Wformat-y2k @gol
+@@ -4817,6 +4817,22 @@ This option is only supported for C and 
+ @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
+ @option{-Wno-pointer-sign}.
+ 
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
++ at item -fhonour-copts
++ at opindex fhonour-copts
++If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
++given at least once, and warn if it is given more than once.
++If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
++given exactly once.
++If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
++is not given exactly once.
++The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
++This flag and environment variable only affect the C language.
++
+ @item -Wstack-protector
+ @opindex Wstack-protector
+ @opindex Wno-stack-protector
+@@ -6928,7 +6944,7 @@ so, the first branch is redirected to ei
+ second branch or a point immediately following it, depending on whether
+ the condition is known to be true or false.
+ 
+-Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
++Enabled at levels @option{-O3}.
+ 
+ @item -fsplit-wide-types
+ @opindex fsplit-wide-types
+--- a/gcc/java/jvspec.c
++++ b/gcc/java/jvspec.c
+@@ -626,6 +626,7 @@ lang_specific_pre_link (void)
+      class name.  Append dummy `.c' that can be stripped by set_input so %b
+      is correct.  */ 
+   set_input (concat (main_class_name, "main.c", NULL));
++  putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack!  */
+   err = do_spec (jvgenmain_spec);
+   if (err == 0)
+     {
diff --git a/toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000000..09768f525b
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,14 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -8029,7 +8029,10 @@ getenv_spec_function (int argc, const ch
+ 
+   value = getenv (argv[0]);
+   if (!value)
+-    fatal_error ("environment variable %qs not defined", argv[0]);
++    {
++      warning (0, "environment variable %qs not defined", argv[0]);
++      value = "";
++    }
+ 
+   /* We have to escape every character of the environment variable so
+      they are not interpreted as active spec characters.  A
diff --git a/toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000000..dbecef2d57
--- /dev/null
+++ b/toolchain/gcc/patches/arc-2016.03/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1342,7 +1342,7 @@
+ 	@$(STAMP) stamp-bits
+ 
+ stamp-bits-sup: stamp-bits ${bits_sup_headers}
+-	@-cd ${bits_builddir} && $(LN_S) $? . 2>/dev/null
++	@-cd ${bits_builddir} && $(LN_S) $(filter-out stamp-bits,$?) . 2>/dev/null
+ 	@$(STAMP) stamp-bits-sup
+ 
+ stamp-c_base: ${c_base_headers}
-- 
cgit v1.2.3