summaryrefslogtreecommitdiff
path: root/patches/gcc/5.2.0
diff options
context:
space:
mode:
Diffstat (limited to 'patches/gcc/5.2.0')
-rw-r--r--patches/gcc/5.2.0/100-uclibc-conf.patch15
-rw-r--r--patches/gcc/5.2.0/201-libgcc-remove-unistd-header.patch14
-rw-r--r--patches/gcc/5.2.0/301-missing-execinfo_h.patch13
-rw-r--r--patches/gcc/5.2.0/810-arm-softfloat-libgcc.patch30
-rw-r--r--patches/gcc/5.2.0/830-arm_unbreak_armv4t.patch15
-rw-r--r--patches/gcc/5.2.0/840-microblaze-enable-dwarf-eh-support.patch166
-rw-r--r--patches/gcc/5.2.0/850-libstdcxx-uclibc-c99.patch273
-rw-r--r--patches/gcc/5.2.0/860-cilk-wchar.patch56
-rw-r--r--patches/gcc/5.2.0/870-xtensa-add-mauto-litpools-option.patch290
-rw-r--r--patches/gcc/5.2.0/871-xtensa-reimplement-register-spilling.patch76
-rw-r--r--patches/gcc/5.2.0/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch31
-rw-r--r--patches/gcc/5.2.0/873-xtensa-fix-_Unwind_GetCFA.patch40
-rw-r--r--patches/gcc/5.2.0/900-libitm-fixes-for-musl-support.patch (renamed from patches/gcc/5.2.0/100-libitm-fixes-for-musl-support.patch)12
-rw-r--r--patches/gcc/5.2.0/901-fixincludes-update-for-musl-support.patch (renamed from patches/gcc/5.2.0/101-fixincludes-update-for-musl-support.patch)6
-rw-r--r--patches/gcc/5.2.0/902-unwind-fix-for-musl.patch (renamed from patches/gcc/5.2.0/102-unwind-fix-for-musl.patch)4
-rw-r--r--patches/gcc/5.2.0/903-libstdc++-libgfortran-gthr-workaround-for-musl.patch (renamed from patches/gcc/5.2.0/103-libstdc++-libgfortran-gthr-workaround-for-musl.patch)22
-rw-r--r--patches/gcc/5.2.0/904-musl-libc-config.patch (renamed from patches/gcc/5.2.0/104-musl-libc-config.patch)80
-rw-r--r--patches/gcc/5.2.0/905-add-musl-support-to-gcc.patch (renamed from patches/gcc/5.2.0/105-add-musl-support-to-gcc.patch)30
-rw-r--r--patches/gcc/5.2.0/906-mips-musl-support.patch (renamed from patches/gcc/5.2.0/106-mips-musl-support.patch)7
-rw-r--r--patches/gcc/5.2.0/907-x86-musl-support.patch (renamed from patches/gcc/5.2.0/107-x86-musl-support.patch)12
-rw-r--r--patches/gcc/5.2.0/908-arm-musl-support.patch (renamed from patches/gcc/5.2.0/108-arm-musl-support.patch)4
-rw-r--r--patches/gcc/5.2.0/909-aarch64-musl-support.patch (renamed from patches/gcc/5.2.0/109-aarch64-musl-support.patch)4
22 files changed, 1091 insertions, 109 deletions
diff --git a/patches/gcc/5.2.0/100-uclibc-conf.patch b/patches/gcc/5.2.0/100-uclibc-conf.patch
new file mode 100644
index 0000000..73d1f0d
--- /dev/null
+++ b/patches/gcc/5.2.0/100-uclibc-conf.patch
@@ -0,0 +1,15 @@
+Index: b/contrib/regression/objs-gcc.sh
+===================================================================
+--- a/contrib/regression/objs-gcc.sh
++++ b/contrib/regression/objs-gcc.sh
+@@ -106,6 +106,10 @@
+ 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
diff --git a/patches/gcc/5.2.0/201-libgcc-remove-unistd-header.patch b/patches/gcc/5.2.0/201-libgcc-remove-unistd-header.patch
new file mode 100644
index 0000000..20d1c06
--- /dev/null
+++ b/patches/gcc/5.2.0/201-libgcc-remove-unistd-header.patch
@@ -0,0 +1,14 @@
+Upstream status: In progress
+
+Index: b/libgcc/config/nios2/linux-atomic.c
+===================================================================
+--- a/libgcc/config/nios2/linux-atomic.c
++++ b/libgcc/config/nios2/linux-atomic.c
+@@ -20,7 +20,6 @@
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+-#include <asm/unistd.h>
+ #define EFAULT 14
+ #define EBUSY 16
+ #define ENOSYS 38
diff --git a/patches/gcc/5.2.0/301-missing-execinfo_h.patch b/patches/gcc/5.2.0/301-missing-execinfo_h.patch
new file mode 100644
index 0000000..2d0e7ba
--- /dev/null
+++ b/patches/gcc/5.2.0/301-missing-execinfo_h.patch
@@ -0,0 +1,13 @@
+Index: b/boehm-gc/include/gc.h
+===================================================================
+--- a/boehm-gc/include/gc.h
++++ b/boehm-gc/include/gc.h
+@@ -503,7 +503,7 @@
+ #if defined(__linux__) || defined(__GLIBC__)
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/patches/gcc/5.2.0/810-arm-softfloat-libgcc.patch b/patches/gcc/5.2.0/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..5efa7fd
--- /dev/null
+++ b/patches/gcc/5.2.0/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,30 @@
+Index: b/gcc/config/arm/linux-elf.h
+===================================================================
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,7 +60,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+Index: b/libgcc/config/arm/t-linux
+===================================================================
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,11 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \
++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \
++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \
++ _arm_fixsfsi _arm_fixunssfsi
+
+ # Just for these, we omit the frame pointer since it makes such a big
+ # difference.
diff --git a/patches/gcc/5.2.0/830-arm_unbreak_armv4t.patch b/patches/gcc/5.2.0/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..b730059
--- /dev/null
+++ b/patches/gcc/5.2.0/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,15 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+Index: b/gcc/config/arm/linux-eabi.h
+===================================================================
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -45,7 +45,7 @@
+ The ARM10TDMI core is the default for armv5t, so set
+ SUBTARGET_CPU_DEFAULT to achieve this. */
+ #undef SUBTARGET_CPU_DEFAULT
+-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
++#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi
+
+ /* TARGET_BIG_ENDIAN_DEFAULT is set in
+ config.gcc for big endian configurations. */
diff --git a/patches/gcc/5.2.0/840-microblaze-enable-dwarf-eh-support.patch b/patches/gcc/5.2.0/840-microblaze-enable-dwarf-eh-support.patch
new file mode 100644
index 0000000..9d29090
--- /dev/null
+++ b/patches/gcc/5.2.0/840-microblaze-enable-dwarf-eh-support.patch
@@ -0,0 +1,166 @@
+Fetched from Xilinx gcc git at https://github.com/Xilinx/gcc
+
+From 23c35173490ac2d6348a668dfc9c1a6eb62171f2 Mon Sep 17 00:00:00 2001
+From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
+Date: Mon, 18 Jun 2012 20:18:13 +0200
+Subject: [PATCH] [Patch, microblaze]: Enable DWARF exception handling support.
+
+Changelog
+
+2013-03-18 Edgar E. Iglesias <edgar.iglesias@xilinx.com>
+ David Holsgrove <david.holsgrove@xilinx.com>
+
+ * common/config/microblaze/microblaze-common.c: Remove
+ TARGET_EXCEPT_UNWIND_INFO definition.
+ * config/microblaze/microblaze-protos.h: Add
+ microblaze_eh_return prototype.
+ * gcc/config/microblaze/microblaze.c: (microblaze_must_save_register,
+ microblaze_expand_epilogue, microblaze_return_addr): Handle
+ calls_eh_return
+ (microblaze_eh_return): New function.
+ * gcc/config/microblaze/microblaze.h: Define RETURN_ADDR_OFFSET,
+ EH_RETURN_DATA_REGNO, MB_EH_STACKADJ_REGNUM, EH_RETURN_STACKADJ_RTX,
+ ASM_PREFERRED_EH_DATA_FORMAT
+ * gcc/config/microblaze/microblaze.md: Define eh_return pattern.
+
+Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
+Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
+---
+ gcc/common/config/microblaze/microblaze-common.c | 3 ---
+ gcc/config/microblaze/microblaze-protos.h | 1 +
+ gcc/config/microblaze/microblaze.c | 29 ++++++++++++++++++++----
+ gcc/config/microblaze/microblaze.h | 15 ++++++++++++
+ gcc/config/microblaze/microblaze.md | 11 +++++++++
+ 5 files changed, 52 insertions(+), 7 deletions(-)
+
+Index: b/gcc/common/config/microblaze/microblaze-common.c
+===================================================================
+--- a/gcc/common/config/microblaze/microblaze-common.c
++++ b/gcc/common/config/microblaze/microblaze-common.c
+@@ -37,7 +37,4 @@
+ #undef TARGET_OPTION_OPTIMIZATION_TABLE
+ #define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
+
+-#undef TARGET_EXCEPT_UNWIND_INFO
+-#define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
+-
+ struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
+Index: b/gcc/config/microblaze/microblaze-protos.h
+===================================================================
+--- a/gcc/config/microblaze/microblaze-protos.h
++++ b/gcc/config/microblaze/microblaze-protos.h
+@@ -56,6 +56,7 @@
+ extern int symbol_mentioned_p (rtx);
+ extern int label_mentioned_p (rtx);
+ extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
++extern void microblaze_eh_return (rtx op0);
+ #endif /* RTX_CODE */
+
+ /* Declare functions in microblaze-c.c. */
+Index: b/gcc/config/microblaze/microblaze.c
+===================================================================
+--- a/gcc/config/microblaze/microblaze.c
++++ b/gcc/config/microblaze/microblaze.c
+@@ -1959,6 +1959,11 @@
+ if (frame_pointer_needed && (regno == HARD_FRAME_POINTER_REGNUM))
+ return 1;
+
++ if (crtl->calls_eh_return
++ && regno == MB_ABI_SUB_RETURN_ADDR_REGNUM) {
++ return 1;
++ }
++
+ if (!crtl->is_leaf)
+ {
+ if (regno == MB_ABI_SUB_RETURN_ADDR_REGNUM)
+@@ -1986,6 +1991,13 @@
+ return 1;
+ }
+
++ if (crtl->calls_eh_return
++ && (regno == EH_RETURN_DATA_REGNO (0)
++ || regno == EH_RETURN_DATA_REGNO (1)))
++ {
++ return 1;
++ }
++
+ return 0;
+ }
+
+@@ -3067,6 +3079,12 @@
+ emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
+ }
+
++ if (crtl->calls_eh_return)
++ emit_insn (gen_addsi3 (stack_pointer_rtx,
++ stack_pointer_rtx,
++ gen_rtx_raw_REG (SImode,
++ MB_EH_STACKADJ_REGNUM)));
++
+ emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +
+ MB_ABI_SUB_RETURN_ADDR_REGNUM)));
+ }
+@@ -3364,10 +3382,13 @@
+ if (count != 0)
+ return NULL_RTX;
+
+- return gen_rtx_PLUS (Pmode,
+- get_hard_reg_initial_val (Pmode,
+- MB_ABI_SUB_RETURN_ADDR_REGNUM),
+- GEN_INT (8));
++ return get_hard_reg_initial_val (Pmode,
++ MB_ABI_SUB_RETURN_ADDR_REGNUM);
++}
++
++void microblaze_eh_return (rtx op0)
++{
++ emit_insn (gen_movsi(gen_rtx_MEM(Pmode, stack_pointer_rtx), op0));
+ }
+
+ /* Queue an .ident string in the queue of top-level asm statements.
+Index: b/gcc/config/microblaze/microblaze.h
+===================================================================
+--- a/gcc/config/microblaze/microblaze.h
++++ b/gcc/config/microblaze/microblaze.h
+@@ -184,6 +184,21 @@
+ #define INCOMING_RETURN_ADDR_RTX \
+ gen_rtx_REG (VOIDmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)
+
++/* Specifies the offset from INCOMING_RETURN_ADDR_RTX and the actual return PC. */
++#define RETURN_ADDR_OFFSET (8)
++
++/* Describe how we implement __builtin_eh_return. */
++#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? MB_ABI_FIRST_ARG_REGNUM + (N) : INVALID_REGNUM)
++
++#define MB_EH_STACKADJ_REGNUM MB_ABI_INT_RETURN_VAL2_REGNUM
++#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, MB_EH_STACKADJ_REGNUM)
++
++/* Select a format to encode pointers in exception handling data. CODE
++ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
++ true if the symbol may be affected by dynamic relocations. */
++#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
++ ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
++
+ /* Use DWARF 2 debugging information by default. */
+ #define DWARF2_DEBUGGING_INFO
+ #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+Index: b/gcc/config/microblaze/microblaze.md
+===================================================================
+--- a/gcc/config/microblaze/microblaze.md
++++ b/gcc/config/microblaze/microblaze.md
+@@ -2272,4 +2272,15 @@
+ (set_attr "mode" "SI")
+ (set_attr "length" "4")])
+
++; This is used in compiling the unwind routines.
++(define_expand "eh_return"
++ [(use (match_operand 0 "general_operand" ""))]
++ ""
++ "
++{
++ microblaze_eh_return(operands[0]);
++ DONE;
++}")
++
+ (include "sync.md")
++
diff --git a/patches/gcc/5.2.0/850-libstdcxx-uclibc-c99.patch b/patches/gcc/5.2.0/850-libstdcxx-uclibc-c99.patch
new file mode 100644
index 0000000..9e97d94
--- /dev/null
+++ b/patches/gcc/5.2.0/850-libstdcxx-uclibc-c99.patch
@@ -0,0 +1,273 @@
+Allow C99-depending features of libstdc++ with uClibc
+
+The libstdc++ code is fairly restrictive on how it checks for C99
+compatibility: it requires *complete* C99 support to enable certain
+features. For example, uClibc provides a good number of C99 features,
+but not C99 complex number support. For this reason, libstdc++
+completely disables many the standard C++ methods that can in fact
+work because uClibc provides the necessary functions.
+
+This patch is similar and highly inspired from
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58393, but implemented in
+a way that doesn't involve changing the configure.ac script, as
+autoreconfiguring gcc is complicated. It simply relies on the fact
+that uClibc defines the __UCLIBC__ definition.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/libstdc++-v3/config/locale/generic/c_locale.h
+===================================================================
+--- a/libstdc++-v3/config/locale/generic/c_locale.h
++++ b/libstdc++-v3/config/locale/generic/c_locale.h
+@@ -70,7 +70,7 @@
+ __builtin_va_list __args;
+ __builtin_va_start(__args, __fmt);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
+ #else
+ const int __ret = __builtin_vsprintf(__out, __fmt, __args);
+Index: b/libstdc++-v3/config/locale/gnu/c_locale.h
+===================================================================
+--- a/libstdc++-v3/config/locale/gnu/c_locale.h
++++ b/libstdc++-v3/config/locale/gnu/c_locale.h
+@@ -88,7 +88,7 @@
+ __builtin_va_list __args;
+ __builtin_va_start(__args, __fmt);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
+ #else
+ const int __ret = __builtin_vsprintf(__out, __fmt, __args);
+Index: b/libstdc++-v3/include/bits/basic_string.h
+===================================================================
+--- a/libstdc++-v3/include/bits/basic_string.h
++++ b/libstdc++-v3/include/bits/basic_string.h
+@@ -5239,7 +5239,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
++#if __cplusplus >= 201103L && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__))
+
+ #include <ext/string_conversions.h>
+
+Index: b/libstdc++-v3/include/bits/locale_facets.tcc
+===================================================================
+--- a/libstdc++-v3/include/bits/locale_facets.tcc
++++ b/libstdc++-v3/include/bits/locale_facets.tcc
+@@ -992,7 +992,7 @@
+ char __fbuf[16];
+ __num_base::_S_format_float(__io, __fbuf, __mod);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ // Precision is always used except for hexfloat format.
+ const bool __use_prec =
+ (__io.flags() & ios_base::floatfield) != ios_base::floatfield;
+Index: b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+===================================================================
+--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
++++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+@@ -578,7 +578,7 @@
+ {
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ // First try a buffer perhaps big enough.
+ int __cs_size = 64;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+Index: b/libstdc++-v3/include/c_compatibility/math.h
+===================================================================
+--- a/libstdc++-v3/include/c_compatibility/math.h
++++ b/libstdc++-v3/include/c_compatibility/math.h
+@@ -56,7 +56,7 @@
+ using std::floor;
+ using std::fmod;
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::fpclassify;
+ using std::isfinite;
+ using std::isinf;
+Index: b/libstdc++-v3/include/c_compatibility/wchar.h
+===================================================================
+--- a/libstdc++-v3/include/c_compatibility/wchar.h
++++ b/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -103,7 +103,7 @@
+ using std::wmemset;
+ using std::wcsftime;
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/c_global/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/c_global/cstdlib
++++ b/libstdc++-v3/include/c_global/cstdlib
+@@ -195,7 +195,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef _Exit
+ #undef llabs
+Index: b/libstdc++-v3/include/c_global/cwchar
+===================================================================
+--- a/libstdc++-v3/include/c_global/cwchar
++++ b/libstdc++-v3/include/c_global/cwchar
+@@ -232,7 +232,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef wcstold
+ #undef wcstoll
+@@ -289,7 +289,7 @@
+ using std::vwscanf;
+ #endif
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/c_std/cstdio
+===================================================================
+--- a/libstdc++-v3/include/c_std/cstdio
++++ b/libstdc++-v3/include/c_std/cstdio
+@@ -144,7 +144,7 @@
+ using ::vsprintf;
+ } // namespace std
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
+Index: b/libstdc++-v3/include/c_std/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/c_std/cstdlib
++++ b/libstdc++-v3/include/c_std/cstdlib
+@@ -192,7 +192,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef _Exit
+ #undef llabs
+Index: b/libstdc++-v3/include/c_std/cwchar
+===================================================================
+--- a/libstdc++-v3/include/c_std/cwchar
++++ b/libstdc++-v3/include/c_std/cwchar
+@@ -228,7 +228,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef wcstold
+ #undef wcstoll
+Index: b/libstdc++-v3/include/ext/vstring.h
+===================================================================
+--- a/libstdc++-v3/include/ext/vstring.h
++++ b/libstdc++-v3/include/ext/vstring.h
+@@ -2680,7 +2680,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
++#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
+
+ #include <ext/string_conversions.h>
+
+Index: b/libstdc++-v3/include/tr1/cstdio
+===================================================================
+--- a/libstdc++-v3/include/tr1/cstdio
++++ b/libstdc++-v3/include/tr1/cstdio
+@@ -33,7 +33,7 @@
+
+ #include <cstdio>
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+Index: b/libstdc++-v3/include/tr1/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/tr1/cstdlib
++++ b/libstdc++-v3/include/tr1/cstdlib
+@@ -35,7 +35,7 @@
+
+ #if _GLIBCXX_HOSTED
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+Index: b/libstdc++-v3/include/tr1/cwchar
+===================================================================
+--- a/libstdc++-v3/include/tr1/cwchar
++++ b/libstdc++-v3/include/tr1/cwchar
+@@ -52,7 +52,7 @@
+ using std::vwscanf;
+ #endif
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/tr1/stdlib.h
+===================================================================
+--- a/libstdc++-v3/include/tr1/stdlib.h
++++ b/libstdc++-v3/include/tr1/stdlib.h
+@@ -33,7 +33,7 @@
+
+ #if _GLIBCXX_HOSTED
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ using std::tr1::atoll;
+ using std::tr1::strtoll;
+Index: b/libstdc++-v3/src/c++11/debug.cc
+===================================================================
+--- a/libstdc++-v3/src/c++11/debug.cc
++++ b/libstdc++-v3/src/c++11/debug.cc
+@@ -788,7 +788,7 @@
+ int __n __attribute__ ((__unused__)),
+ const char* __fmt, _Tp __s) const throw ()
+ {
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ std::snprintf(__buf, __n, __fmt, __s);
+ #else
+ std::sprintf(__buf, __fmt, __s);
+Index: b/libstdc++-v3/include/c_global/cstdio
+===================================================================
+--- a/libstdc++-v3/include/c_global/cstdio
++++ b/libstdc++-v3/include/c_global/cstdio
+@@ -146,7 +146,7 @@
+ using ::vsprintf;
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/patches/gcc/5.2.0/860-cilk-wchar.patch b/patches/gcc/5.2.0/860-cilk-wchar.patch
new file mode 100644
index 0000000..1d9916f
--- /dev/null
+++ b/patches/gcc/5.2.0/860-cilk-wchar.patch
@@ -0,0 +1,56 @@
+[PATCH] cilk: fix build without wchar
+
+When building against uClibc with wchar support disabled, WCHAR_MIN and
+WCHAR_MAX are not defined leading to compilation errors.
+
+Fix it by only including the wchar code if available.
+
+Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
+---
+ libcilkrts/include/cilk/reducer_min_max.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+Index: b/libcilkrts/include/cilk/reducer_min_max.h
+===================================================================
+--- a/libcilkrts/include/cilk/reducer_min_max.h
++++ b/libcilkrts/include/cilk/reducer_min_max.h
+@@ -3154,7 +3154,9 @@
+ CILK_C_REDUCER_MAX_INSTANCE(char, char, CHAR_MIN)
+ CILK_C_REDUCER_MAX_INSTANCE(unsigned char, uchar, 0)
+ CILK_C_REDUCER_MAX_INSTANCE(signed char, schar, SCHAR_MIN)
++#ifdef WCHAR_MIN
+ CILK_C_REDUCER_MAX_INSTANCE(wchar_t, wchar_t, WCHAR_MIN)
++#endif
+ CILK_C_REDUCER_MAX_INSTANCE(short, short, SHRT_MIN)
+ CILK_C_REDUCER_MAX_INSTANCE(unsigned short, ushort, 0)
+ CILK_C_REDUCER_MAX_INSTANCE(int, int, INT_MIN)
+@@ -3306,7 +3308,9 @@
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(char, char, CHAR_MIN)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(unsigned char, uchar, 0)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(signed char, schar, SCHAR_MIN)
++#ifdef WCHAR_MIN
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(wchar_t, wchar_t, WCHAR_MIN)
++#endif
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(short, short, SHRT_MIN)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(unsigned short, ushort, 0)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(int, int, INT_MIN)
+@@ -3432,7 +3436,9 @@
+ CILK_C_REDUCER_MIN_INSTANCE(char, char, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(unsigned char, uchar, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(signed char, schar, SCHAR_MAX)
++#ifdef WCHAR_MAX
+ CILK_C_REDUCER_MIN_INSTANCE(wchar_t, wchar_t, WCHAR_MAX)
++#endif
+ CILK_C_REDUCER_MIN_INSTANCE(short, short, SHRT_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(unsigned short, ushort, USHRT_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(int, int, INT_MAX)
+@@ -3584,7 +3590,9 @@
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(char, char, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(unsigned char, uchar, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(signed char, schar, SCHAR_MAX)
++#ifdef WCHAR_MAX
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(wchar_t, wchar_t, WCHAR_MAX)
++#endif
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(short, short, SHRT_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(unsigned short, ushort, USHRT_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(int, int, INT_MAX)
diff --git a/patches/gcc/5.2.0/870-xtensa-add-mauto-litpools-option.patch b/patches/gcc/5.2.0/870-xtensa-add-mauto-litpools-option.patch
new file mode 100644
index 0000000..aa1376c
--- /dev/null
+++ b/patches/gcc/5.2.0/870-xtensa-add-mauto-litpools-option.patch
@@ -0,0 +1,290 @@
+From 6d852ffb43b111a39162135c95249e749c4e285b Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 6 Aug 2015 01:16:02 +0300
+Subject: [PATCH] xtensa: add -mauto-litpools option
+
+With support from assembler this option allows compiling huge functions,
+where single literal pool at the beginning of a function may not be
+reachable by L32R instructions at its end.
+
+Currently assembler --auto-litpools option cannot deal with literals
+used from multiple locations separated by more than 256 KBytes of code.
+Don't turn constants into literals, instead use MOVI instruction to load
+them into registers and let the assembler turn them into literals as
+necessary.
+
+2015-08-12 Max Filippov <jcmvbkbc@gmail.com>
+gcc/
+ * config/xtensa/constraints.md (define_constraint "Y"): New
+ constraint.
+ * config/xtensa/elf.h (ASM_SPEC): Add m(no-)auto-litpools.
+ * config/xtensa/linux.h (ASM_SPEC): Likewise.
+ * config/xtensa/predicates.md (move_operand): Match constants
+ and symbols in the presence of TARGET_AUTO_LITPOOLS.
+ * config/xtensa/xtensa.c (xtensa_valid_move): Don't allow
+ immediate references to TLS data.
+ (xtensa_emit_move_sequence): Don't force constants to memory in
+ the presence of TARGET_AUTO_LITPOOLS.
+ (print_operand): Add 'y' format, same as default, but capable of
+ printing SF mode constants as well.
+ * config/xtensa/xtensa.md (movsi_internal, movhi_internal)
+ (movsf_internal): Add movi pattern that loads literal.
+ (movsf, movdf): Don't force constants to memory in the presence
+ of TARGET_AUTO_LITPOOLS.
+ (movdf_internal): Add 'Y' constraint.
+ * config/xtensa/xtensa.opt (mauto-litpools): New option.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226828
+Changes to ChangeLogs and documentation are dropped.
+
+ gcc/config/xtensa/constraints.md | 5 +++++
+ gcc/config/xtensa/elf.h | 4 +++-
+ gcc/config/xtensa/linux.h | 4 +++-
+ gcc/config/xtensa/predicates.md | 3 ++-
+ gcc/config/xtensa/xtensa.c | 19 ++++++++++++++++++-
+ gcc/config/xtensa/xtensa.md | 35 +++++++++++++++++++----------------
+ gcc/config/xtensa/xtensa.opt | 4 ++++
+ 7 files changed, 54 insertions(+), 20 deletions(-)
+
+diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
+index 30f4c1f..773d4f9 100644
+--- a/gcc/config/xtensa/constraints.md
++++ b/gcc/config/xtensa/constraints.md
+@@ -111,6 +111,11 @@
+ (and (match_code "const_int")
+ (match_test "xtensa_mask_immediate (ival)")))
+
++(define_constraint "Y"
++ "A constant that can be used in relaxed MOVI instructions."
++ (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
++ (match_test "TARGET_AUTO_LITPOOLS")))
++
+ ;; Memory constraints. Do not use define_memory_constraint here. Doing so
+ ;; causes reload to force some constants into the constant pool, but since
+ ;; the Xtensa constant pool can only be accessed with L32R instructions, it
+diff --git a/gcc/config/xtensa/elf.h b/gcc/config/xtensa/elf.h
+index e59bede..12056f7 100644
+--- a/gcc/config/xtensa/elf.h
++++ b/gcc/config/xtensa/elf.h
+@@ -48,7 +48,9 @@ along with GCC; see the file COPYING3. If not see
+ %{mtarget-align:--target-align} \
+ %{mno-target-align:--no-target-align} \
+ %{mlongcalls:--longcalls} \
+- %{mno-longcalls:--no-longcalls}"
++ %{mno-longcalls:--no-longcalls} \
++ %{mauto-litpools:--auto-litpools} \
++ %{mno-auto-litpools:--no-auto-litpools}"
+
+ #undef LIB_SPEC
+ #define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
+diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
+index 675aacf..5b0243a 100644
+--- a/gcc/config/xtensa/linux.h
++++ b/gcc/config/xtensa/linux.h
+@@ -42,7 +42,9 @@ along with GCC; see the file COPYING3. If not see
+ %{mtarget-align:--target-align} \
+ %{mno-target-align:--no-target-align} \
+ %{mlongcalls:--longcalls} \
+- %{mno-longcalls:--no-longcalls}"
++ %{mno-longcalls:--no-longcalls} \
++ %{mauto-litpools:--auto-litpools} \
++ %{mno-auto-litpools:--no-auto-litpools}"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md
+index e02209e..d7dfa11 100644
+--- a/gcc/config/xtensa/predicates.md
++++ b/gcc/config/xtensa/predicates.md
+@@ -142,7 +142,8 @@
+ (match_test "GET_MODE_CLASS (mode) == MODE_INT
+ && xtensa_simm12b (INTVAL (op))"))
+ (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
+- (match_test "TARGET_CONST16 && CONSTANT_P (op)
++ (match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS)
++ && CONSTANT_P (op)
+ && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
+
+ ;; Accept the floating point constant 1 in the appropriate mode.
+diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
+index eb039ba..206ff80 100644
+--- a/gcc/config/xtensa/xtensa.c
++++ b/gcc/config/xtensa/xtensa.c
+@@ -501,6 +501,9 @@ xtensa_valid_move (machine_mode mode, rtx *operands)
+ {
+ int dst_regnum = xt_true_regnum (operands[0]);
+
++ if (xtensa_tls_referenced_p (operands[1]))
++ return FALSE;
++
+ /* The stack pointer can only be assigned with a MOVSP opcode. */
+ if (dst_regnum == STACK_POINTER_REGNUM)
+ return !TARGET_WINDOWED_ABI
+@@ -1069,7 +1072,7 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode)
+ return 1;
+ }
+
+- if (! TARGET_CONST16)
++ if (! TARGET_AUTO_LITPOOLS && ! TARGET_CONST16)
+ {
+ src = force_const_mem (SImode, src);
+ operands[1] = src;
+@@ -2449,6 +2452,20 @@ print_operand (FILE *file, rtx x, int letter)
+ }
+ break;
+
++ case 'y':
++ if (GET_CODE (x) == CONST_DOUBLE &&
++ GET_MODE (x) == SFmode)
++ {
++ REAL_VALUE_TYPE r;
++ long l;
++ REAL_VALUE_FROM_CONST_DOUBLE (r, x);
++ REAL_VALUE_TO_TARGET_SINGLE (r, l);
++ fprintf (file, "0x%08lx", l);
++ break;
++ }
++
++ /* fall through */
++
+ default:
+ if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG)
+ fprintf (file, "%s", reg_names[xt_true_regnum (x)]);
+diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
+index 6d84384..0e673a3 100644
+--- a/gcc/config/xtensa/xtensa.md
++++ b/gcc/config/xtensa/xtensa.md
+@@ -761,8 +761,8 @@
+ })
+
+ (define_insn "movsi_internal"
+- [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,W,a,a,U,*a,*A")
+- (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,i,T,U,r,*A,*r"))]
++ [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,a,W,a,a,U,*a,*A")
++ (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,Y,i,T,U,r,*A,*r"))]
+ "xtensa_valid_move (SImode, operands)"
+ "@
+ movi.n\t%0, %x1
+@@ -774,15 +774,16 @@
+ mov\t%0, %1
+ movsp\t%0, %1
+ movi\t%0, %x1
++ movi\t%0, %1
+ const16\t%0, %t1\;const16\t%0, %b1
+ %v1l32r\t%0, %1
+ %v1l32i\t%0, %1
+ %v0s32i\t%1, %0
+ rsr\t%0, ACCLO
+ wsr\t%1, ACCLO"
+- [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,load,load,store,rsr,wsr")
++ [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,move,load,load,store,rsr,wsr")
+ (set_attr "mode" "SI")
+- (set_attr "length" "2,2,2,2,2,2,3,3,3,6,3,3,3,3,3")])
++ (set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")])
+
+ ;; 16-bit Integer moves
+
+@@ -796,21 +797,22 @@
+ })
+
+ (define_insn "movhi_internal"
+- [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
+- (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
++ [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
++ (match_operand:HI 1 "move_operand" "M,d,r,I,Y,U,r,*A,*r"))]
+ "xtensa_valid_move (HImode, operands)"
+ "@
+ movi.n\t%0, %x1
+ mov.n\t%0, %1
+ mov\t%0, %1
+ movi\t%0, %x1
++ movi\t%0, %1
+ %v1l16ui\t%0, %1
+ %v0s16i\t%1, %0
+ rsr\t%0, ACCLO
+ wsr\t%1, ACCLO"
+- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
++ [(set_attr "type" "move,move,move,move,move,load,store,rsr,wsr")
+ (set_attr "mode" "HI")
+- (set_attr "length" "2,2,3,3,3,3,3,3")])
++ (set_attr "length" "2,2,3,3,3,3,3,3,3")])
+
+ ;; 8-bit Integer moves
+
+@@ -881,7 +883,7 @@
+ (match_operand:SF 1 "general_operand" ""))]
+ ""
+ {
+- if (!TARGET_CONST16 && CONSTANT_P (operands[1]))
++ if (!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS && CONSTANT_P (operands[1]))
+ operands[1] = force_const_mem (SFmode, operands[1]);
+
+ if ((!register_operand (operands[0], SFmode)
+@@ -896,8 +898,8 @@
+ })
+
+ (define_insn "movsf_internal"
+- [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,W,a,a,U")
+- (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,iF,T,U,r"))]
++ [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,a,W,a,a,U")
++ (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,Y,iF,T,U,r"))]
+ "((register_operand (operands[0], SFmode)
+ || register_operand (operands[1], SFmode))
+ && !(FP_REG_P (xt_true_regnum (operands[0]))
+@@ -912,13 +914,14 @@
+ mov\t%0, %1
+ wfr\t%0, %1
+ rfr\t%0, %1
++ movi\t%0, %y1
+ const16\t%0, %t1\;const16\t%0, %b1
+ %v1l32r\t%0, %1
+ %v1l32i\t%0, %1
+ %v0s32i\t%1, %0"
+- [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,load,load,store")
++ [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,move,load,load,store")
+ (set_attr "mode" "SF")
+- (set_attr "length" "3,3,3,2,2,2,3,3,3,6,3,3,3")])
++ (set_attr "length" "3,3,3,2,2,2,3,3,3,3,6,3,3,3")])
+
+ (define_insn "*lsiu"
+ [(set (match_operand:SF 0 "register_operand" "=f")
+@@ -991,7 +994,7 @@
+ (match_operand:DF 1 "general_operand" ""))]
+ ""
+ {
+- if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
++ if (CONSTANT_P (operands[1]) && !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS)
+ operands[1] = force_const_mem (DFmode, operands[1]);
+
+ if (!register_operand (operands[0], DFmode)
+@@ -1002,8 +1005,8 @@
+ })
+
+ (define_insn_and_split "movdf_internal"
+- [(set (match_operand:DF 0 "nonimmed_operand" "=a,W,a,a,U")
+- (match_operand:DF 1 "move_operand" "r,iF,T,U,r"))]
++ [(set (match_operand:DF 0 "nonimmed_operand" "=a,a,W,a,a,U")
++ (match_operand:DF 1 "move_operand" "r,Y,iF,T,U,r"))]
+ "register_operand (operands[0], DFmode)
+ || register_operand (operands[1], DFmode)"
+ "#"
+diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
+index 2fd6cee..21c6e96 100644
+--- a/gcc/config/xtensa/xtensa.opt
++++ b/gcc/config/xtensa/xtensa.opt
+@@ -38,6 +38,10 @@ mtext-section-literals
+ Target
+ Intersperse literal pools with code in the text section
+
++mauto-litpools
++Target Report Mask(AUTO_LITPOOLS)
++Relax literals in assembler and place them automatically in the text section
++
+ mserialize-volatile
+ Target Report Mask(SERIALIZE_VOLATILE)
+ -mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions
+--
+1.8.1.4
+
diff --git a/patches/gcc/5.2.0/871-xtensa-reimplement-register-spilling.patch b/patches/gcc/5.2.0/871-xtensa-reimplement-register-spilling.patch
new file mode 100644
index 0000000..4056f8b
--- /dev/null
+++ b/patches/gcc/5.2.0/871-xtensa-reimplement-register-spilling.patch
@@ -0,0 +1,76 @@
+From 40507bf199440082ed69b777986d50c31efe2520 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Mon, 10 Aug 2015 21:35:20 +0300
+Subject: [PATCH 1/3] xtensa: reimplement register spilling
+
+Spilling windowed registers in userspace is much easier, more portable,
+less error-prone and equally effective as in kernel. Now that register
+spilling syscall is considered obsolete in the xtensa linux kernel
+replace it with CALL12 followed by series of ENTRY in libgcc.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
+ CALL12 followed by series of ENTRY to spill windowed registers.
+ (__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
+ instead of making linux spill syscall.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226962
+
+ libgcc/config/xtensa/lib2funcs.S | 30 +++++++++++++++++++++++-------
+ 1 file changed, 23 insertions(+), 7 deletions(-)
+
+diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
+index 4d451c8..ef0703f 100644
+--- a/libgcc/config/xtensa/lib2funcs.S
++++ b/libgcc/config/xtensa/lib2funcs.S
+@@ -34,10 +34,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ .global __xtensa_libgcc_window_spill
+ .type __xtensa_libgcc_window_spill,@function
+ __xtensa_libgcc_window_spill:
+- entry sp, 32
+- movi a2, 0
+- syscall
++ entry sp, 48
++#if XCHAL_NUM_AREGS > 16
++ call12 1f
++ retw
++ .align 4
++1:
++ .rept (XCHAL_NUM_AREGS - 24) / 12
++ _entry sp, 48
++ mov a12, a0
++ .endr
++ _entry sp, 16
++#if XCHAL_NUM_AREGS % 12 == 0
++ mov a4, a4
++#elif XCHAL_NUM_AREGS % 12 == 4
++ mov a8, a8
++#elif XCHAL_NUM_AREGS % 12 == 8
++ mov a12, a12
++#endif
+ retw
++#else
++ mov a8, a8
++ retw
++#endif
+ .size __xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
+ #endif
+
+@@ -61,10 +80,7 @@ __xtensa_nonlocal_goto:
+ entry sp, 32
+
+ /* Flush registers. */
+- mov a5, a2
+- movi a2, 0
+- syscall
+- mov a2, a5
++ call8 __xtensa_libgcc_window_spill
+
+ /* Because the save area for a0-a3 is stored one frame below
+ the one identified by a2, the only way to restore those
+--
+1.8.1.4
+
diff --git a/patches/gcc/5.2.0/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch b/patches/gcc/5.2.0/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch
new file mode 100644
index 0000000..9707f68
--- /dev/null
+++ b/patches/gcc/5.2.0/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch
@@ -0,0 +1,31 @@
+From 7d7a85f75ba218df4a4226e95865fc8fa561cb86 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Fri, 14 Aug 2015 02:45:02 +0300
+Subject: [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde
+
+This allows having exception cleanup code in binaries that don't
+register their unwind tables.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/t-windowed (LIB2ADDEH): Replace unwind-dw2-fde
+ with unwind-dw2-fde-dip.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226963
+
+ libgcc/config/xtensa/t-windowed | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libgcc/config/xtensa/t-windowed b/libgcc/config/xtensa/t-windowed
+index 7d9e9db..a99156c 100644
+--- a/libgcc/config/xtensa/t-windowed
++++ b/libgcc/config/xtensa/t-windowed
+@@ -1,2 +1,2 @@
+ LIB2ADDEH = $(srcdir)/config/xtensa/unwind-dw2-xtensa.c \
+- $(srcdir)/unwind-dw2-fde.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
++ $(srcdir)/unwind-dw2-fde-dip.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+--
+1.8.1.4
+
diff --git a/patches/gcc/5.2.0/873-xtensa-fix-_Unwind_GetCFA.patch b/patches/gcc/5.2.0/873-xtensa-fix-_Unwind_GetCFA.patch
new file mode 100644
index 0000000..2d8eb7c
--- /dev/null
+++ b/patches/gcc/5.2.0/873-xtensa-fix-_Unwind_GetCFA.patch
@@ -0,0 +1,40 @@
+From b33905dc310f475ddbde4c9fb7230724b2068a2b Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sat, 15 Aug 2015 05:12:11 +0300
+Subject: [PATCH 3/3] xtensa: fix _Unwind_GetCFA
+
+Returning context->cfa in _Unwind_GetCFA makes CFA point one stack frame
+higher than what was actually used by code at context->ra. This results
+in invalid CFA value in signal frames and premature unwinding completion
+in forced unwinding used by uClibc NPTL thread cancellation.
+Returning context->sp from _Unwind_GetCFA makes all CFA values valid and
+matching code that used them.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/unwind-dw2-xtensa.c (_Unwind_GetCFA): Return
+ context->sp instead of context->cfa.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226964
+
+ libgcc/config/xtensa/unwind-dw2-xtensa.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libgcc/config/xtensa/unwind-dw2-xtensa.c b/libgcc/config/xtensa/unwind-dw2-xtensa.c
+index 82b0e63..8e579c7 100644
+--- a/libgcc/config/xtensa/unwind-dw2-xtensa.c
++++ b/libgcc/config/xtensa/unwind-dw2-xtensa.c
+@@ -130,7 +130,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
+ _Unwind_Word
+ _Unwind_GetCFA (struct _Unwind_Context *context)
+ {
+- return (_Unwind_Ptr) context->cfa;
++ return (_Unwind_Ptr) context->sp;
+ }
+
+ /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
+--
+1.8.1.4
+
diff --git a/patches/gcc/5.2.0/100-libitm-fixes-for-musl-support.patch b/patches/gcc/5.2.0/900-libitm-fixes-for-musl-support.patch
index 96a724b..fdf4ee7 100644
--- a/patches/gcc/5.2.0/100-libitm-fixes-for-musl-support.patch
+++ b/patches/gcc/5.2.0/900-libitm-fixes-for-musl-support.patch
@@ -17,11 +17,11 @@ On behalf of Szabolcs.Nagy@arm.com
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222325 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/libitm/config/arm/hwcap.cc b/libitm/config/arm/hwcap.cc
-index a1c2cfd..ea8f023 100644
+Index: b/libitm/config/arm/hwcap.cc
+===================================================================
--- a/libitm/config/arm/hwcap.cc
+++ b/libitm/config/arm/hwcap.cc
-@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0
+@@ -40,7 +40,7 @@
#ifdef __linux__
#include <unistd.h>
@@ -30,8 +30,8 @@ index a1c2cfd..ea8f023 100644
#include <elf.h>
static void __attribute__((constructor))
-diff --git a/libitm/config/linux/x86/tls.h b/libitm/config/linux/x86/tls.h
-index e731ab7..54ad8b6 100644
+Index: b/libitm/config/linux/x86/tls.h
+===================================================================
--- a/libitm/config/linux/x86/tls.h
+++ b/libitm/config/linux/x86/tls.h
@@ -25,16 +25,19 @@
@@ -56,7 +56,7 @@ index e731ab7..54ad8b6 100644
namespace GTM HIDDEN {
#ifdef __x86_64__
-@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct abi_dispatch *x)
+@@ -101,5 +104,6 @@
} // namespace GTM
#endif /* >= GLIBC 2.10 */
diff --git a/patches/gcc/5.2.0/101-fixincludes-update-for-musl-support.patch b/patches/gcc/5.2.0/901-fixincludes-update-for-musl-support.patch
index 6bc3f54..13c08d6 100644
--- a/patches/gcc/5.2.0/101-fixincludes-update-for-musl-support.patch
+++ b/patches/gcc/5.2.0/901-fixincludes-update-for-musl-support.patch
@@ -16,11 +16,11 @@ On behalf of Szabolcs.Nagy@arm.com
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222327 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
-index 6653fed..0d96c8c 100755
+Index: b/fixincludes/mkfixinc.sh
+===================================================================
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
-@@ -19,7 +19,8 @@ case $machine in
+@@ -19,7 +19,8 @@
powerpc-*-eabi* | \
powerpc-*-rtems* | \
powerpcle-*-eabisim* | \
diff --git a/patches/gcc/5.2.0/102-unwind-fix-for-musl.patch b/patches/gcc/5.2.0/902-unwind-fix-for-musl.patch
index 6db0e6f..ef47054 100644
--- a/patches/gcc/5.2.0/102-unwind-fix-for-musl.patch
+++ b/patches/gcc/5.2.0/902-unwind-fix-for-musl.patch
@@ -17,8 +17,8 @@ On behalf of szabolcs.nagy@arm.com
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222328 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
-index e1e566b..137dced 100644
+Index: b/libgcc/unwind-dw2-fde-dip.c
+===================================================================
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -59,6 +59,12 @@
diff --git a/patches/gcc/5.2.0/103-libstdc++-libgfortran-gthr-workaround-for-musl.patch b/patches/gcc/5.2.0/903-libstdc++-libgfortran-gthr-workaround-for-musl.patch
index df1d321..c852131 100644
--- a/patches/gcc/5.2.0/103-libstdc++-libgfortran-gthr-workaround-for-musl.patch
+++ b/patches/gcc/5.2.0/903-libstdc++-libgfortran-gthr-workaround-for-musl.patch
@@ -24,11 +24,11 @@ On behalf of szabolcs.nagy@arm.com
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222329 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
-index ba890f9..30b8b1a6 100644
+Index: b/libgfortran/acinclude.m4
+===================================================================
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
-@@ -100,7 +100,7 @@ void foo (void);
+@@ -100,7 +100,7 @@
[Define to 1 if the target supports #pragma weak])
fi
case "$host" in
@@ -37,11 +37,11 @@ index ba890f9..30b8b1a6 100644
AC_DEFINE(GTHREAD_USE_WEAK, 0,
[Define to 0 if the target shouldn't use #pragma weak])
;;
-diff --git a/libgfortran/configure b/libgfortran/configure
-index e1592f7..07542e1 100755
+Index: b/libgfortran/configure
+===================================================================
--- a/libgfortran/configure
+++ b/libgfortran/configure
-@@ -26447,7 +26447,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>confdefs.h
+@@ -26447,7 +26447,7 @@
fi
case "$host" in
@@ -50,8 +50,8 @@ index e1592f7..07542e1 100755
$as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
-diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h
-index 45bf52a..103ec0e 100644
+Index: b/libstdc++-v3/config/os/generic/os_defines.h
+===================================================================
--- a/libstdc++-v3/config/os/generic/os_defines.h
+++ b/libstdc++-v3/config/os/generic/os_defines.h
@@ -33,4 +33,9 @@
@@ -64,11 +64,11 @@ index 45bf52a..103ec0e 100644
+#define _GLIBCXX_GTHREAD_USE_WEAK 0
+
#endif
-diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
-index 82ddc52..a349ce3 100644
+Index: b/libstdc++-v3/configure.host
+===================================================================
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
-@@ -271,6 +271,9 @@ case "${host_os}" in
+@@ -271,6 +271,9 @@
freebsd*)
os_include_dir="os/bsd/freebsd"
;;
diff --git a/patches/gcc/5.2.0/104-musl-libc-config.patch b/patches/gcc/5.2.0/904-musl-libc-config.patch
index 7020a3d..8549140 100644
--- a/patches/gcc/5.2.0/104-musl-libc-config.patch
+++ b/patches/gcc/5.2.0/904-musl-libc-config.patch
@@ -25,11 +25,11 @@ X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config.gcc b/gcc/config.gcc
-index 938d619..e993e5d 100644
+Index: b/gcc/config.gcc
+===================================================================
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
-@@ -575,7 +575,7 @@ case ${target} in
+@@ -575,7 +575,7 @@
esac
# Common C libraries.
@@ -38,7 +38,7 @@ index 938d619..e993e5d 100644
# 32-bit x86 processors supported by --with-arch=. Each processor
# MUST be separated by exactly one space.
-@@ -728,6 +728,9 @@ case ${target} in
+@@ -720,6 +720,9 @@
*-*-*uclibc*)
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
;;
@@ -48,11 +48,11 @@ index 938d619..e993e5d 100644
*)
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
;;
-diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index 857389a..b551c56 100644
+Index: b/gcc/config/linux.h
+===================================================================
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
-@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -32,10 +32,12 @@
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
@@ -65,7 +65,7 @@ index 857389a..b551c56 100644
#endif
#define GNU_USER_TARGET_OS_CPP_BUILTINS() \
-@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -50,21 +52,25 @@
} while (0)
/* Determine which dynamic linker to use depending on whether GLIBC or
@@ -101,7 +101,7 @@ index 857389a..b551c56 100644
#else
#error "Unsupported DEFAULT_LIBC"
#endif /* DEFAULT_LIBC */
-@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -81,24 +87,100 @@
#define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
#define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
#define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
@@ -206,11 +206,11 @@ index 857389a..b551c56 100644
#if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
/* This is a *uclinux* target. We don't define below macros to normal linux
versions, because doing so would require *uclinux* targets to include
-diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
-index c054338..ef055a7 100644
+Index: b/gcc/config/linux.opt
+===================================================================
--- a/gcc/config/linux.opt
+++ b/gcc/config/linux.opt
-@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
+@@ -28,5 +28,9 @@
Use GNU C library
muclibc
@@ -221,29 +221,11 @@ index c054338..ef055a7 100644
+mmusl
+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
+Use musl C library
-diff --git a/gcc/configure b/gcc/configure
-index e563e94..b99eb6d 100755
+Index: b/gcc/configure
+===================================================================
--- a/gcc/configure
+++ b/gcc/configure
-@@ -27740,6 +27740,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
- else
- gcc_cv_libc_provides_ssp=no
- case "$target" in
-+ *-*-musl*)
-+ # All versions of musl provide stack protector
-+ gcc_cv_libc_provides_ssp=yes;;
- *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
- # glibc 2.4 and later provides __stack_chk_fail and
- # either __stack_chk_guard, or TLS access to stack guard canary.
-@@ -27772,6 +27775,7 @@ fi
- # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
- # simply assert that glibc does provide this, which is true for all
- # realistically usable GNU/Hurd configurations.
-+ # All supported versions of musl provide it as well
- gcc_cv_libc_provides_ssp=yes;;
- *-*-darwin* | *-*-freebsd*)
- ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
-@@ -27868,6 +27872,9 @@ case "$target" in
+@@ -27809,6 +27813,9 @@
gcc_cv_target_dl_iterate_phdr=no
fi
;;
@@ -253,29 +235,11 @@ index e563e94..b99eb6d 100755
esac
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
-diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 55fe633..810725c 100644
+Index: b/gcc/configure.ac
+===================================================================
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
-@@ -5247,6 +5247,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
- gcc_cv_libc_provides_ssp,
- [gcc_cv_libc_provides_ssp=no
- case "$target" in
-+ *-*-musl*)
-+ # All versions of musl provide stack protector
-+ gcc_cv_libc_provides_ssp=yes;;
- *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
- # glibc 2.4 and later provides __stack_chk_fail and
- # either __stack_chk_guard, or TLS access to stack guard canary.
-@@ -5273,6 +5276,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
- # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
- # simply assert that glibc does provide this, which is true for all
- # realistically usable GNU/Hurd configurations.
-+ # All supported versions of musl provide it as well
- gcc_cv_libc_provides_ssp=yes;;
- *-*-darwin* | *-*-freebsd*)
- AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
-@@ -5346,6 +5350,9 @@ case "$target" in
+@@ -5298,6 +5302,9 @@
gcc_cv_target_dl_iterate_phdr=no
fi
;;
@@ -285,11 +249,11 @@ index 55fe633..810725c 100644
esac
GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index cb5ae17..9169731 100644
+Index: b/gcc/doc/invoke.texi
+===================================================================
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
-@@ -669,7 +669,7 @@ Objective-C and Objective-C++ Dialects}.
+@@ -667,7 +667,7 @@
-mcpu=@var{cpu}}
@emph{GNU/Linux Options}
@@ -298,7 +262,7 @@ index cb5ae17..9169731 100644
-tno-android-cc -tno-android-ld}
@emph{H8/300 Options}
-@@ -15384,13 +15384,19 @@ These @samp{-m} options are defined for GNU/Linux targets:
+@@ -15324,13 +15324,19 @@
@item -mglibc
@opindex mglibc
Use the GNU C library. This is the default except
diff --git a/patches/gcc/5.2.0/105-add-musl-support-to-gcc.patch b/patches/gcc/5.2.0/905-add-musl-support-to-gcc.patch
index a1c3e08..92e7436 100644
--- a/patches/gcc/5.2.0/105-add-musl-support-to-gcc.patch
+++ b/patches/gcc/5.2.0/905-add-musl-support-to-gcc.patch
@@ -19,11 +19,11 @@ X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=f2d678afa5b83
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222905 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
-index c567f43..475ea06 100644
+Index: b/gcc/config/alpha/linux.h
+===================================================================
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
-@@ -61,10 +61,14 @@ along with GCC; see the file COPYING3. If not see
+@@ -61,10 +61,14 @@
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
@@ -38,11 +38,11 @@ index c567f43..475ea06 100644
#endif
/* Determine what functions are present at the runtime;
-diff --git a/gcc/config/glibc-stdint.h b/gcc/config/glibc-stdint.h
-index 3fc67dc..98f4f04 100644
+Index: b/gcc/config/glibc-stdint.h
+===================================================================
--- a/gcc/config/glibc-stdint.h
+++ b/gcc/config/glibc-stdint.h
-@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Exception along with this program;
+@@ -22,6 +22,12 @@
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
@@ -55,7 +55,7 @@ index 3fc67dc..98f4f04 100644
#define SIG_ATOMIC_TYPE "int"
#define INT8_TYPE "signed char"
-@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -43,12 +49,12 @@
#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
#define INT_FAST8_TYPE "signed char"
@@ -72,11 +72,11 @@ index 3fc67dc..98f4f04 100644
#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
-diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index b551c56..7bc87ab 100644
+Index: b/gcc/config/linux.h
+===================================================================
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
-@@ -32,11 +32,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -32,11 +32,13 @@
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
@@ -90,8 +90,8 @@ index b551c56..7bc87ab 100644
#define OPTION_MUSL (linux_libc == LIBC_MUSL)
#endif
-diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
-index fe0ebd6..a68ff69 100644
+Index: b/gcc/config/rs6000/linux.h
+===================================================================
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -30,10 +30,14 @@
@@ -109,11 +109,11 @@ index fe0ebd6..a68ff69 100644
#endif
/* Determine what functions are present at the runtime;
-diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
-index 0879e7e..1b7f695 100644
+Index: b/gcc/config/rs6000/linux64.h
+===================================================================
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
-@@ -299,10 +299,14 @@ extern int dot_symbols;
+@@ -299,10 +299,14 @@
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
diff --git a/patches/gcc/5.2.0/106-mips-musl-support.patch b/patches/gcc/5.2.0/906-mips-musl-support.patch
index 60a5ac0..6b473f9 100644
--- a/patches/gcc/5.2.0/106-mips-musl-support.patch
+++ b/patches/gcc/5.2.0/906-mips-musl-support.patch
@@ -16,11 +16,11 @@ X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2550b6a866c88
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222915 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
-index 91df261..fb358e2 100644
+Index: b/gcc/config/mips/linux.h
+===================================================================
--- a/gcc/config/mips/linux.h
+++ b/gcc/config/mips/linux.h
-@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3. If not see
+@@ -37,7 +37,13 @@
#define UCLIBC_DYNAMIC_LINKERN32 \
"%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
@@ -35,4 +35,3 @@ index 91df261..fb358e2 100644
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
- BIONIC_DYNAMIC_LINKERN32)
+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
-
diff --git a/patches/gcc/5.2.0/107-x86-musl-support.patch b/patches/gcc/5.2.0/907-x86-musl-support.patch
index 1ab6c44..3f2fe5d 100644
--- a/patches/gcc/5.2.0/107-x86-musl-support.patch
+++ b/patches/gcc/5.2.0/907-x86-musl-support.patch
@@ -17,22 +17,22 @@ On behalf of Szabolcs Nagy.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223218 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
-index a100963..385aefd 100644
+Index: b/gcc/config/i386/linux.h
+===================================================================
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
-@@ -21,3 +21,6 @@ along with GCC; see the file COPYING3. If not see
+@@ -21,3 +21,6 @@
#define GNU_USER_LINK_EMULATION "elf_i386"
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
-diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
-index a27d3be..e300480 100644
+Index: b/gcc/config/i386/linux64.h
+===================================================================
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
-@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+@@ -30,3 +30,10 @@
#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
diff --git a/patches/gcc/5.2.0/108-arm-musl-support.patch b/patches/gcc/5.2.0/908-arm-musl-support.patch
index 34b348f..906355a 100644
--- a/patches/gcc/5.2.0/108-arm-musl-support.patch
+++ b/patches/gcc/5.2.0/908-arm-musl-support.patch
@@ -15,8 +15,8 @@ On behalf of szabolcs.nagy@arm.com
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223749 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
-index 2cf3ca7..d51376f 100644
+Index: b/gcc/config/arm/linux-eabi.h
+===================================================================
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -77,6 +77,23 @@
diff --git a/patches/gcc/5.2.0/109-aarch64-musl-support.patch b/patches/gcc/5.2.0/909-aarch64-musl-support.patch
index d6a95ca..3d032f5 100644
--- a/patches/gcc/5.2.0/109-aarch64-musl-support.patch
+++ b/patches/gcc/5.2.0/909-aarch64-musl-support.patch
@@ -17,8 +17,8 @@ gcc/Changelog:
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223766 138bc75d-0d04-0410-961f-82ee72b054a4
---
-diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
-index ba7fc3b..1600a32 100644
+Index: b/gcc/config/aarch64/aarch64-linux.h
+===================================================================
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -23,6 +23,9 @@