aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/Config.in306
-rw-r--r--toolchain/Makefile82
-rw-r--r--toolchain/binutils/Config.in29
-rw-r--r--toolchain/binutils/Makefile102
-rw-r--r--toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch22
-rw-r--r--toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch20
-rw-r--r--toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch18
-rw-r--r--toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch37
-rw-r--r--toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch22
-rw-r--r--toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch20
-rw-r--r--toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch18
-rw-r--r--toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch37
-rw-r--r--toolchain/fortify-headers/Makefile28
-rw-r--r--toolchain/gcc/Config.in71
-rw-r--r--toolchain/gcc/Config.version25
-rw-r--r--toolchain/gcc/common.mk196
-rw-r--r--toolchain/gcc/files/alternate-arch-cc.in3
-rw-r--r--toolchain/gcc/final/Makefile82
-rw-r--r--toolchain/gcc/initial/Makefile36
-rw-r--r--toolchain/gcc/minimal/Makefile46
-rw-r--r--toolchain/gcc/patches/4.6-linaro/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch70
-rw-r--r--toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch16
-rw-r--r--toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch65
-rw-r--r--toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/4.6-linaro/200-musl.patch240
-rw-r--r--toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch47
-rw-r--r--toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch26
-rw-r--r--toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch86
-rw-r--r--toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch29
-rw-r--r--toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch20
-rw-r--r--toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt9
-rw-r--r--toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch253
-rw-r--r--toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch14
-rw-r--r--toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/999-coldfire.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch21
-rw-r--r--toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch65
-rw-r--r--toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch42
-rw-r--r--toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch94
-rw-r--r--toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch28
-rw-r--r--toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/4.8-linaro/200-musl_config.patch204
-rw-r--r--toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch40
-rw-r--r--toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch100
-rw-r--r--toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch17
-rw-r--r--toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch48
-rw-r--r--toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch12
-rw-r--r--toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch26
-rw-r--r--toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch8
-rw-r--r--toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch22
-rw-r--r--toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch25
-rw-r--r--toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch47
-rw-r--r--toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch12
-rw-r--r--toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch42
-rw-r--r--toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch9
-rw-r--r--toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch253
-rw-r--r--toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch111
-rw-r--r--toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch117
-rw-r--r--toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch65
-rw-r--r--toolchain/gcc/patches/5.2.0/002-case_insensitive.patch14
-rw-r--r--toolchain/gcc/patches/5.2.0/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch28
-rw-r--r--toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch21
-rw-r--r--toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/5.2.0/200-musl_config.patch309
-rw-r--r--toolchain/gcc/patches/5.2.0/201-musl_arm.patch43
-rw-r--r--toolchain/gcc/patches/5.2.0/202-musl_mips.patch35
-rw-r--r--toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch209
-rw-r--r--toolchain/gcc/patches/5.2.0/204-musl_sh.patch39
-rw-r--r--toolchain/gcc/patches/5.2.0/205-musl_x86.patch41
-rw-r--r--toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch31
-rw-r--r--toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch30
-rw-r--r--toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch72
-rw-r--r--toolchain/gcc/patches/5.2.0/230-musl_libssp.patch13
-rw-r--r--toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch61
-rw-r--r--toolchain/gcc/patches/5.2.0/250-add-musl.patch120
-rw-r--r--toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch34
-rw-r--r--toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch24
-rw-r--r--toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch25
-rw-r--r--toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch47
-rw-r--r--toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch12
-rw-r--r--toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch9
-rw-r--r--toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch222
-rw-r--r--toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch15
-rw-r--r--toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch111
-rw-r--r--toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gdb/Makefile49
-rw-r--r--toolchain/gdb/patches/100-no_extern_inline.patch32
-rw-r--r--toolchain/gdb/patches/110-no_testsuite.patch21
-rw-r--r--toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch11
-rw-r--r--toolchain/glibc/Config.in21
-rw-r--r--toolchain/glibc/Config.version26
-rw-r--r--toolchain/glibc/Makefile31
-rw-r--r--toolchain/glibc/common.mk109
-rw-r--r--toolchain/glibc/config/Config.in903
-rw-r--r--toolchain/glibc/headers/Makefile27
-rw-r--r--toolchain/glibc/include/libintl.h6
-rw-r--r--toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch48
-rw-r--r--toolchain/glibc/patches/2.15/005-versions.patch11
-rw-r--r--toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch110
-rw-r--r--toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch71
-rw-r--r--toolchain/glibc/patches/2.15/110-fix_cross_zic.patch27
-rw-r--r--toolchain/glibc/patches/2.15/120-use_host_cflags.patch22
-rw-r--r--toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch52
-rw-r--r--toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch13
-rw-r--r--toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch52
-rw-r--r--toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/info.mk6
-rw-r--r--toolchain/insight/Makefile54
-rw-r--r--toolchain/insight/patches/600-fix-compile-flag-mismatch.patch31
-rw-r--r--toolchain/kernel-headers/Makefile100
-rw-r--r--toolchain/musl/Config.in6
-rw-r--r--toolchain/musl/Config.version8
-rw-r--r--toolchain/musl/Makefile31
-rw-r--r--toolchain/musl/common.mk69
-rw-r--r--toolchain/musl/headers/Makefile16
-rw-r--r--toolchain/musl/include/bits/wordsize.h1
-rw-r--r--toolchain/musl/include/features.h48
-rw-r--r--toolchain/musl/include/sgidefs.h73
-rw-r--r--toolchain/musl/include/sys/cdefs.h378
-rw-r--r--toolchain/musl/include/sys/glibc-types.h35
-rw-r--r--toolchain/musl/include/sys/queue.h574
-rw-r--r--toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch154
-rw-r--r--toolchain/musl/patches/020-upstream_open_memstream.patch79
-rw-r--r--toolchain/musl/patches/100-add_glob_onlydir.patch11
-rw-r--r--toolchain/musl/patches/110-read_timezone_from_fs.patch28
-rw-r--r--toolchain/musl/patches/200-add_libssp_nonshared.patch50
-rw-r--r--toolchain/musl/patches/300-relative.patch11
-rw-r--r--toolchain/musl/patches/900-iconv_size_hack.patch68
-rw-r--r--toolchain/musl/patches/901-crypt_size_hack.patch60
-rw-r--r--toolchain/uClibc/Config.in6
-rw-r--r--toolchain/uClibc/Config.version9
-rw-r--r--toolchain/uClibc/Makefile41
-rw-r--r--toolchain/uClibc/common.mk96
-rw-r--r--toolchain/uClibc/config/arm9
-rw-r--r--toolchain/uClibc/config/armeb9
-rw-r--r--toolchain/uClibc/config/common225
-rw-r--r--toolchain/uClibc/config/debug6
-rw-r--r--toolchain/uClibc/config/i38621
-rw-r--r--toolchain/uClibc/config/i68621
-rw-r--r--toolchain/uClibc/config/m68k6
-rw-r--r--toolchain/uClibc/config/mips18
-rw-r--r--toolchain/uClibc/config/mips6418
-rw-r--r--toolchain/uClibc/config/mips64.3219
-rw-r--r--toolchain/uClibc/config/mips64.6419
-rw-r--r--toolchain/uClibc/config/mips64.n3219
-rw-r--r--toolchain/uClibc/config/mips64el18
-rw-r--r--toolchain/uClibc/config/mips64el.3219
-rw-r--r--toolchain/uClibc/config/mips64el.6419
-rw-r--r--toolchain/uClibc/config/mips64el.n3219
-rw-r--r--toolchain/uClibc/config/mipsel18
-rw-r--r--toolchain/uClibc/config/mipsel.cobalt18
-rw-r--r--toolchain/uClibc/config/powerpc6
-rw-r--r--toolchain/uClibc/config/powerpc.e5006
-rw-r--r--toolchain/uClibc/config/sparc8
-rw-r--r--toolchain/uClibc/config/sparc.leon8
-rw-r--r--toolchain/uClibc/config/x86_646
-rw-r--r--toolchain/uClibc/headers/Makefile26
-rw-r--r--toolchain/uClibc/utils/Makefile24
-rw-r--r--toolchain/wrapper/Makefile62
191 files changed, 10038 insertions, 0 deletions
diff --git a/toolchain/Config.in b/toolchain/Config.in
new file mode 100644
index 0000000..adc2b29
--- /dev/null
+++ b/toolchain/Config.in
@@ -0,0 +1,306 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menuconfig TARGET_OPTIONS
+ bool "Target Options" if DEVEL
+
+ config TARGET_OPTIMIZATION
+ string "Target Optimizations" if TARGET_OPTIONS
+ default DEFAULT_TARGET_OPTIMIZATION
+ help
+ Optimizations to use when building for the target host.
+
+ config SOFT_FLOAT
+ bool "Use software floating point by default" if TARGET_OPTIONS
+ default y if !HAS_FPU
+ depends on arm || armeb || powerpc || mipsel || mips || mips64el || mips64
+ help
+ If your target CPU does not have a Floating Point Unit (FPU) or a
+ kernel FPU emulator, but you still wish to support floating point
+ functions, then everything will need to be compiled with soft floating
+ point support (-msoft-float).
+
+ Most people will answer N.
+
+ config USE_MIPS16
+ bool "Build packages with MIPS16 instructions" if TARGET_OPTIONS
+ depends on HAS_MIPS16
+ depends on !GCC_VERSION_4_6
+ default y
+ help
+ If your target CPU does support the MIPS16 instruction set
+ and you want to use it for packages, enable this option.
+ MIPS16 produces smaller binaries thus reducing pressure on
+ caches and TLB.
+
+ Most people will answer N.
+
+
+menuconfig EXTERNAL_TOOLCHAIN
+ bool
+ prompt "Use external toolchain" if DEVEL
+ help
+ If enabled, OpenWrt will compile using an existing toolchain instead of
+ compiling one.
+
+ config NATIVE_TOOLCHAIN
+ bool
+ prompt "Use host's toolchain" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN
+ select NO_STRIP
+ help
+ If enabled, OpenWrt will compile using the native toolchain for your
+ host instead of compiling one.
+
+ config TARGET_NAME
+ string
+ prompt "Target name" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "aarch64-unknown-linux-gnu" if aarch64
+ default "aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "arm-unknown-linux-gnu" if arm
+ default "armeb-unknown-linux-gnu" if armeb
+ default "i486-unknown-linux-gnu" if i386
+ default "mips-unknown-linux-gnu" if mips
+ default "mipsel-unknown-linux-gnu" if mipsel
+ default "powerpc-unknown-linux-gnu" if powerpc
+ default "x86_64-unknown-linux-gnu" if x86_64
+
+ config TOOLCHAIN_PREFIX
+ string
+ prompt "Toolchain prefix" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "aarch64-unknown-linux-gnu" if aarch64
+ default "aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "arm-unknown-linux-gnu-" if arm
+ default "armeb-unknown-linux-gnu-" if armeb
+ default "i486-unknown-linux-gnu-" if i386
+ default "mips-unknown-linux-gnu-" if mips
+ default "mipsel-unknown-linux-gnu-" if mipsel
+ default "powerpc-unknown-linux-gnu-" if powerpc
+ default "x86_64-unknown-linux-gnu-" if x86_64
+
+ config TOOLCHAIN_ROOT
+ string
+ prompt "Toolchain root" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "/opt/cross/aarch64-unknown-linux-gnu" if aarch64
+ default "/opt/cross/aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "/opt/cross/arm-unknown-linux-gnu" if arm
+ default "/opt/cross/armeb-unknown-linux-gnu" if armeb
+ default "/opt/cross/i486-unknown-linux-gnu" if i386
+ default "/opt/cross/mips-unknown-linux-gnu" if mips
+ default "/opt/cross/mipsel-unknown-linux-gnu" if mipsel
+ default "/opt/cross/powerpc-unknown-linux-gnu" if powerpc
+ default "/opt/cross/x86_64-unknown-linux-gnu" if x86_64
+
+ config TOOLCHAIN_LIBC
+ string
+ prompt "Toolchain libc" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "uclibc"
+ help
+ Specify the libc type used by the external toolchain. The given value
+ is passed as -m flag to all gcc and g++ invocations. This is mainly
+ intended for multilib toolchains which support glibc and uclibc at
+ the same time. If no value is specified, no -m flag is passed.
+
+ config TOOLCHAIN_BIN_PATH
+ string
+ prompt "Toolchain program path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/bin ./bin"
+ help
+ Specify additional directories searched for toolchain binaries
+ (override PATH). Use ./DIR for directories relative to the root above.
+
+ config TOOLCHAIN_INC_PATH
+ string
+ prompt "Toolchain include path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/include ./include"
+ help
+ Specify additional directories searched for header files (override
+ CPPFLAGS). Use ./DIR for directories relative to the root above.
+
+ config TOOLCHAIN_LIB_PATH
+ string
+ prompt "Toolchain library path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/lib ./lib"
+ help
+ Specify additional directories searched for libraries (override LDFLAGS).
+ Use ./DIR for directories relative to the root above.
+
+config NEED_TOOLCHAIN
+ bool
+ depends on DEVEL
+ default y if !EXTERNAL_TOOLCHAIN
+
+menuconfig TOOLCHAINOPTS
+ bool "Toolchain Options" if DEVEL
+ depends on NEED_TOOLCHAIN
+
+menuconfig EXTRA_TARGET_ARCH
+ bool
+ prompt "Enable an extra toolchain target architecture" if TOOLCHAINOPTS
+ depends on !sparc
+ default y if powerpc64
+ default n
+ help
+ Some builds may require a 'biarch' toolchain. This option
+ allows you to specify an additional target arch.
+
+ Most people will answer N here.
+
+ config EXTRA_TARGET_ARCH_NAME
+ string
+ default "powerpc64" if powerpc64
+ prompt "Extra architecture name" if EXTRA_TARGET_ARCH
+ help
+ Specify the cpu name (eg powerpc64 or x86_64) of the
+ additional target architecture.
+
+ config EXTRA_TARGET_ARCH_OPTS
+ string
+ default "-m64" if powerpc64
+ prompt "Extra architecture compiler options" if EXTRA_TARGET_ARCH
+ help
+ If you're specifying an addition target architecture,
+ you'll probably need to also provide options to make
+ the compiler use this alternate arch.
+
+ For example, if you're building a compiler that can build
+ both powerpc and powerpc64 binaries, you'll need to
+ specify -m64 here.
+
+
+ choice
+ prompt "MIPS64 user-land ABI" if TOOLCHAINOPTS && (mips64 || mips64el)
+ default MIPS64_ABI_N64
+ help
+ MIPS64 supports 3 different user-land ABIs: o32 (legacy),
+ n32 and n64.
+
+ config MIPS64_ABI_N64
+ bool "n64"
+
+ config MIPS64_ABI_N32
+ bool "n32"
+
+ config MIPS64_ABI_O32
+ bool "o32"
+
+ endchoice
+
+comment "Binary tools"
+ depends on TOOLCHAINOPTS
+
+source "toolchain/binutils/Config.in"
+
+comment "Compiler"
+ depends on TOOLCHAINOPTS
+
+source "toolchain/gcc/Config.in"
+
+comment "C Library"
+ depends on TOOLCHAINOPTS
+
+choice
+ prompt "C Library implementation" if TOOLCHAINOPTS
+ default LIBC_USE_GLIBC if mips64 || mips64el
+ default LIBC_USE_MUSL
+ help
+ Select the C library implementation.
+
+ config LIBC_USE_GLIBC
+ bool "Use (e)glibc"
+ select USE_GLIBC
+
+ config LIBC_USE_UCLIBC
+ select USE_UCLIBC
+ bool "Use uClibc"
+ depends on !(aarch64 || aarch64_be)
+
+ config LIBC_USE_MUSL
+ select USE_MUSL
+ bool "Use musl"
+ depends on !(mips64 || mips64el)
+
+endchoice
+
+source "toolchain/glibc/Config.in"
+source "toolchain/uClibc/Config.in"
+source "toolchain/musl/Config.in"
+
+comment "Debuggers"
+ depends on TOOLCHAINOPTS
+
+config GDB
+ bool
+ depends on !(aarch64 || aarch64_be)
+ prompt "Build gdb" if TOOLCHAINOPTS
+ default y if !EXTERNAL_TOOLCHAIN
+ help
+ Enable if you want to build the gdb.
+
+config INSIGHT
+ bool
+ prompt "Build insight-gdb" if TOOLCHAINOPTS
+ select GDB
+ default n
+ help
+ Enable if you want to build insight-gdb.
+
+config USE_GLIBC
+ bool
+
+config USE_UCLIBC
+ default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && (mips64 || mips64el)
+ bool
+
+config USE_MUSL
+ default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && !(mips64 || mips64el)
+ bool
+
+config USE_EXTERNAL_LIBC
+ bool
+ default y if EXTERNAL_TOOLCHAIN || NATIVE_TOOLCHAIN
+
+source "toolchain/gcc/Config.version"
+
+source "toolchain/glibc/Config.version"
+source "toolchain/uClibc/Config.version"
+source "toolchain/musl/Config.version"
+
+config LIBC
+ string
+ default "glibc" if USE_GLIBC
+ default "uClibc" if USE_UCLIBC
+ default "musl" if USE_MUSL
+
+config LIBC_VERSION
+ string
+ default GLIBC_VERSION if USE_GLIBC
+ default UCLIBC_VERSION if USE_UCLIBC
+ default MUSL_VERSION if USE_MUSL
+
+config TARGET_SUFFIX
+ string
+ default "gnueabi" if USE_GLIBC && (arm || armeb)
+ default "gnu" if USE_GLIBC && !(arm || armeb)
+ default "uclibcgnueabi" if USE_UCLIBC && (arm || armeb)
+ default "uclibc" if USE_UCLIBC && !(arm || armeb)
+ default "muslgnueabi" if USE_MUSL && (arm || armeb)
+ default "musl" if USE_MUSL && !(arm || armeb)
+
+config MIPS64_ABI
+ depends on mips64 || mips64el
+ string
+ default "64" if MIPS64_ABI_N64
+ default "n32" if MIPS64_ABI_N32
+ default "32" if MIPS64_ABI_O32
+ default "64"
diff --git a/toolchain/Makefile b/toolchain/Makefile
new file mode 100644
index 0000000..cd5399e
--- /dev/null
+++ b/toolchain/Makefile
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2007-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# Main makefile for the toolchain
+#
+# Steps:
+# 1) toolchain/binutils/install
+# build & install binutils
+# 2) toolchain/gcc/minimal/install
+# build & install a minimal gcc, needed for steps 3 & 4
+# 3) toolchain/kernel-headers/install
+# install kernel headers, needed for step 4
+# 4) toolchain/libc/headers/install
+# build & install libc headers & support files, needed for step 5
+# 5) toolchain/gcc/initial/install
+# build & install an initial gcc, needed for step 6
+# 6) toolchain/libc/install
+# build & install the final libc
+# 7) toolchain/gcc/final/install
+# build & install the final gcc
+# 8) toolchain/libc/utils/install
+# build & install libc utilities
+#
+
+curdir:=toolchain
+
+# subdirectories to descend into
+$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/minimal gcc/initial gcc/final $(LIBC)/headers $(LIBC) fortify-headers)
+ifdef CONFIG_USE_UCLIBC
+ $(curdir)/builddirs += $(LIBC)/utils
+endif
+$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
+$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
+
+# builddir dependencies
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+ $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
+ $(curdir)/kernel-headers/install:=$(curdir)/gcc/minimal/install
+ $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
+ $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
+
+ $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install
+ $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
+ $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
+ $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install
+ $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install
+ $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
+ $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare
+endif
+
+ifndef DUMP_TARGET_DB
+ifneq ($(ARCH),)
+ $(TOOLCHAIN_DIR)/info.mk: .config
+ @for dir in $(TOOLCHAIN_DIR); do ( \
+ $(if $(QUIET),,set -x;) \
+ mkdir -p "$$dir"; \
+ cd "$$dir"; \
+ ln -nsf lib lib64; \
+ ln -nsf lib lib32; \
+ mkdir -p stamp lib usr/include usr/lib ; \
+ ); done
+ @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
+ @touch $@
+endif
+endif
+
+# prerequisites for the individual targets
+$(curdir)/ := .config prereq
+$(curdir)//prepare = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk $(tools/stamp-install)
+$(curdir)//compile = $(1)/prepare
+$(curdir)//install = $(1)/compile
+
+ifndef DUMP_TARGET_DB
+$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
+endif
+
+$(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
+$(eval $(call subdir,$(curdir)))
+
diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in
new file mode 100644
index 0000000..27b2ffa
--- /dev/null
+++ b/toolchain/binutils/Config.in
@@ -0,0 +1,29 @@
+# Choose binutils version.
+
+choice
+ prompt "Binutils Version" if TOOLCHAINOPTS
+ default BINUTILS_VERSION_LINARO
+ help
+ Select the version of binutils you wish to use.
+
+ config BINUTILS_VERSION_LINARO
+ bool "Linaro binutils 2.24"
+
+ config BINUTILS_VERSION_2_25_1
+ bool "Binutils 2.25.1"
+
+endchoice
+
+config EXTRA_BINUTILS_CONFIG_OPTIONS
+ string
+ prompt "Additional binutils configure options" if TOOLCHAINOPTS
+ default ""
+ help
+ Any additional binutils options you may want to include....
+
+config BINUTILS_VERSION
+ string
+ prompt "Binutils Version" if (TOOLCHAINOPTS && NULL)
+ default "linaro" if BINUTILS_VERSION_LINARO
+ default "2.25.1" if BINUTILS_VERSION_2_25_1
+ default "linaro"
diff --git a/toolchain/binutils/Makefile b/toolchain/binutils/Makefile
new file mode 100644
index 0000000..0028a02
--- /dev/null
+++ b/toolchain/binutils/Makefile
@@ -0,0 +1,102 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=binutils
+PKG_VERSION:=$(call qstrip,$(CONFIG_BINUTILS_VERSION))
+BIN_VERSION:=$(PKG_VERSION)
+
+ifeq ($(findstring linaro, $(CONFIG_BINUTILS_VERSION)),linaro)
+ PKG_SOURCE_URL:=https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/
+ PKG_REV:=2.24.0-2014.09
+ PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz
+ PKG_MD5SUM:=8f9b2b2e049d59b1b86ce9657802a353
+ BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV)
+ HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR)
+else
+ PKG_SOURCE_URL:=@GNU/binutils/
+ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+
+ ifeq ($(PKG_VERSION),2.25.1)
+ PKG_MD5SUM:=ac493a78de4fee895961d025b7905be4
+ endif
+endif
+
+HOST_BUILD_PARALLEL:=1
+
+PATCH_DIR:=./patches/$(PKG_VERSION)
+
+REAL_STAGING_DIR_HOST:=$(STAGING_DIR_HOST)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+BINUTILS_CONFIGURE:= \
+ ./configure \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --with-sysroot=$(TOOLCHAIN_DIR) \
+ --enable-deterministic-archives \
+ --enable-plugins \
+ --disable-multilib \
+ --disable-werror \
+ --disable-nls \
+ $(GRAPHITE_CONFIGURE) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS))
+
+ifneq ($(CONFIG_SSP_SUPPORT),)
+ BINUTILS_CONFIGURE+= \
+ --enable-libssp
+else
+ BINUTILS_CONFIGURE+= \
+ --disable-libssp
+endif
+
+ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
+ BINUTILS_CONFIGURE+= \
+ --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
+endif
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ ln -snf $(notdir $(HOST_BUILD_DIR)) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
+ $(SED) 's, " Linaro.*,,' $(HOST_BUILD_DIR)/bfd/version.h
+endef
+
+define Host/Configure
+ (cd $(HOST_BUILD_DIR); \
+ $(BINUTILS_CONFIGURE) \
+ );
+endef
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) all
+endef
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/initial
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ prefix=$(TOOLCHAIN_DIR)/initial \
+ install
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ prefix=$(TOOLCHAIN_DIR) \
+ install
+ $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial)
+ $(RM) $(TOOLCHAIN_DIR)/initial/lib/libiberty.a
+ $(CP) $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-readelf $(REAL_STAGING_DIR_HOST)/bin/readelf
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000..c51fc00
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch
@@ -0,0 +1,22 @@
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -54,7 +54,7 @@ endif
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -388,7 +388,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000..2e24b38
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,20 @@
+--- a/ld/emultempl/elf32.em
++++ b/ld/emultempl/elf32.em
+@@ -1198,6 +1198,8 @@ fragment <<EOF
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1461,6 +1463,8 @@ gld${EMULATION_NAME}_before_allocation (
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+
+ for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
diff --git a/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch
new file mode 100644
index 0000000..a63203d
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch
@@ -0,0 +1,18 @@
+--- a/bfd/elfxx-mips.c
++++ b/bfd/elfxx-mips.c
+@@ -7689,6 +7689,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
+ bh = NULL;
++ if (0) {
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
+ NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+@@ -7701,6 +7702,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
++ }
+
+ if (! mips_elf_hash_table (info)->use_rld_obj_head)
+ {
diff --git a/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch
new file mode 100644
index 0000000..3343a85
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch
@@ -0,0 +1,37 @@
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -1062,12 +1062,12 @@ case "${targ}" in
+ targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
+ ;;
+ mips64*el-*-linux*)
+- targ_defvec=mips_elf32_ntrad_le_vec
+- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
++ targ_defvec=mips_elf64_trad_le_vec
++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec"
+ ;;
+ mips64*-*-linux*)
+- targ_defvec=mips_elf32_ntrad_be_vec
+- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
++ targ_defvec=mips_elf64_trad_be_vec
++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec"
+ ;;
+ mips*el-*-linux*)
+ targ_defvec=mips_elf32_trad_le_vec
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -476,11 +476,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
+ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
+ targ_extra_emuls="elf32elmipvxworks" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
+- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
++mips64*el-*-linux-*) targ_emul=elf64ltsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+-mips64*-*-linux-*) targ_emul=elf32btsmipn32
+- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
++mips64*-*-linux-*) targ_emul=elf64btsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ mips*el-*-linux-*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
diff --git a/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000..0efcd18
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch
@@ -0,0 +1,22 @@
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -54,7 +54,7 @@ endif
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -386,7 +386,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000..37752b7
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,20 @@
+--- a/ld/emultempl/elf32.em
++++ b/ld/emultempl/elf32.em
+@@ -1267,6 +1267,8 @@ fragment <<EOF
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1518,6 +1520,8 @@ gld${EMULATION_NAME}_before_allocation (
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+
+ for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
diff --git a/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch
new file mode 100644
index 0000000..251134f
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch
@@ -0,0 +1,18 @@
+--- a/bfd/elfxx-mips.c
++++ b/bfd/elfxx-mips.c
+@@ -7450,6 +7450,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
+ bh = NULL;
++ if (0) {
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
+ NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+@@ -7462,6 +7463,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
++ }
+
+ if (! mips_elf_hash_table (info)->use_rld_obj_head)
+ {
diff --git a/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch
new file mode 100644
index 0000000..cd036be
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch
@@ -0,0 +1,37 @@
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -1053,12 +1053,12 @@ case "${targ}" in
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+ mips64*el-*-linux*)
+- targ_defvec=bfd_elf32_ntradlittlemips_vec
+- targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec"
++ targ_defvec=bfd_elf64_tradlittlemips_vec
++ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec"
+ ;;
+ mips64*-*-linux*)
+- targ_defvec=bfd_elf32_ntradbigmips_vec
+- targ_selvecs="bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
++ targ_defvec=bfd_elf64_tradbigmips_vec
++ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradlittlemips_vec"
+ ;;
+ mips*el-*-linux*)
+ targ_defvec=bfd_elf32_tradlittlemips_vec
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -472,11 +472,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
+ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
+ targ_extra_emuls="elf32elmipvxworks" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
+- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
++mips64*el-*-linux-*) targ_emul=elf64ltsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+-mips64*-*-linux-*) targ_emul=elf32btsmipn32
+- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
++mips64*-*-linux-*) targ_emul=elf64btsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ mips*el-*-linux-*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
diff --git a/toolchain/fortify-headers/Makefile b/toolchain/fortify-headers/Makefile
new file mode 100644
index 0000000..8d952c5
--- /dev/null
+++ b/toolchain/fortify-headers/Makefile
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_NAME:=fortify-headers
+PKG_VERSION:=0.7
+PKG_RELEASE=1
+
+PKG_SOURCE_URL:=http://dl.2f30.org/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_MD5SUM:=3f7c36daa0be000987e8ad8c0a202b42
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+define Host/Compile
+ true
+endef
+
+define Host/Install
+ $(MAKE) -C $(HOST_BUILD_DIR) PREFIX="" DESTDIR="$(TOOLCHAIN_DIR)" install
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in
new file mode 100644
index 0000000..2d4400a
--- /dev/null
+++ b/toolchain/gcc/Config.in
@@ -0,0 +1,71 @@
+# Choose gcc version.
+
+choice
+ prompt "GCC compiler Version" if TOOLCHAINOPTS
+ default GCC_USE_VERSION_4_6_LINARO if TARGET_octeon
+ default GCC_USE_VERSION_4_8_LINARO
+ help
+ Select the version of gcc you wish to use.
+
+ config GCC_USE_VERSION_4_6_LINARO
+ select GCC_VERSION_4_6_LINARO
+ bool "gcc 4.6.x with Linaro enhancements"
+
+ config GCC_USE_VERSION_4_8_LINARO
+ select GCC_VERSION_4_8_LINARO
+ bool "gcc 4.8.x with Linaro enhancements"
+
+ config GCC_USE_VERSION_5
+ select GCC_VERSION_5
+ bool "gcc 5.x"
+
+endchoice
+
+config GCC_USE_GRAPHITE
+ bool
+ prompt "Compile in support for the new Graphite framework in GCC 4.4+" if TOOLCHAINOPTS
+
+config GCC_USE_SYSTEM_PPL_CLOOG
+ bool
+ prompt "Use the system versions of PPL and CLooG"
+ depends on GCC_USE_GRAPHITE
+ default n
+
+config EXTRA_GCC_CONFIG_OPTIONS
+ string
+ prompt "Additional gcc configure options" if TOOLCHAINOPTS
+ default ""
+ help
+ Any additional gcc options you may want to include....
+
+config SSP_SUPPORT
+ bool
+ prompt "Enable Stack-Smashing Protection support" if TOOLCHAINOPTS
+ depends on !USE_MUSL
+ default y if !USE_MUSL
+ help
+ Enable Stack-Smashing Protection support
+
+config SJLJ_EXCEPTIONS
+ bool
+ prompt "Use setjump()/longjump() exceptions" if TOOLCHAINOPTS
+ default n
+ help
+ Use old setjump()/longjump() exceptions instead of the newer
+ frame unwinding exceptions handling routines. Warning: increases
+ code size and runtime memory usage.
+
+config INSTALL_LIBGCJ
+ bool
+ prompt "Build/install java compiler and GNU classpath ?" if TOOLCHAINOPTS
+ default n
+ help
+ Build/install java compiler and GNU classpath ?
+
+
+config INSTALL_GFORTRAN
+ bool
+ prompt "Build/install fortran compiler?" if TOOLCHAINOPTS
+ default n
+ help
+ Build/install GNU fortran compiler ?
diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version
new file mode 100644
index 0000000..9636fca
--- /dev/null
+++ b/toolchain/gcc/Config.version
@@ -0,0 +1,25 @@
+config GCC_VERSION_4_6_LINARO
+ default y if (!TOOLCHAINOPTS && TARGET_octeon)
+ bool
+
+config GCC_VERSION_4_8_LINARO
+ default y if (!TOOLCHAINOPTS && !TARGET_octeon)
+ bool
+
+config GCC_VERSION
+ string
+ default "5.2.0" if GCC_VERSION_5
+ default "4.6-linaro" if GCC_VERSION_4_6_LINARO
+ default "4.8-linaro" if GCC_VERSION_4_8_LINARO
+ default "4.6-linaro"
+
+config GCC_VERSION_4_6
+ bool
+ default y if GCC_VERSION_4_6_LINARO
+
+config GCC_VERSION_4_8
+ bool
+ default y if GCC_VERSION_4_8_LINARO
+
+config GCC_VERSION_5
+ bool
diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
new file mode 100644
index 0000000..b33769c
--- /dev/null
+++ b/toolchain/gcc/common.mk
@@ -0,0 +1,196 @@
+#
+# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
+# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gcc
+GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
+PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
+GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
+ LINARO_RELEASE:=
+ ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
+ PKG_REV:=4.6-2013.05
+ PKG_VERSION:=4.6.4
+ PKG_VERSION_MAJOR:=4.6
+ PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7
+ PKG_COMP:=bz2
+ endif
+ ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro")
+ PKG_REV:=4.8-2014.04
+ PKG_VERSION:=4.8.3
+ PKG_VERSION_MAJOR:=4.8
+ PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03
+ PKG_COMP:=xz
+ endif
+ ifneq ($(LINARO_RELEASE),)
+ PKG_SOURCE_URL:=http://releases.linaro.org/$(LINARO_RELEASE)/components/toolchain/gcc-linaro/$(PKG_VERSION_MAJOR)
+ else
+ PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
+ endif
+ PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP)
+ GCC_DIR:=gcc-linaro-$(PKG_REV)
+ HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
+else
+ PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
+ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+
+ ifeq ($(PKG_VERSION),4.8.0)
+ PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0
+ endif
+ ifeq ($(PKG_VERSION),5.2.0)
+ PKG_MD5SUM:=a51bcfeb3da7dd4c623e27207ed43467
+ endif
+endif
+
+PATCH_DIR=../patches/$(GCC_VERSION)
+
+BUGURL=https://dev.openwrt.org/
+ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
+ PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION)
+else
+ PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)
+endif
+
+HOST_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
+ifeq ($(GCC_VARIANT),minimal)
+ GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
+else
+ HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
+ GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
+endif
+
+HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
+HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
+HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
+HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
+
+SEP:=,
+TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
+
+export libgcc_cv_fixed_point=no
+ifdef CONFIG_USE_UCLIBC
+ export glibcxx_cv_c99_math_tr1=no
+endif
+
+GCC_CONFIGURE:= \
+ SHELL="$(BASH)" \
+ $(if $(shell gcc --version 2>&1 | grep LLVM), \
+ CFLAGS="-O2 -fbracket-depth=512 -pipe" \
+ CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
+ ) \
+ $(HOST_SOURCE_DIR)/configure \
+ --with-bugurl=$(BUGURL) \
+ --with-pkgversion="$(PKGVERSION)" \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --with-gnu-ld \
+ --enable-target-optspace \
+ --disable-libgomp \
+ --disable-libmudflap \
+ --disable-multilib \
+ --disable-nls \
+ $(GRAPHITE_CONFIGURE) \
+ --with-host-libstdcxx=-lstdc++ \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
+ $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
+ --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
+ --with-gmp=$(TOPDIR)/staging_dir/host \
+ --with-mpfr=$(TOPDIR)/staging_dir/host \
+ --with-mpc=$(TOPDIR)/staging_dir/host \
+ --disable-decimal-float
+ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
+ GCC_CONFIGURE += --with-mips-plt
+endif
+
+ifneq ($(CONFIG_SSP_SUPPORT),)
+ GCC_CONFIGURE+= \
+ --enable-libssp
+else
+ GCC_CONFIGURE+= \
+ --disable-libssp
+endif
+
+ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
+ GCC_CONFIGURE+= \
+ --enable-biarch \
+ --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
+endif
+
+ifdef CONFIG_sparc
+ GCC_CONFIGURE+= \
+ --enable-targets=all \
+ --with-long-double-128
+endif
+
+ifeq ($(LIBC),uClibc)
+ GCC_CONFIGURE+= \
+ --disable-__cxa_atexit
+else
+ GCC_CONFIGURE+= \
+ --enable-__cxa_atexit
+endif
+
+ifneq ($(GCC_ARCH),)
+ GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
+endif
+
+ifneq ($(CONFIG_SOFT_FLOAT),y)
+ ifeq ($(CONFIG_arm),y)
+ GCC_CONFIGURE+= \
+ --with-float=hard
+ endif
+endif
+
+GCC_MAKE:= \
+ export SHELL="$(BASH)"; \
+ $(MAKE) \
+ CFLAGS="$(HOST_CFLAGS)" \
+ CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
+ CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
+
+define Host/Prepare
+ mkdir -p $(GCC_BUILD_DIR)
+endef
+
+define Host/Configure
+ (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
+ $(GCC_CONFIGURE) \
+ );
+endef
+
+define Host/Clean
+ rm -rf \
+ $(STAGING_DIR_HOST)/stamp/.gcc_* \
+ $(STAGING_DIR_HOST)/stamp/.binutils_* \
+ $(GCC_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
+ $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
+ $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
+endef
diff --git a/toolchain/gcc/files/alternate-arch-cc.in b/toolchain/gcc/files/alternate-arch-cc.in
new file mode 100644
index 0000000..e169951
--- /dev/null
+++ b/toolchain/gcc/files/alternate-arch-cc.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec @CC_BASE@ @EXTRA_ARCH_OPTS@ "$@"
diff --git a/toolchain/gcc/final/Makefile b/toolchain/gcc/final/Makefile
new file mode 100644
index 0000000..1212d14
--- /dev/null
+++ b/toolchain/gcc/final/Makefile
@@ -0,0 +1,82 @@
+GCC_VARIANT:=final
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-headers=$(TOOLCHAIN_DIR)/include \
+ --disable-libsanitizer \
+ --enable-languages=$(TARGET_LANGUAGES) \
+ --enable-shared \
+ --enable-threads \
+ --with-slibdir=$(TOOLCHAIN_DIR)/lib
+
+ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
+ GCC_CONFIGURE += \
+ --enable-lto \
+ --with-libelf=$(TOPDIR)/staging_dir/host
+endif
+
+ifdef CONFIG_USE_MUSL
+ GCC_MAKE += gcc_cv_libc_provides_ssp=yes
+endif
+
+ifneq ($(CONFIG_SJLJ_EXCEPTIONS),)
+ GCC_CONFIGURE += \
+ --enable-sjlj-exceptions
+endif
+
+define CleanupToolchain
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
+ # Important! Required for limits.h to be fixed.
+ rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
+ ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
+ rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
+ ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
+ $(if $(CONFIG_ARCH_64BIT),ln -sf ../lib64 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib64)
+endef
+
+define Host/Configure
+ $(CleanupToolchain)
+ mkdir -p $(GCC_BUILD_DIR)
+ (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
+ $(GCC_CONFIGURE) \
+ );
+endef
+
+define Host/Compile
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
+endef
+
+define SetupExtraArch
+ for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
+ [ -e $$$$app ] || continue; \
+ old_base=$$$$(basename $$$$app); \
+ new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
+ sed -e "s/@CC_BASE@/$$$$old_base/" \
+ -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
+ ../files/alternate-arch-cc.in > \
+ $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
+ chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
+ done
+endef
+
+define Host/Install
+ $(CleanupToolchain)
+ $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
+ # Set up the symlinks to enable lying about target name.
+ set -e; \
+ (cd $(TOOLCHAIN_DIR); \
+ ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
+ cd bin; \
+ for app in $(REAL_GNU_TARGET_NAME)-* ; do \
+ ln -sf $$$${app} \
+ $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
+ done; \
+ );
+ $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
+ $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
+ $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/gcc/initial/Makefile b/toolchain/gcc/initial/Makefile
new file mode 100644
index 0000000..f0c65b5
--- /dev/null
+++ b/toolchain/gcc/initial/Makefile
@@ -0,0 +1,36 @@
+GCC_VARIANT:=initial
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-newlib \
+ --with-sysroot=$(TOOLCHAIN_DIR) \
+ --enable-languages=c \
+ --disable-shared \
+ --disable-threads \
+
+define Host/Compile
+ $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) \
+ all-build-libiberty \
+ all-gcc \
+ all-target-libgcc
+endef
+
+define Host/Install
+ $(GCC_MAKE) -C $(GCC_BUILD_DIR) \
+ prefix="$(TOOLCHAIN_DIR)/initial" \
+ install-gcc \
+ install-target-libgcc
+
+ # XXX: glibc insists on linking against libgcc_eh
+ ( cd $(TOOLCHAIN_DIR)/initial/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
+ [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
+ cp libgcc.a libgcc_initial.a; \
+ )
+
+ $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial)
+ $$(call file_copy,$(TOOLCHAIN_DIR)/initial/.,$(TOOLCHAIN_DIR)/)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/minimal/Makefile b/toolchain/gcc/minimal/Makefile
new file mode 100644
index 0000000..0344e1a
--- /dev/null
+++ b/toolchain/gcc/minimal/Makefile
@@ -0,0 +1,46 @@
+GCC_VARIANT:=minimal
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-newlib \
+ --without-headers \
+ --enable-languages=c \
+ --disable-libsanitizer \
+ --disable-libssp \
+ --disable-shared \
+ --disable-threads
+
+define Host/SetToolchainInfo
+ $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Prepare
+ $(call Host/SetToolchainInfo)
+ $(call Host/Prepare/Default)
+ ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
+ $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_BUILD_DIR)/gcc/config/*/t-*
+ $(SED) 'd' $(HOST_BUILD_DIR)/gcc/DEV-PHASE
+ $(SED) 's, DATESTAMP,,' $(HOST_BUILD_DIR)/gcc/version.c
+ #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
+ $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
+ mkdir -p $(GCC_BUILD_DIR)
+endef
+
+define Host/Compile
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all-gcc all-target-libgcc
+endef
+
+define Host/Install
+ $(GCC_MAKE) -C $(GCC_BUILD_DIR) install-gcc install-target-libgcc
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(GCC_BUILD_DIR)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/patches/4.6-linaro/010-documentation.patch b/toolchain/gcc/patches/4.6-linaro/010-documentation.patch
new file mode 100644
index 0000000..46178da
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4267,18 +4267,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/4.6-linaro/020-gcc_bug_54295.patch b/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch
new file mode 100644
index 0000000..5bef9ea
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch
@@ -0,0 +1,70 @@
+diff -urN a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
+--- a/gcc/tree-ssa-math-opts.c 2012-12-12 18:05:23.000000000 +0100
++++ b/gcc/tree-ssa-math-opts.c 2013-04-29 15:54:00.051998936 +0200
+@@ -1280,6 +1280,47 @@
+ return result;
+ }
+
++/* Return true if stmt is a type conversion operation that can be stripped
++ when used in a widening multiply operation. */
++static bool
++widening_mult_conversion_strippable_p (tree result_type, gimple stmt)
++{
++ enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
++
++ if (TREE_CODE (result_type) == INTEGER_TYPE)
++ {
++ tree op_type;
++ tree inner_op_type;
++
++ if (!CONVERT_EXPR_CODE_P (rhs_code))
++ return false;
++
++ op_type = TREE_TYPE (gimple_assign_lhs (stmt));
++
++ /* If the type of OP has the same precision as the result, then
++ we can strip this conversion. The multiply operation will be
++ selected to create the correct extension as a by-product. */
++ if (TYPE_PRECISION (result_type) == TYPE_PRECISION (op_type))
++ return true;
++
++ /* We can also strip a conversion if it preserves the signed-ness of
++ the operation and doesn't narrow the range. */
++ inner_op_type = TREE_TYPE (gimple_assign_rhs1 (stmt));
++
++ /* If the inner-most type is unsigned, then we can strip any
++ intermediate widening operation. If it's signed, then the
++ intermediate widening operation must also be signed. */
++ if ((TYPE_UNSIGNED (inner_op_type)
++ || TYPE_UNSIGNED (op_type) == TYPE_UNSIGNED (inner_op_type))
++ && TYPE_PRECISION (op_type) > TYPE_PRECISION (inner_op_type))
++ return true;
++
++ return false;
++ }
++
++ return rhs_code == FIXED_CONVERT_EXPR;
++}
++
+ /* Return true if RHS is a suitable operand for a widening multiplication,
+ assuming a target type of TYPE.
+ There are two cases:
+@@ -1296,17 +1337,13 @@
+ {
+ gimple stmt;
+ tree type1, rhs1;
+- enum tree_code rhs_code;
+
+ if (TREE_CODE (rhs) == SSA_NAME)
+ {
+ stmt = SSA_NAME_DEF_STMT (rhs);
+ if (is_gimple_assign (stmt))
+ {
+- rhs_code = gimple_assign_rhs_code (stmt);
+- if (TREE_CODE (type) == INTEGER_TYPE
+- ? !CONVERT_EXPR_CODE_P (rhs_code)
+- : rhs_code != FIXED_CONVERT_EXPR)
++ if (! widening_mult_conversion_strippable_p (type, stmt))
+ rhs1 = rhs;
+ else
+ {
diff --git a/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch b/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch
new file mode 100644
index 0000000..69569de
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch
@@ -0,0 +1,16 @@
+--- a/gcc/haifa-sched.c
++++ b/gcc/haifa-sched.c
+@@ -4654,10 +4654,12 @@ schedule_block (basic_block *target_bb)
+
+ if (recog_memoized (insn) >= 0)
+ {
++ memcpy (temp_state, curr_state, dfa_state_size);
+ cost = state_transition (curr_state, insn);
+ if (sched_pressure != SCHED_PRESSURE_WEIGHTED)
+ gcc_assert (cost < 0);
+- cycle_issued_insns++;
++ if (memcmp (temp_state, curr_state, dfa_state_size) != 0)
++ cycle_issued_insns++;
+ asm_p = false;
+ }
+ else
diff --git a/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch b/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch
new file mode 100644
index 0000000..74b9a86
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch
@@ -0,0 +1,65 @@
+--- a/gcc/config/mips/sync.md
++++ b/gcc/config/mips/sync.md
+@@ -136,7 +136,7 @@
+ [(match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 3 "register_operand" "dJ"))]
++ (match_operand:SI 3 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 4 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -177,7 +177,7 @@
+ [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 4 "register_operand" "dJ"))]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 5 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -218,7 +218,7 @@
+ (match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 4 "register_operand" "dJ"))]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_NEW_OP_12))
+ (set (match_dup 1)
+ (unspec_volatile:SI
+@@ -259,7 +259,7 @@
+ [(match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")
+ (match_dup 0)
+- (match_operand:SI 3 "register_operand" "dJ")]
++ (match_operand:SI 3 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 4 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -298,7 +298,7 @@
+ (unspec_volatile:SI
+ [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "register_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 5 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -337,7 +337,7 @@
+ [(match_operand:SI 1 "memory_operand" "+R")
+ (match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "register_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_NEW_OP_12))
+ (set (match_dup 1)
+ (unspec_volatile:SI
+@@ -546,7 +546,7 @@
+ (set (match_dup 1)
+ (unspec_volatile:SI [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "arith_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_EXCHANGE_12))]
+ "GENERATE_LL_SC"
+ { return mips_output_sync_loop (insn, operands); }
diff --git a/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/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/4.6-linaro/200-musl.patch b/toolchain/gcc/patches/4.6-linaro/200-musl.patch
new file mode 100644
index 0000000..1cc5756
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/200-musl.patch
@@ -0,0 +1,240 @@
+--- a/config.sub
++++ b/config.sub
+@@ -125,6 +125,7 @@ esac
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
++ linux-musl* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -485,7 +485,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -598,6 +598,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -78,6 +78,10 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* musl has no "classic" (i.e. broken) mode */
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -93,6 +93,7 @@ along with GCC; see the file COPYING3.
+ /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
+ #define LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+
+ #undef ASM_SPEC
+ #define ASM_SPEC \
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -65,6 +65,9 @@ see the files COPYING3 and COPYING.RUNTI
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++
+ #if TARGET_64BIT_DEFAULT
+ #define SPEC_32 "m32"
+ #define SPEC_64 "!m32"
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define LINUX_TARGET_OS_CPP_BUILTINS() \
+@@ -54,18 +56,21 @@ see the files COPYING3 and COPYING.RUNTI
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -83,13 +88,13 @@ see the files COPYING3 and COPYING.RUNTI
+
+ #define LINUX_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define LINUX_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define LINUX_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -30,3 +30,7 @@ Use GNU C library
+ muclibc
+ Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
++Use musl C library
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3.
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
++
+ /* Borrowed from sparc/linux.h */
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+--- a/gcc/ginclude/stddef.h
++++ b/gcc/ginclude/stddef.h
+@@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #ifndef _GCC_SIZE_T
+ #ifndef _SIZET_
+ #ifndef __size_t
++#ifndef __DEFINED_size_t /* musl */
+ #define __size_t__ /* BeOS */
+ #define __SIZE_T__ /* Cray Unicos/Mk */
+ #define _SIZE_T
+@@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #define ___int_size_t_h
+ #define _GCC_SIZE_T
+ #define _SIZET_
++#define __DEFINED_size_t /* musl */
+ #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
+ /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
+ #else
+@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
+ typedef long ssize_t;
+ #endif /* __BEOS__ */
+ #endif /* !(defined (__GNUG__) && defined (size_t)) */
++#endif /* __DEFINED_size_t */
+ #endif /* __size_t */
+ #endif /* _SIZET_ */
+ #endif /* _GCC_SIZE_T */
+--- a/libgomp/config/posix/time.c
++++ b/libgomp/config/posix/time.c
+@@ -28,6 +28,8 @@
+ The following implementation uses the most simple POSIX routines.
+ If present, POSIX 4 clocks should be used instead. */
+
++#define _POSIX_C_SOURCE 199309L /* for clocks */
++
+ #include "libgomp.h"
+ #include <unistd.h>
+ #if TIME_WITH_SYS_TIME
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -237,6 +237,13 @@ case "${host_os}" in
+ os_include_dir="os/bsd/freebsd"
+ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
++ # check for musl by target
++ case "${host_os}" in
++ *-musl*)
++ os_include_dir="os/generic"
++ ;;
++ *)
++
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+ elif [ "$bionic" = "yes" ]; then
+@@ -245,6 +252,9 @@ case "${host_os}" in
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
+--- a/gcc/config/mips/linux64.h
++++ b/gcc/config/mips/linux64.h
+@@ -40,9 +40,12 @@ along with GCC; see the file COPYING3.
+ #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
+ #define LINUX_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
+
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+--- a/gcc/config/sparc/linux64.h 2013-09-10 10:02:45.663973856 +0100
++++ b/gcc/config/sparc/linux64.h 2013-09-10 10:03:17.871972435 +0100
+@@ -104,6 +104,9 @@
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
+
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-sparc.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-sparc.so.1"
++
+ #ifdef SPARC_BI_ARCH
+
+ #undef SUBTARGET_EXTRA_SPECS
diff --git a/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch b/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch
new file mode 100644
index 0000000..b3f1e68
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- a/boehm-gc/include/gc.h
++++ b/boehm-gc/include/gc.h
+@@ -503,7 +503,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_of
+ #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/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch b/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch
new file mode 100644
index 0000000..eda1854
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/c_global/cstdio
++++ b/libstdc++-v3/include/c_global/cstdio
+@@ -137,7 +137,7 @@ namespace std
+ using ::vsprintf;
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined __UCLIBC__
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch b/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000..8e2d15f
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,47 @@
+--- a/libmudflap/mf-hooks2.c
++++ b/libmudflap/mf-hooks2.c
+@@ -421,7 +421,7 @@ WRAPPER2(void, bzero, void *s, size_t n)
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -431,7 +431,7 @@ WRAPPER2(void, bcopy, const void *src, v
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -441,7 +441,7 @@ WRAPPER2(int, bcmp, const void *s1, cons
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -450,7 +450,7 @@ WRAPPER2(char *, index, const char *s, i
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -459,7 +459,7 @@ WRAPPER2(char *, rindex, const char *s,
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..4b7770d
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -232,7 +232,7 @@ extern void (*arm_lang_output_object_att
+ #define TARGET_BACKTRACE (leaf_function_p () \
+ ? TARGET_TPCS_LEAF_FRAME \
+ : TARGET_TPCS_FRAME)
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN)
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN)
+ #define TARGET_AAPCS_BASED \
+ (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS)
+
diff --git a/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..60cfde4
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,26 @@
+--- 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 "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+--- a/gcc/config/arm/t-linux
++++ b/gcc/config/arm/t-linux
+@@ -23,7 +23,11 @@ TARGET_LIBGCC2_CFLAGS = -fomit-frame-poi
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _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
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
diff --git a/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch
new file mode 100644
index 0000000..3760ac2
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -747,11 +747,12 @@ $(libgcov-objects): %$(objext): $(gcc_sr
+
+ # 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)"; \
+@@ -773,7 +774,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
+@@ -954,6 +955,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/4.6-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..7e2ed69
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -46,7 +46,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/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..3be371b
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -82,10 +82,15 @@
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC BE8_LINK_SPEC \
++#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..61e1035
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch
@@ -0,0 +1,86 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -115,10 +115,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.asm, so ensure an error if this definition
+ is used. */
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,8 +60,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "-lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -52,6 +52,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/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -88,6 +88,8 @@
+ #define USE_LD_AS_NEEDED 1
+ #endif
+
++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
++
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
+
+--- a/gcc/mkmap-symver.awk
++++ b/gcc/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/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -269,6 +269,12 @@ ifeq ($(enable_shared),yes)
+ install-libunwind = install-libunwind
+ endif
+
++else
++# Not enable_shared.
++iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
++endif
++
++
+ # For -fvisibility=hidden. We need both a -fvisibility=hidden on
+ # the command line, and a #define to prevent libgcc2.h etc from
+ # overriding that with #pragmas.
+@@ -291,13 +297,6 @@ else
+ gen-hide-list = echo > $@
+ endif
+
+-else
+-# Not enable_shared.
+-iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
+-vis_hide =
+-gen-hide-list = echo > \$@
+-endif
+-
+ ifneq ($(EXTRA_PARTS),)
+ extra-parts = libgcc-extra-parts
+ INSTALL_PARTS = $(EXTRA_PARTS)
diff --git a/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch b/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch
new file mode 100644
index 0000000..381a14b
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch
@@ -0,0 +1,29 @@
+--- a/gcc/crtstuff.c
++++ b/gcc/crtstuff.c
+@@ -100,15 +100,20 @@ call_ ## FUNC (void) \
+ #if defined(OBJECT_FORMAT_ELF) \
+ && !defined(OBJECT_FORMAT_FLAT) \
+ && defined(HAVE_LD_EH_FRAME_HDR) \
+- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
+- && defined(__GLIBC__) && __GLIBC__ >= 2
++ && !defined(inhibit_libc) && !defined(CRTSTUFFT_O)
+ #include <link.h>
+ /* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h.
+ But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */
+-# if !defined(__UCLIBC__) \
+- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+-# define USE_PT_GNU_EH_FRAME
++# if defined(__UCLIBC__)
++# if (__UCLIBC_MAJOR__ > 0 || __UCLIBC_MINOR__ > 9 || \
++ (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ >= 33))
++# define USE_PT_GNU_EH_FRAME
++# endif
++# elif defined(__GLIBC__)
++# if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
++ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
++# define USE_PT_GNU_EH_FRAME
++# endif
+ # endif
+ #endif
+ #if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME)
diff --git a/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..0e15ffc
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch
@@ -0,0 +1,20 @@
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -248,13 +248,13 @@ do { \
+
+ /* Define cutoff for using external functions to save floating point.
+ When optimizing for size, use external functions when profitable. */
+-#define FP_SAVE_INLINE(FIRST_REG) (optimize_size \
++#define FP_SAVE_INLINE(FIRST_REG) (1 || (optimize_size \
+ ? ((FIRST_REG) == 62 \
+ || (FIRST_REG) == 63) \
+- : (FIRST_REG) < 64)
++ : (FIRST_REG) < 64))
+ /* And similarly for general purpose registers. */
+-#define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32 \
+- && !optimize_size)
++#define GP_SAVE_INLINE(FIRST_REG) (1 || ((FIRST_REG) < 32 \
++ && !optimize_size))
+
+ /* Put jump tables in read-only memory, rather than in .text. */
+ #define JUMP_TABLES_IN_TEXT_SECTION 0
diff --git a/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch b/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch
new file mode 100644
index 0000000..404b7d3
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch
@@ -0,0 +1,11 @@
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -383,7 +383,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/4.6-linaro/900-bad-mips16-crt b/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt
new file mode 100644
index 0000000..5bb2ffb
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt
@@ -0,0 +1,9 @@
+--- gcc/gcc/config/mips/t-libgcc-mips16~ 2013-03-26 09:09:34.209077496 -0400
++++ gcc/gcc/config/mips/t-libgcc-mips16 2013-03-26 18:21:01.717303669 -0400
+@@ -43,3 +43,6 @@
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch
new file mode 100644
index 0000000..32b408a
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/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
+@@ -103,6 +103,9 @@ static size_t deferred_count;
+ /* Number of deferred options scanned for -include. */
+ static size_t include_cursor;
+
++/* 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_cxx0x (int);
+@@ -441,6 +444,9 @@ c_common_handle_option (size_t scode, co
+ global_dc->warning_as_error_requested = value;
+ break;
+
++ case OPT_Werror_maybe_reset:
++ break;
++
+ case OPT_Wformat:
+ set_Wformat (value);
+ break;
+@@ -584,6 +590,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;
+@@ -1058,6 +1070,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
+@@ -363,6 +363,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
+@@ -794,6 +798,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
+@@ -523,6 +523,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
+@@ -1159,6 +1163,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
+@@ -477,8 +477,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 },
+@@ -494,6 +492,8 @@ static const struct default_options defa
+ { OPT_LEVELS_2_PLUS, OPT_falign_functions, 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
+@@ -1405,6 +1405,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
+@@ -164,6 +164,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
+@@ -4498,6 +4498,22 @@ This option is only supported for C and
+ @option{-Wall} and by @option{-pedantic}, 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
+@@ -6322,7 +6338,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
+@@ -627,6 +627,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/4.6-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..0b241fa
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,14 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -7830,7 +7830,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/4.6-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..9106a4a
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1326,7 +1326,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/4.6-linaro/999-coldfire.patch b/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch
new file mode 100644
index 0000000..e014386
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1809,7 +1809,7 @@ m68k-*-linux*) # Motorola m68k's runnin
+ default_m68k_cpu=68020
+ default_cf_cpu=5475
+ with_arch=${with_arch:-m68k}
+- tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h ./sysroot-suffix.h"
++ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h"
+ extra_options="${extra_options} m68k/ieee.opt"
+ tm_defines="${tm_defines} MOTOROLA=1"
+ tmake_file="${tmake_file} m68k/t-floatlib m68k/t-linux m68k/t-mlibs"
diff --git a/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch b/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch
new file mode 100644
index 0000000..7ab0d4c
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch
@@ -0,0 +1,21 @@
+--- a/gcc/cp/cfns.h
++++ b/gcc/cp/cfns.h
+@@ -53,6 +53,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ /* maximum key range = 391, duplicates = 0 */
+@@ -96,7 +99,7 @@ hash (register const char *str, register
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400
+ };
+- register int hval = len;
++ register int hval = (int)len;
+
+ switch (hval)
+ {
diff --git a/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch b/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch
new file mode 100644
index 0000000..162d651
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/002-weak_data_fix.patch b/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch
new file mode 100644
index 0000000..a740b4c
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/003-universal_initializer.patch b/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch
new file mode 100644
index 0000000..1b9a5b3
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/004-case_insensitive.patch b/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch
new file mode 100644
index 0000000..b3d2dbe
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/010-documentation.patch b/toolchain/gcc/patches/4.8-linaro/010-documentation.patch
new file mode 100644
index 0000000..5548069
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/020-no-plt-backport.patch b/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch
new file mode 100644
index 0000000..b225376
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/200-musl_config.patch b/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch
new file mode 100644
index 0000000..0142745
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch
@@ -0,0 +1,204 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -559,7 +559,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -662,6 +662,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTI
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -84,21 +89,21 @@ see the files COPYING3 and COPYING.RUNTI
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+ #undef TARGET_C99_FUNCTIONS
+-#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
++#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL)
+
+ /* Whether we have sincos that follows the GNU extension. */
+ #undef TARGET_HAS_SINCOS
+@@ -107,3 +112,74 @@ see the files COPYING3 and COPYING.RUNTI
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
++
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -30,3 +30,7 @@ Use GNU C library
+ muclibc
+ Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
++Use musl C library
+--- a/gcc/ginclude/stddef.h
++++ b/gcc/ginclude/stddef.h
+@@ -181,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #ifndef _GCC_SIZE_T
+ #ifndef _SIZET_
+ #ifndef __size_t
++#ifndef __DEFINED_size_t /* musl */
+ #define __size_t__ /* BeOS */
+ #define __SIZE_T__ /* Cray Unicos/Mk */
+ #define _SIZE_T
+@@ -197,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #define ___int_size_t_h
+ #define _GCC_SIZE_T
+ #define _SIZET_
++#define __DEFINED_size_t /* musl */
+ #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
+ || defined(__FreeBSD_kernel__)
+ /* __size_t is a typedef on FreeBSD 5, must not trash it. */
+@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
+ typedef long ssize_t;
+ #endif /* __BEOS__ */
+ #endif /* !(defined (__GNUG__) && defined (size_t)) */
++#endif /* __DEFINED_size_t */
+ #endif /* __size_t */
+ #endif /* _SIZET_ */
+ #endif /* _GCC_SIZE_T */
diff --git a/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch b/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch
new file mode 100644
index 0000000..f39ff52
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch
@@ -0,0 +1,40 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -77,6 +77,23 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* For ARM musl currently supports four dynamic linkers:
++ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
++ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
++ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
++ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
++ musl does not support the legacy OABI mode.
++ All the dynamic linkers live in /lib.
++ We default to soft-float, EL. */
++#undef MUSL_DYNAMIC_LINKER
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
++#endif
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+--- a/libitm/config/arm/hwcap.cc
++++ b/libitm/config/arm/hwcap.cc
+@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
+
+ #ifdef __linux__
+ #include <unistd.h>
++#ifdef __GLIBC__
+ #include <sys/fcntl.h>
++#else
++#include <fcntl.h>
++#endif
+ #include <elf.h>
+
+ static void __attribute__((constructor))
diff --git a/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch b/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch
new file mode 100644
index 0000000..42a2648
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch
@@ -0,0 +1,13 @@
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -18,3 +18,10 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++
++#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
++#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
++#endif
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
diff --git a/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch b/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch
new file mode 100644
index 0000000..61e94be
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch
@@ -0,0 +1,100 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2122,6 +2122,10 @@ powerpc*-*-linux*)
+ powerpc*-*-linux*paired*)
+ tm_file="${tm_file} rs6000/750cl.h" ;;
+ esac
++ case ${target} in
++ *-linux*-musl*)
++ enable_secureplt=yes ;;
++ esac
+ if test x${enable_secureplt} = xyes; then
+ tm_file="rs6000/secureplt.h ${tm_file}"
+ fi
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -354,17 +354,21 @@ extern int dot_symbols;
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
+ #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
+ #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER32 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ #undef DEFAULT_ASM_ENDIAN
+ #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
+--- a/gcc/config/rs6000/secureplt.h
++++ b/gcc/config/rs6000/secureplt.h
+@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -550,6 +550,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+ #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
+ #define CC1_SECURE_PLT_DEFAULT_SPEC ""
+ #endif
++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
++#define LINK_SECURE_PLT_DEFAULT_SPEC ""
++#endif
+
+ /* Pass -G xxx to the compiler and set correct endian mode. */
+ #define CC1_SPEC "%{G*} %(cc1_cpu)" \
+@@ -600,7 +603,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ /* Override the default target of the linker. */
+ #define LINK_TARGET_SPEC \
+- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
++ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
++ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
+
+ /* Any specific OS flags. */
+ #define LINK_OS_SPEC "\
+@@ -778,15 +782,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+
+ #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+@@ -912,6 +919,7 @@ ncrtn.o%s"
+ { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
+ { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
+ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
+ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
+ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
diff --git a/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch b/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch
new file mode 100644
index 0000000..9a50c22
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch
@@ -0,0 +1,17 @@
+--- a/gcc/config/sh/linux.h
++++ b/gcc/config/sh/linux.h
+@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3.
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
++#if TARGET_BIG_ENDIAN_DEFAULT /* BE */
++#define MUSL_DYNAMIC_LINKER_E "eb"
++#else
++#define MUSL_DYNAMIC_LINKER_E
++#endif
++
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
+
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
diff --git a/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch b/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch
new file mode 100644
index 0000000..9a25113
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch
@@ -0,0 +1,48 @@
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI
+ #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"
++
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
+--- a/libitm/config/linux/x86/tls.h
++++ b/libitm/config/linux/x86/tls.h
+@@ -25,16 +25,19 @@
+ #ifndef LIBITM_X86_TLS_H
+ #define LIBITM_X86_TLS_H 1
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ /* Use slots in the TCB head rather than __thread lookups.
+ GLIBC has reserved words 10 through 13 for TM. */
+ #define HAVE_ARCH_GTM_THREAD 1
+ #define HAVE_ARCH_GTM_THREAD_DISP 1
+ #endif
++#endif
+
+ #include "config/generic/tls.h"
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ namespace GTM HIDDEN {
+
+ #ifdef __x86_64__
+@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
+
+ } // namespace GTM
+ #endif /* >= GLIBC 2.10 */
++#endif
+
+ #endif // LIBITM_X86_TLS_H
diff --git a/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch b/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch
new file mode 100644
index 0000000..9d75dc9
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch
@@ -0,0 +1,14 @@
+--- a/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc/config/aarch64/aarch64-linux.h
+@@ -21,7 +21,11 @@
+ #ifndef GCC_AARCH64_LINUX_H
+ #define GCC_AARCH64_LINUX_H
+
++/* The AArch64 port currently supports two dynamic linkers:
++ - ld-linux-aarch64.so.1 - GLIBC dynamic linker
++ - ld-musl-aarch64.so.1 - musl libc dynamic linker */
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64.so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
+
+ #define CPP_SPEC "%{pthread:-D_REENTRANT}"
+
diff --git a/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch b/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch
new file mode 100644
index 0000000..e6fa47f
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch
@@ -0,0 +1,12 @@
+--- a/fixincludes/mkfixinc.sh
++++ b/fixincludes/mkfixinc.sh
+@@ -19,7 +19,8 @@ case $machine in
+ powerpc-*-eabi* | \
+ powerpc-*-rtems* | \
+ powerpcle-*-eabisim* | \
+- powerpcle-*-eabi* )
++ powerpcle-*-eabi* | \
++ *-musl* )
+ # IF there is no include fixing,
+ # THEN create a no-op fixer and exit
+ (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
diff --git a/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch b/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch
new file mode 100644
index 0000000..84c781e
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch
@@ -0,0 +1,11 @@
+--- a/libgomp/config/posix/time.c
++++ b/libgomp/config/posix/time.c
+@@ -28,6 +28,8 @@
+ The following implementation uses the most simple POSIX routines.
+ If present, POSIX 4 clocks should be used instead. */
+
++#define _POSIX_C_SOURCE 199309L /* for clocks */
++
+ #include "libgomp.h"
+ #include <unistd.h>
+ #if TIME_WITH_SYS_TIME
diff --git a/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch b/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch
new file mode 100644
index 0000000..6643935
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch
@@ -0,0 +1,26 @@
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -264,6 +264,13 @@ case "${host_os}" in
+ os_include_dir="os/bsd/freebsd"
+ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
++ # check for musl by target
++ case "${host_os}" in
++ *-musl*)
++ os_include_dir="os/generic"
++ ;;
++ *)
++
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+ elif [ "$bionic" = "yes" ]; then
+@@ -272,6 +279,9 @@ case "${host_os}" in
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
diff --git a/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch
new file mode 100644
index 0000000..5608469
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/220-musl_mips_softfloat.patch b/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch
new file mode 100644
index 0000000..b86adf5
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch
@@ -0,0 +1,8 @@
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -24,4 +24,4 @@ along with GCC; see the file COPYING3.
+ #else
+ #define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
+ #endif
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
diff --git a/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch b/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch
new file mode 100644
index 0000000..7447dbd
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch
@@ -0,0 +1,22 @@
+Index: gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h
+===================================================================
+--- gcc-linaro-4.8-2014.04.orig/gcc/config/mips/linux64.h 2014-10-23 15:52:48.999134219 -0700
++++ gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h 2014-10-23 15:59:19.815116979 -0700
+@@ -27,6 +27,16 @@
+ #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
++
++#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
++#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
++#endif
++
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
diff --git a/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch b/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch
new file mode 100644
index 0000000..2217693
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch
@@ -0,0 +1,13 @@
+--- gcc-4.8.1/gcc/gcc.c.orig 2013-09-24 06:27:32.133894539 +0000
++++ gcc-4.8.1/gcc/gcc.c 2013-09-24 06:29:35.790562854 +0000
+@@ -656,7 +656,9 @@
+ #endif
+
+ #ifndef LINK_SSP_SPEC
+-#ifdef TARGET_LIBC_PROVIDES_SSP
++#if DEFAULT_LIBC == LIBC_MUSL
++#define LINK_SSP_SPEC "-lssp_nonshared"
++#elif defined(TARGET_LIBC_PROVIDES_SSP)
+ #define LINK_SSP_SPEC "%{fstack-protector:}"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}"
diff --git a/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..efa9789
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -277,7 +277,7 @@ extern void (*arm_lang_output_object_att
+ /* Thumb-1 only. */
+ #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
+
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN \
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN \
+ && !TARGET_THUMB1)
+
+ #define TARGET_CRC32 (arm_arch_crc)
diff --git a/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..33cf8ad
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,25 @@
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,10 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _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.
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -55,8 +55,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
diff --git a/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch
new file mode 100644
index 0000000..7a0ac73
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..37f8f2a
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- 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/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..2283b83
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -94,10 +94,15 @@
+ #define MUSL_DYNAMIC_LINKER \
+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC BE8_LINK_SPEC \
++#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..6934bc9
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/851-libgcc_no_compat.patch b/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch
new file mode 100644
index 0000000..80c3476
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/860-use_eh_frame.patch b/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch
new file mode 100644
index 0000000..1ac83fe
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..4b7fcbd
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/880-no_java_section.patch b/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch
new file mode 100644
index 0000000..def6c9f
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/900-bad-mips16-crt.patch b/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch
new file mode 100644
index 0000000..dd6e9dc
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch
@@ -0,0 +1,9 @@
+--- a/libgcc/config/mips/t-mips16
++++ b/libgcc/config/mips/t-mips16
+@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch
new file mode 100644
index 0000000..5387f8e
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..09768f5
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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/4.8-linaro/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch
new file mode 100644
index 0000000..e72ed3a
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch
@@ -0,0 +1,111 @@
+From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001
+From: Andrew McDonnell <bugs@andrewmcdonnell.net>
+Date: Fri, 3 Oct 2014 19:09:00 +0930
+Subject: Add .note.GNU-stack section
+
+See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html
+Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html
+
+Re: [Patch, MIPS] Add .note.GNU-stack section
+
+ From: Steve Ellcey <sellcey at mips dot com>
+
+On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote:
+>
+>
+> On Wed, Sep 10, 2014 at 9:27 AM, <pinskia@gmail.com> wrote:
+
+> This works except you did not update the assembly files in
+> libgcc or glibc. We (Cavium) have the same patch in our tree
+> for a few released versions.
+
+> Mind just checking yours in then Andrew?
+
+> Thanks!
+> -eric
+
+I talked to Andrew about what files he changed in GCC and created and
+tested this new patch. Andrew also mentioned changing some assembly
+files in glibc but I don't see any use of '.section .note.GNU-stack' in
+any assembly files in glibc (for any platform) so I wasn't planning on
+creating a glibc to add them to mips glibc assembly language files.
+
+OK to check in this patch?
+
+Steve Ellcey
+sellcey@mips.com
+
+
+
+2014-09-26 Steve Ellcey <sellcey@mips.com>
+---
+ gcc/config/mips/mips.c | 3 +++
+ libgcc/config/mips/crti.S | 4 ++++
+ libgcc/config/mips/crtn.S | 3 +++
+ libgcc/config/mips/mips16.S | 4 ++++
+ libgcc/config/mips/vr4120-div.S | 4 ++++
+ 5 files changed, 18 insertions(+)
+
+--- a/gcc/config/mips/mips.c
++++ b/gcc/config/mips/mips.c
+@@ -18223,6 +18223,9 @@ mips_expand_vec_minmax (rtx target, rtx
+ #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
+ #define TARGET_VECTORIZE_VEC_PERM_CONST_OK mips_vectorize_vec_perm_const_ok
+
++#undef TARGET_ASM_FILE_END
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ struct gcc_target targetm = TARGET_INITIALIZER;
+
+ #include "gt-mips.h"
+--- a/libgcc/config/mips/crti.S
++++ b/libgcc/config/mips/crti.S
+@@ -21,6 +21,10 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/crtn.S
++++ b/libgcc/config/mips/crtn.S
+@@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/mips16.S
++++ b/libgcc/config/mips/mips16.S
+@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTI
+ values using the soft-float calling convention, but do the actual
+ operation using the hard floating point instructions. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
+
+ /* This file contains 32-bit assembly code. */
+--- a/libgcc/config/mips/vr4120-div.S
++++ b/libgcc/config/mips/vr4120-div.S
+@@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTI
+ -mfix-vr4120. div and ddiv do not give the correct result when one
+ of the operands is negative. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ .set nomips16
+
+ #define DIV \
diff --git a/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..dbecef2
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/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}
diff --git a/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch b/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch
new file mode 100644
index 0000000..f487dbc
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch
@@ -0,0 +1,117 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58595
+
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/tls/pr58595.c
+@@ -0,0 +1,28 @@
++/* PR target/58595 */
++/* { dg-do run } */
++/* { dg-options "-O2" } */
++/* { dg-additional-options "-fpic" { target fpic } } */
++/* { dg-require-effective-target tls } */
++/* { dg-require-effective-target sync_int_long } */
++
++struct S { unsigned long a, b; };
++__thread struct S s;
++void bar (unsigned long *);
++
++__attribute__((noinline)) void
++foo (void)
++{
++ int i;
++ for (i = 0; i < 10; i++)
++ __sync_fetch_and_add (&s.b, 1L);
++}
++
++int
++main ()
++{
++ s.b = 12;
++ foo ();
++ if (s.b != 22)
++ __builtin_abort ();
++ return 0;
++}
+--- a/gcc/config/arm/arm.c
++++ b/gcc/config/arm/arm.c
+@@ -231,7 +231,6 @@ static tree arm_gimplify_va_arg_expr (tr
+ static void arm_option_override (void);
+ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
+ static bool arm_cannot_copy_insn_p (rtx);
+-static bool arm_tls_symbol_p (rtx x);
+ static int arm_issue_rate (void);
+ static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
+ static bool arm_output_addr_const_extra (FILE *, rtx);
+@@ -6665,6 +6664,32 @@ legitimize_tls_address (rtx x, rtx reg)
+ rtx
+ arm_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
+ {
++ if (arm_tls_referenced_p (x))
++ {
++ rtx addend = NULL;
++
++ if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS)
++ {
++ addend = XEXP (XEXP (x, 0), 1);
++ x = XEXP (XEXP (x, 0), 0);
++ }
++
++ if (GET_CODE (x) != SYMBOL_REF)
++ return x;
++
++ gcc_assert (SYMBOL_REF_TLS_MODEL (x) != 0);
++
++ x = legitimize_tls_address (x, NULL_RTX);
++
++ if (addend)
++ {
++ x = gen_rtx_PLUS (SImode, x, addend);
++ orig_x = x;
++ }
++ else
++ return x;
++ }
++
+ if (!TARGET_ARM)
+ {
+ /* TODO: legitimize_address for Thumb2. */
+@@ -6673,9 +6698,6 @@ arm_legitimize_address (rtx x, rtx orig_
+ return thumb_legitimize_address (x, orig_x, mode);
+ }
+
+- if (arm_tls_symbol_p (x))
+- return legitimize_tls_address (x, NULL_RTX);
+-
+ if (GET_CODE (x) == PLUS)
+ {
+ rtx xop0 = XEXP (x, 0);
+@@ -6787,9 +6809,6 @@ arm_legitimize_address (rtx x, rtx orig_
+ rtx
+ thumb_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
+ {
+- if (arm_tls_symbol_p (x))
+- return legitimize_tls_address (x, NULL_RTX);
+-
+ if (GET_CODE (x) == PLUS
+ && CONST_INT_P (XEXP (x, 1))
+ && (INTVAL (XEXP (x, 1)) >= 32 * GET_MODE_SIZE (mode)
+@@ -7080,20 +7099,6 @@ thumb_legitimize_reload_address (rtx *x_
+
+ /* Test for various thread-local symbols. */
+
+-/* Return TRUE if X is a thread-local symbol. */
+-
+-static bool
+-arm_tls_symbol_p (rtx x)
+-{
+- if (! TARGET_HAVE_TLS)
+- return false;
+-
+- if (GET_CODE (x) != SYMBOL_REF)
+- return false;
+-
+- return SYMBOL_REF_TLS_MODEL (x) != 0;
+-}
+-
+ /* Helper for arm_tls_referenced_p. */
+
+ static int
diff --git a/toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch b/toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch
new file mode 100644
index 0000000..06373eb
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/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
+@@ -665,35 +665,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/5.2.0/002-case_insensitive.patch b/toolchain/gcc/patches/5.2.0/002-case_insensitive.patch
new file mode 100644
index 0000000..b3d2dbe
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/002-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/5.2.0/010-documentation.patch b/toolchain/gcc/patches/5.2.0/010-documentation.patch
new file mode 100644
index 0000000..07064a9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -2941,18 +2941,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/5.2.0/020-no-plt-backport.patch b/toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch
new file mode 100644
index 0000000..b9702c9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch
@@ -0,0 +1,28 @@
+--- a/gcc/calls.c
++++ b/gcc/calls.c
+@@ -225,6 +225,12 @@ prepare_call_address (tree fndecl_or_typ
+ && 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_or_type
++ && TREE_CODE (fndecl_or_type) == FUNCTION_DECL
++ && !targetm.binds_local_p (fndecl_or_type))
++ {
++ funexp = force_reg (Pmode, funexp);
++ }
+ else if (! sibcallp)
+ {
+ #ifndef NO_FUNCTION_CSE
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -1779,6 +1779,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/5.2.0/030-fix-arm-codegen-PR-65932.patch b/toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch
new file mode 100644
index 0000000..7f0b43c
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch
@@ -0,0 +1,21 @@
+Fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932
+
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -628,16 +628,10 @@ extern int arm_arch_crc;
+ type, but kept valid in the wider mode. The signedness of the
+ extension may differ from that of the type. */
+
+-/* It is far faster to zero extend chars than to sign extend them */
+-
+ #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
+ if (GET_MODE_CLASS (MODE) == MODE_INT \
+ && GET_MODE_SIZE (MODE) < 4) \
+ { \
+- if (MODE == QImode) \
+- UNSIGNEDP = 1; \
+- else if (MODE == HImode) \
+- UNSIGNEDP = 1; \
+ (MODE) = SImode; \
+ }
+
diff --git a/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch b/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/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/5.2.0/200-musl_config.patch b/toolchain/gcc/patches/5.2.0/200-musl_config.patch
new file mode 100644
index 0000000..a2b41b3
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/200-musl_config.patch
@@ -0,0 +1,309 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 08:25:47 +0000 (+0000)
+Subject: [PATCH 2/13] musl libc config
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29c16f8ef226fbf98af373a4b2ceb
+
+[PATCH 2/13] musl libc config
+
+2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config.gcc (LIBC_MUSL): New tm_defines macro.
+ * config/linux.h (OPTION_MUSL): Define.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ * config/linux.opt (mmusl): New option.
+ * doc/invoke.texi (GNU/Linux Options): Document -mmusl.
+ * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
+ (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
+ * configure: Regenerate.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -575,7 +575,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # 32-bit x86 processors supported by --with-arch=. Each processor
+ # MUST be separated by exactly one space.
+@@ -720,6 +720,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTI
+ } while (0)
+
+ /* 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. */
++ uClibc or Bionic or musl is the default C library and whether
++ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
++ the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTI
+ #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+ #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
++/* Should be redefined for each target that supports musl. */
++#define MUSL_DYNAMIC_LINKER "/dev/null"
++#define MUSL_DYNAMIC_LINKER32 "/dev/null"
++#define MUSL_DYNAMIC_LINKER64 "/dev/null"
++#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
+
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
++
+ #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
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_l
+ Use GNU C library
+
+ muclibc
+-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
++Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
++Use musl C library
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -27742,6 +27742,9 @@ if test "${gcc_cv_libc_provides_ssp+set}
+ 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.
+@@ -27774,6 +27777,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"
+@@ -27870,6 +27874,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -5229,6 +5229,9 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
+ 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.
+@@ -5255,6 +5258,7 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
+ # <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],
+@@ -5328,6 +5332,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+ GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -667,7 +667,7 @@ Objective-C and Objective-C++ Dialects}.
+ -mcpu=@var{cpu}}
+
+ @emph{GNU/Linux Options}
+-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
++@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
+ -tno-android-cc -tno-android-ld}
+
+ @emph{H8/300 Options}
+@@ -15324,13 +15324,19 @@ These @samp{-m} options are defined for
+ @item -mglibc
+ @opindex mglibc
+ Use the GNU C library. This is the default except
+-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
++on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
++@samp{*-*-linux-*android*} targets.
+
+ @item -muclibc
+ @opindex muclibc
+ Use uClibc C library. This is the default on
+ @samp{*-*-linux-*uclibc*} targets.
+
++@item -mmusl
++@opindex mmusl
++Use the musl C library. This is the default on
++@samp{*-*-linux-*musl*} targets.
++
+ @item -mbionic
+ @opindex mbionic
+ Use Bionic C library. This is the default on
diff --git a/toolchain/gcc/patches/5.2.0/201-musl_arm.patch b/toolchain/gcc/patches/5.2.0/201-musl_arm.patch
new file mode 100644
index 0000000..27a26af
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/201-musl_arm.patch
@@ -0,0 +1,43 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 27 May 2015 13:17:11 +0000 (+0000)
+Subject: [PATCH 4/13] arm musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=de799bd087ab9a179768fea75bd195a31d3432a4
+
+[PATCH 4/13] arm musl support
+
+On behalf of szabolcs.nagy@arm.com
+
+2015-05-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223749 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -77,6 +77,23 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* For ARM musl currently supports four dynamic linkers:
++ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
++ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
++ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
++ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
++ musl does not support the legacy OABI mode.
++ All the dynamic linkers live in /lib.
++ We default to soft-float, EL. */
++#undef MUSL_DYNAMIC_LINKER
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
++#endif
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
diff --git a/toolchain/gcc/patches/5.2.0/202-musl_mips.patch b/toolchain/gcc/patches/5.2.0/202-musl_mips.patch
new file mode 100644
index 0000000..816dd8d
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/202-musl_mips.patch
@@ -0,0 +1,35 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 15:16:50 +0000 (+0000)
+Subject: [PATCH 6/13] mips musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2550b6a866c887472b587bef87d433c51cf1ebc8
+
+[PATCH 6/13] mips musl support
+
+2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
+ (GNU_USER_DYNAMIC_LINKERN32): Update.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222915 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3.
+ #define UCLIBC_DYNAMIC_LINKERN32 \
+ "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
+
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips%{EL:el}%{msoft-float:-sf}.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips64%{EL:el}%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mipsn32%{EL:el}%{msoft-float:-sf}.so.1"
++
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
diff --git a/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch b/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch
new file mode 100644
index 0000000..2783b27
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch
@@ -0,0 +1,209 @@
+
+gcc/Changelog:
+
+2015-04-24 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config.gcc (secure_plt): Add *-linux*-musl*.
+ * config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64): Define.
+ (GNU_USER_DYNAMIC_LINKER32): Update.
+ (GNU_USER_DYNAMIC_LINKER64): Update.
+ (CHOOSE_DYNAMIC_LINKER): Update.
+
+ * config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
+ * config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
+ (CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update.
+
+ * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define.
+
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -365,17 +365,21 @@ extern int dot_symbols;
+ #endif
+ #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
+ #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER32 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ #undef DEFAULT_ASM_ENDIAN
+ #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
+--- a/gcc/config/rs6000/secureplt.h
++++ b/gcc/config/rs6000/secureplt.h
+@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+ #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
+ #define CC1_SECURE_PLT_DEFAULT_SPEC ""
+ #endif
++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
++#define LINK_SECURE_PLT_DEFAULT_SPEC ""
++#endif
+
+ /* Pass -G xxx to the compiler. */
+ #undef CC1_SPEC
+@@ -586,7 +589,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ /* Override the default target of the linker. */
+ #define LINK_TARGET_SPEC \
+- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
++ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
++ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
+
+ /* Any specific OS flags. */
+ #define LINK_OS_SPEC "\
+@@ -762,17 +766,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #define LINK_START_LINUX_SPEC ""
+
++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
++
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+
+ #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+@@ -895,6 +904,7 @@ ncrtn.o%s"
+ { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
+ { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
+ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
+ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
+ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
+@@ -949,3 +959,72 @@ ncrtn.o%s"
+ /* This target uses the sysv4.opt file. */
+ #define TARGET_USES_SYSV4_OPT 1
+
++/* Include order changes for musl, same as in generic linux.h. */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+--- a/gcc/config/rs6000/sysv4le.h
++++ b/gcc/config/rs6000/sysv4le.h
+@@ -35,3 +35,5 @@
+ /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default. */
+ #define LINUX64_DEFAULT_ABI_ELFv2
+
++#undef MUSL_DYNAMIC_LINKER_E
++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le")
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2410,6 +2410,10 @@ powerpc*-*-linux*)
+ powerpc*-*-linux*paired*)
+ tm_file="${tm_file} rs6000/750cl.h" ;;
+ esac
++ case ${target} in
++ *-linux*-musl*)
++ enable_secureplt=yes ;;
++ esac
+ if test x${enable_secureplt} = xyes; then
+ tm_file="rs6000/secureplt.h ${tm_file}"
+ fi
diff --git a/toolchain/gcc/patches/5.2.0/204-musl_sh.patch b/toolchain/gcc/patches/5.2.0/204-musl_sh.patch
new file mode 100644
index 0000000..8c3753d
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/204-musl_sh.patch
@@ -0,0 +1,39 @@
+gcc/Changelog:
+
+2015-04-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ (MUSL_DYNAMIC_LINKER_E, MUSL_DYNAMIC_LINKER_FP): Define.
+
+--- a/gcc/config/sh/linux.h
++++ b/gcc/config/sh/linux.h
+@@ -43,6 +43,28 @@ along with GCC; see the file COPYING3.
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
++#if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
++#define MUSL_DYNAMIC_LINKER_E "%{mb:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{!ml:eb}"
++#endif
++
++#if TARGET_CPU_DEFAULT & ( MASK_HARD_SH2A_DOUBLE | MASK_SH4 )
++/* "-nofpu" if any nofpu option is specified */
++#define MUSL_DYNAMIC_LINKER_FP \
++ "%{m1|m2|m2a-nofpu|m3|m4-nofpu|m4-100-nofpu|m4-200-nofpu|m4-300-nofpu|" \
++ "m4-340|m4-400|m4-500|m4al|m5-32media-nofpu|m5-64media-nofpu|" \
++ "m5-compact-nofpu:-nofpu}"
++#else
++/* "-nofpu" if none of the hard fpu options are specified */
++#define MUSL_DYNAMIC_LINKER_FP \
++ "%{m2a|m4|m4-100|m4-200|m4-300|m4a|m5-32media|m5-64media|m5-compact:;:-nofpu}"
++#endif
++
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP ".so.1"
++
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
diff --git a/toolchain/gcc/patches/5.2.0/205-musl_x86.patch b/toolchain/gcc/patches/5.2.0/205-musl_x86.patch
new file mode 100644
index 0000000..8772328
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/205-musl_x86.patch
@@ -0,0 +1,41 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 15 May 2015 13:20:01 +0000 (+0000)
+Subject: [PATCH 9/13] x86 musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=5551c8d927c17f60837f15f8dfe46f945ba3fa9c
+
+[PATCH 9/13] x86 musl support
+
+On behalf of Szabolcs Nagy.
+
+2015-05-15 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223218 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -21,3 +21,6 @@ along with GCC; see the file COPYING3.
+
+ #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"
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTI
+ #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"
++
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#undef MUSL_DYNAMIC_LINKERX32
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
diff --git a/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch b/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch
new file mode 100644
index 0000000..6925a02
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch
@@ -0,0 +1,31 @@
+From: jgreenhalgh <jgreenhalgh@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 27 May 2015 16:46:39 +0000 (+0000)
+Subject: [PATCH 3/13] aarch64 musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=b3ff21cf0531be91bc3fb8200296a7633090ec78
+
+[PATCH 3/13] aarch64 musl support
+
+gcc/Changelog:
+
+2015-05-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223766 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc/config/aarch64/aarch64-linux.h
+@@ -23,6 +23,9 @@
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++
+ #undef ASAN_CC1_SPEC
+ #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
+
diff --git a/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch b/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch
new file mode 100644
index 0000000..0ff33d3
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch
@@ -0,0 +1,30 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:18:16 +0000 (+0000)
+Subject: fixincludes update for musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2dc727de2e87c2756a514cbb43cea23c99deaa3d
+
+fixincludes update for musl support
+
+On behalf of Szabolcs.Nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * mkfixinc.sh: Add *-musl* with no fixes.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222327 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/fixincludes/mkfixinc.sh
++++ b/fixincludes/mkfixinc.sh
+@@ -19,7 +19,8 @@ case $machine in
+ powerpc-*-eabi* | \
+ powerpc-*-rtems* | \
+ powerpcle-*-eabisim* | \
+- powerpcle-*-eabi* )
++ powerpcle-*-eabi* | \
++ *-musl* )
+ # IF there is no include fixing,
+ # THEN create a no-op fixer and exit
+ (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
diff --git a/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch b/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch
new file mode 100644
index 0000000..861bc76
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch
@@ -0,0 +1,72 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:24:11 +0000 (+0000)
+Subject: libstdc++, libgfortran gthr workaround for musl
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=1e5f711c11cb80ce609db9e9c1d8b2da0f7b5b61
+
+libstdc++, libgfortran gthr workaround for musl
+
+On behalf of szabolcs.nagy@arm.com
+
+[libstdc++-v3/]
+2015-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
+ * configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
+
+[libgfortran/]
+2015-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
+ * configure: Regenerate.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222329 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libgfortran/acinclude.m4
++++ b/libgfortran/acinclude.m4
+@@ -100,7 +100,7 @@ void foo (void);
+ [Define to 1 if the target supports #pragma weak])
+ fi
+ case "$host" in
+- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
+ AC_DEFINE(GTHREAD_USE_WEAK, 0,
+ [Define to 0 if the target shouldn't use #pragma weak])
+ ;;
+--- a/libgfortran/configure
++++ b/libgfortran/configure
+@@ -26447,7 +26447,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>con
+
+ fi
+ case "$host" in
+- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
+
+ $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
+
+--- a/libstdc++-v3/config/os/generic/os_defines.h
++++ b/libstdc++-v3/config/os/generic/os_defines.h
+@@ -33,4 +33,9 @@
+ // System-specific #define, typedefs, corrections, etc, go here. This
+ // file will come before all others.
+
++// Disable the weak reference logic in gthr.h for os/generic because it
++// is broken on every platform unless there is implementation specific
++// workaround in gthr-posix.h and at link-time for static linking.
++#define _GLIBCXX_GTHREAD_USE_WEAK 0
++
+ #endif
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -273,6 +273,9 @@ case "${host_os}" in
+ freebsd*)
+ os_include_dir="os/bsd/freebsd"
+ ;;
++ linux-musl*)
++ os_include_dir="os/generic"
++ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
diff --git a/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch b/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch
new file mode 100644
index 0000000..30f42e9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch
@@ -0,0 +1,13 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -727,7 +727,9 @@ proper position among the other output f
+ #endif
+
+ #ifndef LINK_SSP_SPEC
+-#ifdef TARGET_LIBC_PROVIDES_SSP
++#if DEFAULT_LIBC == LIBC_MUSL
++#define LINK_SSP_SPEC "-lssp_nonshared"
++#elif defined(TARGET_LIBC_PROVIDES_SSP)
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit:}"
+ #else
diff --git a/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch b/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch
new file mode 100644
index 0000000..533cb68
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch
@@ -0,0 +1,61 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:11:25 +0000 (+0000)
+Subject: libitm fixes for musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=e53a4d49c3d03ab8eaddb073cf972c1c46d75338
+
+libitm fixes for musl support
+
+On behalf of Szabolcs.Nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
+ * config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222325 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libitm/config/arm/hwcap.cc
++++ b/libitm/config/arm/hwcap.cc
+@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0
+
+ #ifdef __linux__
+ #include <unistd.h>
+-#include <sys/fcntl.h>
++#include <fcntl.h>
+ #include <elf.h>
+
+ static void __attribute__((constructor))
+--- a/libitm/config/linux/x86/tls.h
++++ b/libitm/config/linux/x86/tls.h
+@@ -25,16 +25,19 @@
+ #ifndef LIBITM_X86_TLS_H
+ #define LIBITM_X86_TLS_H 1
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ /* Use slots in the TCB head rather than __thread lookups.
+ GLIBC has reserved words 10 through 13 for TM. */
+ #define HAVE_ARCH_GTM_THREAD 1
+ #define HAVE_ARCH_GTM_THREAD_DISP 1
+ #endif
++#endif
+
+ #include "config/generic/tls.h"
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ namespace GTM HIDDEN {
+
+ #ifdef __x86_64__
+@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
+
+ } // namespace GTM
+ #endif /* >= GLIBC 2.10 */
++#endif
+
+ #endif // LIBITM_X86_TLS_H
diff --git a/toolchain/gcc/patches/5.2.0/250-add-musl.patch b/toolchain/gcc/patches/5.2.0/250-add-musl.patch
new file mode 100644
index 0000000..8cbedde
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/250-add-musl.patch
@@ -0,0 +1,120 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 08:30:40 +0000 (+0000)
+Subject: [PATCH 0/13] Add musl support to GCC
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=f2d678afa5b8385d763b93772d73d6bf80a9739e
+
+[PATCH 0/13] Add musl support to GCC
+
+2015-05-08 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/glibc-stdint.h (OPTION_MUSL): Define.
+ (INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
+ Change the definition based on OPTION_MUSL for 64 bit targets.
+ * config/linux.h (OPTION_MUSL): Redefine.
+ * config/alpha/linux.h (OPTION_MUSL): Redefine.
+ * config/rs6000/linux.h (OPTION_MUSL): Redefine.
+ * config/rs6000/linux64.h (OPTION_MUSL): Redefine.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222905 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/alpha/linux.h
++++ b/gcc/config/alpha/linux.h
+@@ -61,10 +61,14 @@ along with GCC; see the file COPYING3.
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
+--- a/gcc/config/glibc-stdint.h
++++ b/gcc/config/glibc-stdint.h
+@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* Systems using musl libc should use this header and make sure
++ OPTION_MUSL is defined correctly before using the TYPE macros. */
++#ifndef OPTION_MUSL
++#define OPTION_MUSL 0
++#endif
++
+ #define SIG_ATOMIC_TYPE "int"
+
+ #define INT8_TYPE "signed char"
+@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+ #define INT_FAST8_TYPE "signed char"
+-#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
+-#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
++#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
++#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
+ #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
+ #define UINT_FAST8_TYPE "unsigned char"
+-#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
+-#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
++#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
++#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
+ #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")
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,11 +32,13 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
+ #define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
+ #define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -30,10 +30,14 @@
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -299,10 +299,14 @@ extern int dot_symbols;
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
diff --git a/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch b/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch
new file mode 100644
index 0000000..a3b83e2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch
@@ -0,0 +1,34 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:20:01 +0000 (+0000)
+Subject: unwind fix for musl
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a2e31d0681d8a47389b8a3552622fbd9827bcef4
+
+unwind fix for musl
+
+On behalf of szabolcs.nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
+ Linux if target provides dl_iterate_phdr.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222328 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libgcc/unwind-dw2-fde-dip.c
++++ b/libgcc/unwind-dw2-fde-dip.c
+@@ -59,6 +59,12 @@
+
+ #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+ && defined(TARGET_DL_ITERATE_PHDR) \
++ && defined(__linux__)
++# define USE_PT_GNU_EH_FRAME
++#endif
++
++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
++ && defined(TARGET_DL_ITERATE_PHDR) \
+ && (defined(__DragonFly__) || defined(__FreeBSD__))
+ # define ElfW __ElfN
+ # define USE_PT_GNU_EH_FRAME
diff --git a/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch b/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch
new file mode 100644
index 0000000..798936c
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch
@@ -0,0 +1,24 @@
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -369,8 +369,8 @@ extern int dot_symbols;
+ #endif
+ #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
+ #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
+-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
+-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+ #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -770,7 +770,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+ #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_MUSL
diff --git a/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..0edeb13
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -285,7 +285,7 @@ extern void (*arm_lang_output_object_att
+ /* Thumb-1 only. */
+ #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
+
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN \
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN \
+ && !TARGET_THUMB1)
+
+ #define TARGET_CRC32 (arm_arch_crc)
diff --git a/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..1d06f5b
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,25 @@
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,10 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _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.
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,8 +60,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
diff --git a/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch b/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch
new file mode 100644
index 0000000..42bf0c8
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -887,11 +887,12 @@ $(libgcov-driver-objects): %$(objext): $
+
+ # 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)"; \
+@@ -913,7 +914,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
+@@ -1108,6 +1109,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/5.2.0/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..37f8f2a
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- 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/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..cb1fb98
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -94,10 +94,15 @@
+ #define MUSL_DYNAMIC_LINKER \
+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC EABI_LINK_SPEC \
++#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..5818cf4
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/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
+@@ -53,6 +53,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 or musl is the default C library and whether
+ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
+--- 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
+@@ -60,6 +60,9 @@
+ #undef CPP_OS_DEFAULT_SPEC
+ #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
+
++#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/5.2.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch
new file mode 100644
index 0000000..80c3476
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/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/5.2.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..b38b9d5
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -21453,7 +21453,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/5.2.0/880-no_java_section.patch b/toolchain/gcc/patches/5.2.0/880-no_java_section.patch
new file mode 100644
index 0000000..def6c9f
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/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/5.2.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch
new file mode 100644
index 0000000..dd6e9dc
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch
@@ -0,0 +1,9 @@
+--- a/libgcc/config/mips/t-mips16
++++ b/libgcc/config/mips/t-mips16
+@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch b/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch
new file mode 100644
index 0000000..68661d2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch
@@ -0,0 +1,222 @@
+
+ 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.
+
+ 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
+@@ -122,6 +122,9 @@ static int class_dump_flags;
+ /* 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);
+@@ -449,6 +452,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;
+@@ -1034,6 +1043,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
+@@ -431,6 +431,10 @@ Wfloat-conversion
+ C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
+ Warn for implicit type conversions that cause loss of floating point precision
+
++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
+@@ -1161,6 +1165,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
+@@ -561,6 +561,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
+@@ -1360,6 +1364,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
+@@ -1699,6 +1699,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
+@@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
+ -Wdisabled-optimization @gol
+ -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @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-signedness -Wformat-y2k @gol
+@@ -5371,6 +5371,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
+@@ -7844,7 +7860,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
+@@ -629,6 +629,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/5.2.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..3d708f2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,15 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -8807,8 +8807,10 @@ getenv_spec_function (int argc, const ch
+
+ value = getenv (argv[0]);
+ if (!value)
+- fatal_error (input_location,
+- "environment variable %qs not defined", argv[0]);
++ {
++ warning (input_location, "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/5.2.0/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch
new file mode 100644
index 0000000..4bb126e
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch
@@ -0,0 +1,111 @@
+From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001
+From: Andrew McDonnell <bugs@andrewmcdonnell.net>
+Date: Fri, 3 Oct 2014 19:09:00 +0930
+Subject: Add .note.GNU-stack section
+
+See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html
+Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html
+
+Re: [Patch, MIPS] Add .note.GNU-stack section
+
+ From: Steve Ellcey <sellcey at mips dot com>
+
+On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote:
+>
+>
+> On Wed, Sep 10, 2014 at 9:27 AM, <pinskia@gmail.com> wrote:
+
+> This works except you did not update the assembly files in
+> libgcc or glibc. We (Cavium) have the same patch in our tree
+> for a few released versions.
+
+> Mind just checking yours in then Andrew?
+
+> Thanks!
+> -eric
+
+I talked to Andrew about what files he changed in GCC and created and
+tested this new patch. Andrew also mentioned changing some assembly
+files in glibc but I don't see any use of '.section .note.GNU-stack' in
+any assembly files in glibc (for any platform) so I wasn't planning on
+creating a glibc to add them to mips glibc assembly language files.
+
+OK to check in this patch?
+
+Steve Ellcey
+sellcey@mips.com
+
+
+
+2014-09-26 Steve Ellcey <sellcey@mips.com>
+---
+ gcc/config/mips/mips.c | 3 +++
+ libgcc/config/mips/crti.S | 4 ++++
+ libgcc/config/mips/crtn.S | 3 +++
+ libgcc/config/mips/mips16.S | 4 ++++
+ libgcc/config/mips/vr4120-div.S | 4 ++++
+ 5 files changed, 18 insertions(+)
+
+--- a/gcc/config/mips/mips.c
++++ b/gcc/config/mips/mips.c
+@@ -19621,6 +19621,9 @@ mips_lra_p (void)
+ #undef TARGET_LRA_P
+ #define TARGET_LRA_P mips_lra_p
+
++#undef TARGET_ASM_FILE_END
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ struct gcc_target targetm = TARGET_INITIALIZER;
+
+ #include "gt-mips.h"
+--- a/libgcc/config/mips/crti.S
++++ b/libgcc/config/mips/crti.S
+@@ -21,6 +21,10 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/crtn.S
++++ b/libgcc/config/mips/crtn.S
+@@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/mips16.S
++++ b/libgcc/config/mips/mips16.S
+@@ -48,6 +48,10 @@ see the files COPYING3 and COPYING.RUNTI
+ values using the soft-float calling convention, but do the actual
+ operation using the hard floating point instructions. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
+
+ /* This file contains 32-bit assembly code. */
+--- a/libgcc/config/mips/vr4120-div.S
++++ b/libgcc/config/mips/vr4120-div.S
+@@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTI
+ -mfix-vr4120. div and ddiv do not give the correct result when one
+ of the operands is negative. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ .set nomips16
+
+ #define DIV \
diff --git a/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..bf2ab07
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1382,7 +1382,7 @@ stamp-bits: ${bits_headers}
+ @$(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/gdb/Makefile b/toolchain/gdb/Makefile
new file mode 100644
index 0000000..fa5179a
--- /dev/null
+++ b/toolchain/gdb/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gdb
+PKG_VERSION:=7.8
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/gdb
+PKG_MD5SUM:=bd958fe9019d7c7896f29f6724a764ed
+
+HOST_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_CONFIGURE_VARS += \
+ gdb_cv_func_sigsetjmp=yes
+
+HOST_CONFIGURE_ARGS = \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-werror \
+ --without-uiout \
+ --disable-tui --disable-gdbtk --without-x \
+ --without-included-gettext \
+ --enable-threads \
+ --with-expat
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/gdb/gdb $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb
+ ln -fs $(TARGET_CROSS)gdb $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gdb
+ strip $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb \
+ $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gdb
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gdb/patches/100-no_extern_inline.patch b/toolchain/gdb/patches/100-no_extern_inline.patch
new file mode 100644
index 0000000..bbae1d7
--- /dev/null
+++ b/toolchain/gdb/patches/100-no_extern_inline.patch
@@ -0,0 +1,32 @@
+--- a/sim/common/sim-arange.c
++++ b/sim/common/sim-arange.c
+@@ -280,11 +280,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, a
+ build_search_tree (ar);
+ }
+
+-#endif /* DEFINE_NON_INLINE_P */
+-
+-#if DEFINE_INLINE_P
+-
+-SIM_ARANGE_INLINE int
++int
+ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
+ {
+ ADDR_RANGE_TREE *t = ar->range_tree;
+@@ -301,4 +297,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, ad
+ return 0;
+ }
+
+-#endif /* DEFINE_INLINE_P */
++#endif /* DEFINE_NON_INLINE_P */
+--- a/sim/common/sim-arange.h
++++ b/sim/common/sim-arange.h
+@@ -62,7 +62,7 @@ extern void sim_addr_range_delete (ADDR_
+
+ /* Return non-zero if ADDR is in range AR, traversing the entire tree.
+ If no range is specified, that is defined to mean "everything". */
+-extern INLINE int
++extern int
+ sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/);
+ #define ADDR_RANGE_HIT_P(ar, addr) \
+ ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr)))
diff --git a/toolchain/gdb/patches/110-no_testsuite.patch b/toolchain/gdb/patches/110-no_testsuite.patch
new file mode 100644
index 0000000..5c5d15c
--- /dev/null
+++ b/toolchain/gdb/patches/110-no_testsuite.patch
@@ -0,0 +1,21 @@
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -855,8 +855,7 @@ MAKEINFOFLAGS
+ YACC
+ YFLAGS
+ XMKMF'
+-ac_subdirs_all='testsuite
+-gdbtk
++ac_subdirs_all='gdbtk
+ multi-ice
+ gdbserver'
+
+@@ -5168,7 +5167,7 @@ $as_echo "$with_auto_load_safe_path" >&6
+
+
+
+-subdirs="$subdirs testsuite"
++subdirs="$subdirs"
+
+
+ # Check whether to support alternative target configurations
diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000..ce34c95
--- /dev/null
+++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch
@@ -0,0 +1,11 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -2183,7 +2183,7 @@ $as_echo "$as_me: error: \`$ac_var' was
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
diff --git a/toolchain/glibc/Config.in b/toolchain/glibc/Config.in
new file mode 100644
index 0000000..66ff2f4
--- /dev/null
+++ b/toolchain/glibc/Config.in
@@ -0,0 +1,21 @@
+choice
+ prompt "(e)glibc version"
+ depends on TOOLCHAINOPTS && USE_GLIBC
+ default EGLIBC_USE_VERSION_2_19
+ help
+ Select the version of glibc you wish to use.
+
+ config EGLIBC_USE_VERSION_2_19
+ bool "eglibc 2.19"
+ select EGLIBC_VERSION_2_19
+
+ config GLIBC_USE_VERSION_2_21
+ bool "glibc 2.21"
+ select GLIBC_VERSION_2_21
+
+endchoice
+
+menu "eglibc configuration"
+ depends on TOOLCHAINOPTS && USE_GLIBC && EGLIBC_USE_VERSION_2_19
+ source toolchain/glibc/config/Config.in
+endmenu
diff --git a/toolchain/glibc/Config.version b/toolchain/glibc/Config.version
new file mode 100644
index 0000000..2ac01d7
--- /dev/null
+++ b/toolchain/glibc/Config.version
@@ -0,0 +1,26 @@
+if USE_GLIBC
+
+config GLIBC_VERSION
+ string
+ default "2.19" if EGLIBC_VERSION_2_19
+ default "2.21" if GLIBC_VERSION_2_21
+
+config EGLIBC_VERSION_2_19
+ default y if !TOOLCHAINOPTS
+ bool
+
+config GLIBC_VERSION_2_21
+ bool
+
+config GLIBC_REVISION
+ string
+ default "25243" if EGLIBC_VERSION_2_19
+ default "4e42b5b8f8" if GLIBC_VERSION_2_21
+ default ""
+
+endif
+
+menu "eglibc configuration"
+ depends on !TOOLCHAINOPTS && USE_GLIBC
+ source toolchain/glibc/config/Config.in
+endmenu
diff --git a/toolchain/glibc/Makefile b/toolchain/glibc/Makefile
new file mode 100644
index 0000000..f880db8
--- /dev/null
+++ b/toolchain/glibc/Makefile
@@ -0,0 +1,31 @@
+PATH_PREFIX := .
+VARIANT:=final
+HOST_BUILD_PARALLEL:=0
+
+include ./common.mk
+
+define Host/Compile
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ PARALLELMFLAGS="$(HOST_JOBS)" \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ install_root="$(TOOLCHAIN_DIR)" \
+ install
+ ( cd $(TOOLCHAIN_DIR) ; \
+ for d in lib usr/lib ; do \
+ for f in libc.so libpthread.so libgcc_s.so ; do \
+ if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
+ $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
+ fi \
+ done \
+ done \
+ )
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk
new file mode 100644
index 0000000..7487ca2
--- /dev/null
+++ b/toolchain/glibc/common.mk
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=glibc
+PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
+PKG_REVISION:=$(call qstrip,$(CONFIG_GLIBC_REVISION))
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://sourceware.org/git/glibc.git
+PKG_SOURCE_VERSION:=$(PKG_REVISION)
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION)
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
+
+GLIBC_PATH:=
+ifneq ($(CONFIG_EGLIBC_VERSION_2_19),)
+ GLIBC_PATH:=libc/
+ PKG_SOURCE_PROTO:=svn
+ PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
+ PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_19
+endif
+
+PATCH_DIR:=$(PATH_PREFIX)/patches/$(PKG_VERSION)
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
+CUR_BUILD_DIR:=$(HOST_BUILD_DIR)-$(VARIANT)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
+HOST_STAMP_CONFIGURED:=$(CUR_BUILD_DIR)/.configured
+HOST_STAMP_BUILT:=$(CUR_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_$(VARIANT)_installed
+
+ifeq ($(ARCH),mips64)
+ ifdef CONFIG_MIPS64_ABI_N64
+ TARGET_CFLAGS += -mabi=64
+ endif
+ ifdef CONFIG_MIPS64_ABI_N32
+ TARGET_CFLAGS += -mabi=n32
+ endif
+ ifdef CONFIG_MIPS64_ABI_O32
+ TARGET_CFLAGS += -mabi=32
+ endif
+endif
+
+GLIBC_CONFIGURE:= \
+ BUILD_CC="$(HOSTCC)" \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ libc_cv_slibdir="/lib" \
+ use_ldconfig=no \
+ $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \
+ --prefix= \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --with-headers=$(TOOLCHAIN_DIR)/include \
+ --disable-profile \
+ --disable-werror \
+ --without-gd \
+ --without-cvs \
+ --enable-add-ons \
+ --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp
+
+export libc_cv_ssp=no
+export ac_cv_header_cpuid_h=yes
+export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ifneq ($(CONFIG_GLIBC_VERSION_2_21),)
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
+else
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
+endif
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Configure
+ [ -f $(HOST_BUILD_DIR)/.autoconf ] || { \
+ cd $(HOST_BUILD_DIR)/$(GLIBC_PATH); \
+ autoconf --force && \
+ touch $(HOST_BUILD_DIR)/.autoconf; \
+ }
+ mkdir -p $(CUR_BUILD_DIR)
+ grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(CUR_BUILD_DIR)/option-groups.config
+ ( cd $(CUR_BUILD_DIR); rm -f config.cache; \
+ $(GLIBC_CONFIGURE) \
+ );
+endef
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ifeq ($(CONFIG_GLIBC_VERSION_2_21),)
+ $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
+endif
+endef
+
+define Host/Clean
+ rm -rf $(CUR_BUILD_DIR)* \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
diff --git a/toolchain/glibc/config/Config.in b/toolchain/glibc/config/Config.in
new file mode 100644
index 0000000..6f02223
--- /dev/null
+++ b/toolchain/glibc/config/Config.in
@@ -0,0 +1,903 @@
+config EGLIBC_OPTION_EGLIBC_ADVANCED_INET6
+ bool "IPv6 Advanced Sockets API support (RFC3542)"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes the functions specified by RFC 3542,
+ "Advanced Sockets Application Program Interface (API) for
+ IPv6".
+
+ This option group includes the following functions:
+
+ inet6_opt_append
+ inet6_opt_find
+ inet6_opt_finish
+ inet6_opt_get_val
+ inet6_opt_init
+ inet6_option_alloc
+ inet6_option_append
+ inet6_option_find
+ inet6_option_init
+ inet6_option_next
+ inet6_option_space
+ inet6_opt_next
+ inet6_opt_set_val
+ inet6_rth_add
+ inet6_rth_getaddr
+ inet6_rth_init
+ inet6_rth_reverse
+ inet6_rth_segments
+ inet6_rth_space
+
+
+config EGLIBC_OPTION_EGLIBC_BACKTRACE
+ bool "Functions for producing backtraces"
+ default y
+ help
+ This option group includes functions for producing a list of
+ the function calls that are currently active in a thread, from
+ within the thread itself. These functions are often used
+ within signal handlers, to produce diagnostic output.
+
+ This option group includes the following functions:
+
+ backtrace
+ backtrace_symbols
+ backtrace_symbols_fd
+
+
+config EGLIBC_OPTION_EGLIBC_BIG_MACROS
+ bool "Use extensive inline code"
+ default y
+ help
+ This option group specifies whether certain pieces of code
+ should be inlined to achieve maximum speed. If this option
+ group is not selected, function calls will be used instead,
+ hence reducing the library footprint.
+
+
+config EGLIBC_OPTION_EGLIBC_BSD
+ bool "BSD-specific functions, and their compatibility stubs"
+ default y
+ help
+ This option group includes functions specific to BSD kernels.
+ A number of these functions have stub versions that are also
+ included in libraries built for non-BSD systems for
+ compatibility.
+
+ This option group includes the following functions:
+
+ chflags
+ fchflags
+ lchmod
+ revoke
+ setlogin
+
+
+config EGLIBC_OPTION_EGLIBC_CXX_TESTS
+ bool "Tests that link against the standard C++ library."
+ default y
+ select EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+ select EGLIBC_OPTION_EGLIBC_LIBM
+ help
+ This option group does not include any C library functions;
+ instead, it controls which EGLIBC tests an ordinary 'make
+ tests' runs. With this group disabled, tests that would
+ normally link against the standard C++ library are not
+ run.
+
+ The standard C++ library depends on the math library 'libm' and
+ the wide character I/O functions included in EGLIBC. If those
+ option groups are disabled, this test must also be disabled.
+
+
+config EGLIBC_OPTION_EGLIBC_CATGETS
+ bool "Functions for accessing message catalogs"
+ default y
+ select EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ help
+ This option group includes functions for accessing message
+ catalogs: catopen, catclose, and catgets.
+
+ This option group depends on the EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ option group; if you disable that, you must also disable this.
+
+
+config EGLIBC_OPTION_EGLIBC_CHARSETS
+ bool "iconv/gconv character set conversion libraries"
+ default y
+ help
+
+ This option group includes support for character sets other
+ than ASCII (ANSI_X3.4-1968) and Unicode and ISO-10646 in their
+ various encodings. This affects both the character sets
+ supported by the wide and multibyte character functions, and
+ those supported by the 'iconv' functions.
+
+ With this option group disabled, EGLIBC supports only the
+ following character sets:
+
+ ANSI_X3.4 - ASCII
+ ANSI_X3.4-1968
+ ANSI_X3.4-1986
+ ASCII
+ CP367
+ CSASCII
+ IBM367
+ ISO-IR-6
+ ISO646-US
+ ISO_646.IRV:1991
+ OSF00010020
+ US
+ US-ASCII
+
+ 10646-1:1993 - ISO 10646, in big-endian UCS4 form
+ 10646-1:1993/UCS4
+ CSUCS4
+ ISO-10646
+ ISO-10646/UCS4
+ OSF00010104
+ OSF00010105
+ OSF00010106
+ UCS-4
+ UCS-4BE
+ UCS4
+
+ UCS-4LE - ISO 10646, in little-endian UCS4 form
+
+ ISO-10646/UTF-8 - ISO 10646, in UTF-8 form
+ ISO-10646/UTF8
+ ISO-IR-193
+ OSF05010001
+ UTF-8
+ UTF8
+
+ ISO-10646/UCS2 - ISO 10646, in target-endian UCS2 form
+ OSF00010100
+ OSF00010101
+ OSF00010102
+ UCS-2
+ UCS2
+
+ UCS-2BE - ISO 10646, in big-endian UCS2 form
+ UNICODEBIG
+
+ UCS-2LE - ISO 10646, in little-endian UCS2 form
+ UNICODELITTLE
+
+ WCHAR_T - EGLIBC's internal form (target-endian,
+ 32-bit ISO 10646)
+
+
+config EGLIBC_OPTION_EGLIBC_CRYPT
+ bool "Encryption library"
+ default y
+ help
+ This option group includes the `libcrypt' library which
+ provides functions for one-way encryption. Supported
+ encryption algorithms include MD5, SHA-256, SHA-512 and DES.
+
+
+config EGLIBC_OPTION_EGLIBC_CRYPT_UFC
+ bool "Ultra fast `crypt' implementation"
+ default y
+ select EGLIBC_OPTION_EGLIBC_CRYPT
+ help
+ This option group provides ultra fast DES-based implementation of
+ the `crypt' function. When this option group is disabled,
+ (a) the library will not provide the setkey[_r] and encrypt[_r]
+ functions and (b) the crypt[_r] function will return NULL and set the
+ errno to ENOSYS if /salt/ passed does not correspond to either MD5,
+ SHA-256 or SHA-512 algorithm.
+
+
+config EGLIBC_OPTION_EGLIBC_DB_ALIASES
+ bool "Functions for accessing the mail aliases database"
+ default y
+ help
+ This option group includes functions for looking up mail
+ aliases in '/etc/aliases' or using nsswitch. It includes the
+ following functions:
+
+ endaliasent
+ getaliasbyname
+ getaliasbyname_r
+ getaliasent
+ getaliasent_r
+ setaliasent
+
+ When this option group is disabled, the NSS service libraries
+ also lack support for querying their mail alias tables.
+
+
+config EGLIBC_OPTION_EGLIBC_ENVZ
+ bool "Functions for handling envz-style environment vectors."
+ default y
+ help
+ This option group contains functions for creating and operating
+ on envz vectors. An "envz vector" is a vector of strings in a
+ contiguous block of memory, where each element is a name-value
+ pair, and elements are separated from their neighbors by null
+ characters.
+
+ This option group includes the following functions:
+
+ envz_add envz_merge
+ envz_entry envz_remove
+ envz_get envz_strip
+
+
+config EGLIBC_OPTION_EGLIBC_FCVT
+ bool "Functions for converting floating-point numbers to strings"
+ default y
+ help
+ This option group includes functions for converting
+ floating-point numbers to strings.
+
+ This option group includes the following functions:
+
+ ecvt qecvt
+ ecvt_r qecvt_r
+ fcvt qfcvt
+ fcvt_r qfcvt_r
+ gcvt qgcvt
+
+
+config EGLIBC_OPTION_EGLIBC_FMTMSG
+ bool "Functions for formatting messages"
+ default y
+ help
+ This option group includes the following functions:
+
+ addseverity fmtmsg
+
+
+config EGLIBC_OPTION_EGLIBC_FSTAB
+ bool "Access functions for 'fstab'"
+ default y
+ help
+ This option group includes functions for reading the mount
+ point specification table, '/etc/fstab'. These functions are
+ not included in the POSIX standard, which provides the
+ 'getmntent' family of functions instead.
+
+ This option group includes the following functions:
+
+ endfsent getfsspec
+ getfsent setfsent
+ getfsfile
+
+
+config EGLIBC_OPTION_EGLIBC_FTRAVERSE
+ bool "Functions for traversing file hierarchies"
+ default y
+ help
+ This option group includes functions for traversing file
+ UNIX file hierachies.
+
+ This option group includes the following functions:
+
+ fts_open ftw
+ fts_read nftw
+ fts_children ftw64
+ fts_set nftw64
+ fts_close
+
+
+config EGLIBC_OPTION_EGLIBC_GETLOGIN
+ bool "The getlogin function"
+ default y
+ select EGLIBC_OPTION_EGLIBC_UTMP
+ help
+ This function group includes the 'getlogin' and 'getlogin_r'
+ functions, which return the user name associated by the login
+ activity with the current process's controlling terminal.
+
+ With this option group disabled, the 'glob' function will not
+ fall back on 'getlogin' to find the user's login name for tilde
+ expansion when the 'HOME' environment variable is not set.
+
+
+config EGLIBC_OPTION_EGLIBC_IDN
+ bool "International domain names support"
+ default y
+ help
+ This option group includes the `libcidn' library which
+ provides support for international domain names.
+
+
+config EGLIBC_OPTION_EGLIBC_INET
+ bool "Networking support"
+ default y
+ help
+ This option group includes networking-specific functions and
+ data. With EGLIBC_OPTION_EGLIBC_INET disabled, the EGLIBC
+ installation and API changes as follows:
+
+ - The following libraries are not installed:
+
+ libanl
+ libnsl
+ libnss_compat
+ libnss_dns
+ libnss_hesiod
+ libnss_nis
+ libnss_nisplus
+ libresolv
+
+ - The following functions and variables are omitted from libc:
+
+ authdes_create hstrerror svc_fdset
+ authdes_getucred htonl svc_getreq
+ authdes_pk_create htons svc_getreq_common
+ authnone_create if_freenameindex svc_getreq_poll
+ authunix_create if_indextoname svc_getreqset
+ authunix_create_default if_nameindex svc_max_pollfd
+ bindresvport if_nametoindex svc_pollfd
+ callrpc in6addr_any svcraw_create
+ cbc_crypt in6addr_loopback svc_register
+ clnt_broadcast inet6_opt_append svc_run
+ clnt_create inet6_opt_find svc_sendreply
+ clnt_pcreateerror inet6_opt_finish svctcp_create
+ clnt_perrno inet6_opt_get_val svcudp_bufcreate
+ clnt_perror inet6_opt_init svcudp_create
+ clntraw_create inet6_option_alloc svcudp_enablecache
+ clnt_spcreateerror inet6_option_append svcunix_create
+ clnt_sperrno inet6_option_find svcunixfd_create
+ clnt_sperror inet6_option_init svc_unregister
+ clnttcp_create inet6_option_next user2netname
+ clntudp_bufcreate inet6_option_space xdecrypt
+ clntudp_create inet6_opt_next xdr_accepted_reply
+ clntunix_create inet6_opt_set_val xdr_array
+ des_setparity inet6_rth_add xdr_authdes_cred
+ ecb_crypt inet6_rth_getaddr xdr_authdes_verf
+ endaliasent inet6_rth_init xdr_authunix_parms
+ endhostent inet6_rth_reverse xdr_bool
+ endnetent inet6_rth_segments xdr_bytes
+ endnetgrent inet6_rth_space xdr_callhdr
+ endprotoent inet_addr xdr_callmsg
+ endrpcent inet_aton xdr_char
+ endservent inet_lnaof xdr_cryptkeyarg
+ ether_aton inet_makeaddr xdr_cryptkeyarg2
+ ether_aton_r inet_netof xdr_cryptkeyres
+ ether_hostton inet_network xdr_des_block
+ ether_line inet_nsap_addr xdr_double
+ ether_ntoa inet_nsap_ntoa xdr_enum
+ ether_ntoa_r inet_ntoa xdr_float
+ ether_ntohost inet_ntop xdr_free
+ freeaddrinfo inet_pton xdr_getcredres
+ freeifaddrs innetgr xdr_hyper
+ gai_strerror iruserok xdr_int
+ getaddrinfo iruserok_af xdr_int16_t
+ getaliasbyname key_decryptsession xdr_int32_t
+ getaliasbyname_r key_decryptsession_pk xdr_int64_t
+ getaliasent key_encryptsession xdr_int8_t
+ getaliasent_r key_encryptsession_pk xdr_keybuf
+ gethostbyaddr key_gendes xdr_key_netstarg
+ gethostbyaddr_r key_get_conv xdr_key_netstres
+ gethostbyname key_secretkey_is_set xdr_keystatus
+ gethostbyname2 key_setnet xdr_long
+ gethostbyname2_r key_setsecret xdr_longlong_t
+ gethostbyname_r netname2host xdrmem_create
+ gethostent netname2user xdr_netnamestr
+ gethostent_r ntohl xdr_netobj
+ getifaddrs ntohs xdr_opaque
+ getipv4sourcefilter passwd2des xdr_opaque_auth
+ get_myaddress pmap_getmaps xdr_pmap
+ getnameinfo pmap_getport xdr_pmaplist
+ getnetbyaddr pmap_rmtcall xdr_pointer
+ getnetbyaddr_r pmap_set xdr_quad_t
+ getnetbyname pmap_unset xdrrec_create
+ getnetbyname_r rcmd xdrrec_endofrecord
+ getnetent rcmd_af xdrrec_eof
+ getnetent_r registerrpc xdrrec_skiprecord
+ getnetgrent res_init xdr_reference
+ getnetgrent_r rexec xdr_rejected_reply
+ getnetname rexec_af xdr_replymsg
+ getprotobyname rexecoptions xdr_rmtcall_args
+ getprotobyname_r rpc_createerr xdr_rmtcallres
+ getprotobynumber rresvport xdr_short
+ getprotobynumber_r rresvport_af xdr_sizeof
+ getprotoent rtime xdrstdio_create
+ getprotoent_r ruserok xdr_string
+ getpublickey ruserok_af xdr_u_char
+ getrpcbyname ruserpass xdr_u_hyper
+ getrpcbyname_r setaliasent xdr_u_int
+ getrpcbynumber sethostent xdr_uint16_t
+ getrpcbynumber_r setipv4sourcefilter xdr_uint32_t
+ getrpcent setnetent xdr_uint64_t
+ getrpcent_r setnetgrent xdr_uint8_t
+ getrpcport setprotoent xdr_u_long
+ getsecretkey setrpcent xdr_u_longlong_t
+ getservbyname setservent xdr_union
+ getservbyname_r setsourcefilter xdr_unixcred
+ getservbyport svcauthdes_stats xdr_u_quad_t
+ getservbyport_r svcerr_auth xdr_u_short
+ getservent svcerr_decode xdr_vector
+ getservent_r svcerr_noproc xdr_void
+ getsourcefilter svcerr_noprog xdr_wrapstring
+ h_errlist svcerr_progvers xencrypt
+ h_errno svcerr_systemerr xprt_register
+ herror svcerr_weakauth xprt_unregister
+ h_nerr svc_exit
+ host2netname svcfd_create
+
+ - The rpcgen, nscd, and rpcinfo commands are not installed.
+
+ - The 'rpc' file (a text file listing RPC services) is not installed.
+
+ Socket-related system calls do not fall in this option group,
+ because many are also used for other inter-process
+ communication mechanisms. For example, the 'syslog' routines
+ use Unix-domain sockets to communicate with the syslog daemon;
+ syslog is valuable in non-networked contexts.
+
+
+config EGLIBC_OPTION_EGLIBC_INET_ANL
+ bool "Asynchronous name lookup"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes the `libanl' library which
+ provides support for asynchronous name lookup.
+
+
+config EGLIBC_OPTION_EGLIBC_LIBM
+ bool "libm (math library)"
+ default y
+ help
+ This option group includes the 'libm' library, containing
+ mathematical functions. If this option group is omitted, then
+ an EGLIBC installation does not include shared or unshared versions
+ of the math library.
+
+ Note that this does not remove all floating-point related
+ functionality from EGLIBC; for example, 'printf' and 'scanf'
+ can still print and read floating-point values with this option
+ group disabled.
+
+ Note that the ISO Standard C++ library 'libstdc++' depends on
+ EGLIBC's math library 'libm'. If you disable this option
+ group, you will not be able to build 'libstdc++' against the
+ resulting EGLIBC installation.
+
+
+config EGLIBC_OPTION_EGLIBC_LIBM_BIG
+ bool "Math library size"
+ default y
+ help
+ This option group enables default configuration of the math library.
+ Not selecting this option group removes most of the extended and
+ double precision math functions and replaces them with wrappers
+ to the single precision couterparts.
+ Doing so greatly degrades quality of calculations carried
+ out by the functions of the math library, but also significantly
+ reduces the size of the libm.
+ This option group is useful for systems that do not rely on precise
+ floating point math.
+
+
+config EGLIBC_OPTION_EGLIBC_LOCALES
+ bool "Locale definitions"
+ default y
+ help
+ This option group includes all locale definitions other than
+ that for the "C" locale. If this option group is omitted, then
+ only the "C" locale is supported.
+
+
+config EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ bool "Locale functions"
+ default y
+ select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ help
+ This option group includes locale support functions, programs,
+ and libraries. With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled,
+ EGLIBC supports only the 'C' locale (also known as 'POSIX'),
+ and ignores the settings of the 'LANG' and 'LC_*' environment
+ variables.
+
+ With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled, the following
+ functions are omitted from libc:
+
+ duplocale localeconv nl_langinfo rpmatch strfmon_l
+ freelocale newlocale nl_langinfo_l strfmon uselocale
+
+ Furthermore, only the LC_CTYPE and LC_TIME categories of the
+ standard "C" locale are available.
+
+ The EGLIBC_OPTION_EGLIBC_CATGETS option group depends on this option
+ group; if you disable EGLIBC_OPTION_EGLIBC_LOCALE_CODE, you must also
+ disable EGLIBC_OPTION_EGLIBC_CATGETS.
+
+
+config EGLIBC_OPTION_EGLIBC_MEMUSAGE
+ bool "Memory profiling library"
+ default y
+ help
+ This option group includes the `libmemusage' library and
+ the `memusage' and `memusagestat' utilities.
+ These components provide memory profiling functions.
+
+ EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+
+ Libmemusage library buffers the profiling data in memory
+ before writing it out to disk. By default, the library
+ allocates 1.5M buffer, which can be substantial for some
+ systems. EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option
+ allows to change the default buffer size. It specifies
+ the number of entries the buffer should have.
+ On most architectures one buffer entry amounts to 48 bytes,
+ so setting this option to the value of 512 will reduce the size of
+ the memory buffer to 24K.
+
+
+config EGLIBC_OPTION_EGLIBC_NIS
+ bool "Support for NIS, NIS+, and the special 'compat' services."
+ default n
+ select EGLIBC_OPTION_EGLIBC_INET
+ select EGLIBC_OPTION_EGLIBC_SUNRPC
+ help
+ This option group includes the NIS, NIS+, and 'compat' Name
+ Service Switch service libraries. When it is disabled, those
+ services libraries are not installed; you should remove any
+ references to them from your 'nsswitch.conf' file.
+
+ This option group depends on the EGLIBC_OPTION_EGLIBC_INET option
+ group; you must enable that to enable this option group.
+
+
+config EGLIBC_OPTION_EGLIBC_NSSWITCH
+ bool "Name service switch (nsswitch) support"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+
+ This option group includes support for the 'nsswitch' facility.
+ With this option group enabled, all EGLIBC functions for
+ accessing various system databases (passwords and groups;
+ networking; aliases; public keys; and so on) consult the
+ '/etc/nsswitch.conf' configuration file to decide how to handle
+ queries.
+
+ With this option group disabled, EGLIBC uses a fixed list of
+ services to satisfy queries on each database, as requested by
+ configuration files specified when EGLIBC is built. Your
+ 'option-groups.config' file must set the following two
+ variables:
+
+ EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG
+
+ Set this to the name of a file whose contents observe the
+ same syntax as an ordinary '/etc/nsswitch.conf' file. The
+ EGLIBC build process parses this file just as EGLIBC would
+ at run time if EGLIBC_NSSWITCH were enabled, and
+ produces a C library that uses the nsswitch service
+ libraries to search for database entries as this file
+ specifies, instead of consulting '/etc/nsswitch.conf' at run
+ time.
+
+ This should be an absolute filename. The EGLIBC build
+ process may use it from several different working
+ directories. It may include references to Makefile
+ variables like 'common-objpfx' (the top of the build tree,
+ with a trailing slash), or '..' (the top of the source tree,
+ with a trailing slash).
+
+ The EGLIBC source tree includes a sample configuration file
+ named 'nss/fixed-nsswitch.conf'; for simple configurations,
+ you will probably want to delete references to databases not
+ needed on your system.
+
+ EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS
+
+ The EGLIBC build process uses this file to decide which
+ functions to make available from which service libraries.
+ The file 'nss/fixed-nsswitch.functions' serves as a sample
+ configuration file for this setting, and explains its syntax
+ and meaning in more detail.
+
+ This should be an absolute file name. The EGLIBC build
+ process may use it from several different working
+ directories. It may include references to Makefile
+ variables like 'common-objpfx' (the top of the build tree,
+ with a trailing slash), or '..' (the top of the source tree,
+ with a trailing slash).
+
+ Be sure to mention each function in each service you wish to
+ use. If you do not mention a service's function here, the
+ EGLIBC database access functions will not find it, even if
+ it is listed in the EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG
+ file.
+
+ In this arrangement, EGLIBC will not use the 'dlopen' and
+ 'dlsym' functions to find database access functions. Instead,
+ libc hard-codes references to the service libraries' database
+ access functions. You must explicitly link your program
+ against the name service libraries (those whose names start
+ with 'libnss_', in the sysroot's '/lib' directory) whose
+ functions you intend to use. This arrangement helps
+ system-wide static analysis tools decide which functions a
+ system actually uses.
+
+ Note that some nsswitch service libraries require other option
+ groups to be enabled; for example, the EGLIBC_OPTION_EGLIBC_INET
+ option group must be enabled to use the 'libnss_dns.so.2'
+ service library, which uses the Domain Name System network
+ protocol to answer queries.
+
+
+config EGLIBC_OPTION_EGLIBC_RCMD
+ bool "Support for 'rcmd' and related library functions"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes functions for running commands on
+ remote machines via the 'rsh' protocol, and doing authentication
+ related to those functions. This also includes functions that
+ use the 'rexec' protocol.
+
+ This option group includes the following functions:
+
+ rcmd ruserok
+ rcmd_af ruserok_af
+ rexec iruserok
+ rexec_af iruserok_af
+ rresvport ruserpass
+ rresvport_af
+
+
+config EGLIBC_OPTION_EGLIBC_RTLD_DEBUG
+ bool "Runtime linker debug print outs"
+ default y
+ help
+ This option group enables debug output of the runtime linker
+ which is activated via LD_DEBUG and LD_TRACE_PRELINKING
+ environment variables. Disabling this option group yields
+ a smaller runtime linker binary.
+ BEWARE: Disabling this option group is likely to break
+ the `ldd' utility which may also be used by the prelinker.
+ In particular, the `--unused' ldd option will not work correctly.
+
+
+config EGLIBC_OPTION_EGLIBC_SPAWN
+ bool "Support for POSIX posix_spawn functions"
+ default y
+ help
+ This option group includes the POSIX functions for executing
+ programs in child processes without using 'fork' or 'vfork'.
+
+ This option group includes the following functions:
+
+ posix_spawn
+ posix_spawnattr_destroy
+ posix_spawnattr_getflags
+ posix_spawnattr_getpgroup
+ posix_spawnattr_getschedparam
+ posix_spawnattr_getschedpolicy
+ posix_spawnattr_getsigdefault
+ posix_spawnattr_getsigmask
+ posix_spawnattr_init
+ posix_spawnattr_setflags
+ posix_spawnattr_setpgroup
+ posix_spawnattr_setschedparam
+ posix_spawnattr_setschedpolicy
+ posix_spawnattr_setsigdefault
+ posix_spawnattr_setsigmask
+ posix_spawn_file_actions_addclose
+ posix_spawn_file_actions_adddup2
+ posix_spawn_file_actions_addopen
+ posix_spawn_file_actions_destroy
+ posix_spawn_file_actions_init
+ posix_spawnp
+
+ This option group also provides the ability for the iconv,
+ localedef, and locale programs to operate transparently on
+ compressed charset definitions. When this option group is
+ disabled, those programs will only operate on uncompressed
+ charmap files.
+
+
+config EGLIBC_OPTION_EGLIBC_STREAMS
+ bool "Support for accessing STREAMS."
+ default y
+ help
+ This option group includes functions for reading and writing
+ messages to and from STREAMS. The STREAMS interface provides a
+ uniform mechanism for implementing networking services and other
+ character-based I/O. (STREAMS are not to be confused with
+ <stdio.h> FILE objects, also called 'streams'.)
+
+ This option group includes the following functions:
+
+ getmsg putpmsg
+ getpmsg fattach
+ isastream fdetach
+ putmsg
+
+
+config EGLIBC_OPTION_EGLIBC_SUNRPC
+ bool "Support for the Sun 'RPC' protocol."
+ default n
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes support for the Sun RPC protocols,
+ including the 'rpcgen' and 'rpcinfo' programs.
+
+
+config EGLIBC_OPTION_EGLIBC_UTMP
+ bool "Older access functions for 'utmp' login records"
+ default y
+ help
+ This option group includes the older 'utent' family of
+ functions for accessing user login records in the 'utmp' file.
+ POSIX omits these functions in favor of the 'utxent' family,
+ and they are obsolete on systems other than Linux.
+
+ This option group includes the following functions:
+
+ endutent
+ getutent
+ getutent_r
+ getutid
+ getutid_r
+ getutline
+ getutline_r
+ logwtmp
+ pututline
+ setutent
+ updwtmp
+ utmpname
+
+ This option group includes the following libraries:
+
+ libutil.so (and libutil.a)
+
+
+config EGLIBC_OPTION_EGLIBC_UTMPX
+ bool "POSIX access functions for 'utmp' login records"
+ default y
+ select EGLIBC_OPTION_EGLIBC_UTMP
+ help
+ This option group includes the POSIX functions for reading and
+ writing user login records in the 'utmp' file (usually
+ '/var/run/utmp'). The POSIX functions operate on 'struct
+ utmpx' structures, as opposed to the family of older 'utent'
+ functions, which operate on 'struct utmp' structures.
+
+ This option group includes the following functions:
+
+ endutxent
+ getutmp
+ getutmpx
+ getutxent
+ getutxid
+ getutxline
+ pututxline
+ setutxent
+ updwtmpx
+ utmpxname
+
+
+config EGLIBC_OPTION_EGLIBC_WORDEXP
+ bool "Shell-style word expansion"
+ default y
+ help
+ This option group includes the 'wordexp' function for
+ performing word expansion in the manner of the shell, and the
+ accompanying 'wordfree' function.
+
+
+config EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ bool "ISO C library wide character functions, excluding I/O"
+ default y
+ help
+ This option group includes the functions defined by the ISO C
+ standard for working with wide and multibyte characters in
+ memory. Functions for reading and writing wide and multibyte
+ characters from and to files call in the
+ EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO option group.
+
+ This option group includes the following functions:
+
+ btowc mbsinit wcscspn wcstoll
+ iswalnum mbsrtowcs wcsftime wcstombs
+ iswalpha mbstowcs wcslen wcstoul
+ iswblank mbtowc wcsncat wcstoull
+ iswcntrl swprintf wcsncmp wcstoumax
+ iswctype swscanf wcsncpy wcsxfrm
+ iswdigit towctrans wcspbrk wctob
+ iswgraph towlower wcsrchr wctomb
+ iswlower towupper wcsrtombs wctrans
+ iswprint vswprintf wcsspn wctype
+ iswpunct vswscanf wcsstr wmemchr
+ iswspace wcrtomb wcstod wmemcmp
+ iswupper wcscat wcstof wmemcpy
+ iswxdigit wcschr wcstoimax wmemmove
+ mblen wcscmp wcstok wmemset
+ mbrlen wcscoll wcstol
+ mbrtowc wcscpy wcstold
+
+
+config EGLIBC_OPTION_POSIX_REGEXP
+ bool "Regular expressions"
+ default y
+ help
+ This option group includes the POSIX regular expression
+ functions, and the associated non-POSIX extensions and
+ compatibility functions.
+
+ With EGLIBC_OPTION_POSIX_REGEXP disabled, the following functions are
+ omitted from libc:
+
+ re_comp re_max_failures regcomp
+ re_compile_fastmap re_search regerror
+ re_compile_pattern re_search_2 regexec
+ re_exec re_set_registers regfree
+ re_match re_set_syntax rpmatch
+ re_match_2 re_syntax_options
+
+ Furthermore, the compatibility regexp interface defined in the
+ <regexp.h> header file, 'compile', 'step', and 'advance', is
+ omitted.
+
+
+config EGLIBC_OPTION_POSIX_REGEXP_GLIBC
+ bool "Regular expressions from GLIBC"
+ default y
+ select EGLIBC_OPTION_POSIX_REGEXP
+ help
+ This option group specifies which regular expression
+ library to use. The choice is between regex
+ implementation from GLIBC and regex implementation from
+ libiberty. The GLIBC variant is fully POSIX conformant and
+ optimized for speed; regex from libiberty is more than twice
+ as small while still is enough for most practical purposes.
+
+
+config EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+ bool "Input and output functions for wide characters"
+ default y
+ select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ help
+ This option group includes functions for reading and writing
+ wide characters to and from <stdio.h> streams.
+
+ This option group includes the following functions:
+
+ fgetwc fwprintf putwchar vwscanf
+ fgetws fwscanf ungetwc wprintf
+ fputwc getwc vfwprintf wscanf
+ fputws getwchar vfwscanf
+ fwide putwc vwprintf
+
+ This option group further includes the following unlocked
+ variants of the above functions:
+
+ fgetwc_unlocked getwc_unlocked
+ fgetws_unlocked getwchar_unlocked
+ fputwc_unlocked putwc_unlocked
+ fputws_unlocked putwchar_unlocked
+
+ Note that the GNU standard C++ library, 'libstdc++.so', uses
+ some of these functions; you will not be able to link or run
+ C++ programs if you disable this option group.
+
+ This option group also affects the behavior of the following
+ functions:
+
+ fdopen
+ fopen
+ fopen64
+ freopen
+ freopen64
+
+ These functions all take an OPENTYPE parameter which may
+ contain a string of the form ",ccs=CHARSET", indicating that
+ the underlying file uses the character set named CHARSET.
+ This produces a wide-oriented stream, which is only useful
+ when the functions included in this option group are present.
+ If the user attempts to open a file specifying a character set
+ in the OPENTYPE parameter, and EGLIBC was built with this
+ option group disabled, the function returns NULL, and sets
+ errno to EINVAL.
diff --git a/toolchain/glibc/headers/Makefile b/toolchain/glibc/headers/Makefile
new file mode 100644
index 0000000..f9f411b
--- /dev/null
+++ b/toolchain/glibc/headers/Makefile
@@ -0,0 +1,27 @@
+PATH_PREFIX:=..
+VARIANT:=headers
+
+include ../common.mk
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
+ install-bootstrap-headers=yes \
+ install-headers
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ csu/subdir_lib
+ ( cd $(CUR_BUILD_DIR); \
+ $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
+ )
+ $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
+ -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/glibc/include/libintl.h b/toolchain/glibc/include/libintl.h
new file mode 100644
index 0000000..69cb887
--- /dev/null
+++ b/toolchain/glibc/include/libintl.h
@@ -0,0 +1,6 @@
+#ifndef __FAKE_LIBINTL_H
+#define __FAKE_LIBINTL_H
+
+#define _(X) (X)
+
+#endif
diff --git a/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch b/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch
new file mode 100644
index 0000000..55b26c7
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch
@@ -0,0 +1,48 @@
+--- a/libc/aclocal.m4
++++ b/libc/aclocal.m4
+@@ -88,6 +88,12 @@
+ fi
+ rm -fr contest*])
+
++dnl Test a compiler option or options with an empty input file.
++dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false])
++AC_DEFUN([LIBC_TRY_CC_OPTION],
++[AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])],
++ [$2], [$3])])
++
+ AC_DEFUN([LIBC_PROG_BINUTILS],
+ [# Was a --with-binutils option given?
+ if test -n "$path_binutils"; then
+--- a/libc/configure
++++ b/libc/configure
+@@ -7404,7 +7404,14 @@
+ else
+ libc_cv_cc_nofma=
+ for opt in -ffp-contract=off -mno-fused-madd; do
+- LIBC_TRY_CC_OPTION($opt, libc_cv_cc_nofma=$opt; break)
++ if { ac_try='${CC-cc} $opt -xc /dev/null -S -o /dev/null'
++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; }; then :
++ libc_cv_cc_nofma=$opt; break
++fi
+ done
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_nofma" >&5
+--- a/libc/configure.in
++++ b/libc/configure.in
+@@ -2238,10 +2238,9 @@
+ libc_cv_cc_submachine, [dnl
+ libc_cv_cc_submachine=no
+ for opt in "-march=$submachine" "-mcpu=$submachine"; do
+- if AC_TRY_COMMAND([${CC-cc} $opt -xc /dev/null -S -o /dev/null]); then
++ LIBC_TRY_CC_OPTION([$opt], [
+ libc_cv_cc_submachine="$opt"
+- break
+- fi
++ break], [])
+ done])
+ if test "x$libc_cv_cc_submachine" = xno; then
+ AC_MSG_ERROR([${CC-cc} does not support $submachine])
diff --git a/toolchain/glibc/patches/2.15/005-versions.patch b/toolchain/glibc/patches/2.15/005-versions.patch
new file mode 100644
index 0000000..da9d2ba
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/005-versions.patch
@@ -0,0 +1,11 @@
+--- a/libc/configure.in
++++ b/libc/configure.in
+@@ -1037,7 +1037,7 @@
+ critic_missing="$critic_missing gcc")
+ AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
+ [GNU Make[^0-9]*\([0-9][0-9.]*\)],
+- [3.79* | 3.[89]*], critic_missing="$critic_missing make")
++ [3.79* | 3.[89]* | 4.* ], critic_missing="$critic_missing make")
+
+ AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
+ [GNU gettext.* \([0-9]*\.[0-9.]*\)],
diff --git a/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch b/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch
new file mode 100644
index 0000000..d1e19aa
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch
@@ -0,0 +1,110 @@
+partially revert commit 4bff6e0175ed195871f4e01cc4c4c33274b8f6e3 - caused segmentation faults in dlopen
+
+References:
+http://comments.gmane.org/gmane.comp.lib.glibc.user/1227
+http://sourceware.org/ml/libc-alpha/2011-06/msg00006.html
+
+diff --git a/libc/elf/dl-close.c b/libc/elf/dl-close.c
+index 4b17bf8..733cc1b 100644
+--- a/libc/elf/dl-close.c
++++ b/libc/elf/dl-close.c
+@@ -119,17 +119,8 @@ _dl_close_worker (struct link_map *map)
+ if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
+ || dl_close_state != not_pending)
+ {
+- if (map->l_direct_opencount == 0)
+- {
+- if (map->l_type == lt_loaded)
+- dl_close_state = rerun;
+- else if (map->l_type == lt_library)
+- {
+- struct link_map **oldp = map->l_initfini;
+- map->l_initfini = map->l_orig_initfini;
+- _dl_scope_free (oldp);
+- }
+- }
++ if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
++ dl_close_state = rerun;
+
+ /* There are still references to this object. Do nothing more. */
+ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0))
+diff --git a/libc/elf/dl-deps.c b/libc/elf/dl-deps.c
+index 51cb2fa..eddcbf0 100644
+--- a/libc/elf/dl-deps.c
++++ b/libc/elf/dl-deps.c
+@@ -489,6 +489,7 @@ _dl_map_object_deps (struct link_map *map,
+ nneeded * sizeof needed[0]);
+ atomic_write_barrier ();
+ l->l_initfini = l_initfini;
++ l->l_free_initfini = 1;
+ }
+
+ /* If we have no auxiliary objects just go on to the next map. */
+@@ -689,6 +690,7 @@ Filters not supported with LD_TRACE_PRELINKING"));
+ l_initfini[nlist] = NULL;
+ atomic_write_barrier ();
+ map->l_initfini = l_initfini;
++ map->l_free_initfini = 1;
+ if (l_reldeps != NULL)
+ {
+ atomic_write_barrier ();
+@@ -697,7 +699,7 @@ Filters not supported with LD_TRACE_PRELINKING"));
+ _dl_scope_free (old_l_reldeps);
+ }
+ if (old_l_initfini != NULL)
+- map->l_orig_initfini = old_l_initfini;
++ _dl_scope_free (old_l_initfini);
+
+ if (errno_reason)
+ _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
+diff --git a/libc/elf/dl-libc.c b/libc/elf/dl-libc.c
+index f44fa10..7563093 100644
+--- a/libc/elf/dl-libc.c
++++ b/libc/elf/dl-libc.c
+@@ -284,6 +284,10 @@ libc_freeres_fn (free_mem)
+ if (! old->dont_free)
+ free (old);
+ }
++
++ /* Free the initfini dependency list. */
++ if (l->l_free_initfini)
++ free (l->l_initfini);
+ }
+
+ if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0
+diff --git a/libc/elf/rtld.c b/libc/elf/rtld.c
+index b93a01f..2fc83ce 100644
+--- a/libc/elf/rtld.c
++++ b/libc/elf/rtld.c
+@@ -2277,6 +2277,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
+ lnp->dont_free = 1;
+ lnp = lnp->next;
+ }
++ l->l_free_initfini = 0;
+
+ if (l != &GL(dl_rtld_map))
+ _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
+diff --git a/libc/include/link.h b/libc/include/link.h
+index e877104..b1b4065 100644
+--- a/libc/include/link.h
++++ b/libc/include/link.h
+@@ -192,6 +192,9 @@ struct link_map
+ during LD_TRACE_PRELINKING=1
+ contains any DT_SYMBOLIC
+ libraries. */
++ unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be
++ freed, ie. not allocated with
++ the dummy malloc in ld.so. */
+
+ /* Collected information about own RPATH directories. */
+ struct r_search_path_struct l_rpath_dirs;
+@@ -240,9 +243,6 @@ struct link_map
+
+ /* List of object in order of the init and fini calls. */
+ struct link_map **l_initfini;
+- /* The init and fini list generated at startup, saved when the
+- object is also loaded dynamically. */
+- struct link_map **l_orig_initfini;
+
+ /* List of the dependencies introduced through symbol binding. */
+ struct link_map_reldeps
diff --git a/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..8fe5cf3
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch
@@ -0,0 +1,71 @@
+--- a/libc/sunrpc/proto.h
++++ b/libc/sunrpc/proto.h
+@@ -56,12 +56,14 @@ void add_type(int len, const char *type)
+ $build's C library and $host's GLIBC. */
+ #ifdef _CROSS_RPCGEN_
+
++#undef stpcpy
++
+ /* Rather then defining _GNU_SOURCE before including $build's <string.h>
+ we just declare stpcpy here. */
+ extern char *stpcpy (char *, const char *);
+
+-/* Use $build's i18n support as we can't use $host's. */
+-#define _(X) (gettext (X))
++/* Do not use i18n support */
++#define _(X) (X)
+
+ /* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
+ that rpcgen generates. The proper fix would be to rename all those checks
+--- a/libc/sunrpc/rpc/types.h
++++ b/libc/sunrpc/rpc/types.h
+@@ -70,18 +70,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/libc/sunrpc/rpc_main.c
++++ b/libc/sunrpc/rpc_main.c
+@@ -997,9 +997,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch b/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch
new file mode 100644
index 0000000..221eb28
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch
@@ -0,0 +1,27 @@
+--- a/libc/timezone/zic.c
++++ b/libc/timezone/zic.c
+@@ -8,6 +8,8 @@ static char elsieid[] = "@(#)zic.c 8.19"
+ #ifdef CROSS_ZIC
+ #define REPORT_BUGS_TO ""
+ #define PKGVERSION ""
++#undef _
++#define _(X) (X)
+ #else
+ #include "config.h"
+ #endif
+@@ -490,6 +492,7 @@ char * argv[];
+ #ifdef unix
+ (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
+ #endif /* defined unix */
++#ifndef CROSS_ZIC
+ #if HAVE_GETTEXT
+ (void) setlocale(LC_ALL, "");
+ #ifdef TZ_DOMAINDIR
+@@ -497,6 +500,7 @@ char * argv[];
+ #endif /* defined TEXTDOMAINDIR */
+ (void) textdomain(TZ_DOMAIN);
+ #endif /* HAVE_GETTEXT */
++#endif
+ progname = argv[0];
+ if (TYPE_BIT(zic_t) < 64) {
+ (void) fprintf(stderr, "%s: %s\n", progname,
diff --git a/toolchain/glibc/patches/2.15/120-use_host_cflags.patch b/toolchain/glibc/patches/2.15/120-use_host_cflags.patch
new file mode 100644
index 0000000..4c58fb4
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/120-use_host_cflags.patch
@@ -0,0 +1,22 @@
+--- a/libc/sunrpc/Makefile
++++ b/libc/sunrpc/Makefile
+@@ -175,7 +175,7 @@ $(objpfx)rpcgen: $(addprefix $(objpfx),$
+ $(+link)
+
+ $(addprefix $(objpfx)cross-,$(rpcgen-objs)): $(objpfx)cross-%.o: %.c
+- gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ \
++ gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ $(HOST_CFLAGS) \
+ $(OUTPUT_OPTION) $(compile-mkdep-flags)
+
+ $(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+--- a/libc/timezone/Makefile
++++ b/libc/timezone/Makefile
+@@ -182,7 +182,7 @@ $(objpfx)zic: $(addprefix $(objpfx), $(z
+
+ $(addprefix $(objpfx)cross-,$(zic-objs)): $(objpfx)cross-%.o: %.c
+ gcc $< -c $(OUTPUT_OPTION) $(CFLAGS-$*.c) $(CPPFLAGS-$*) \
+- -DCROSS_ZIC $(compile-mkdep-flags)
++ -DCROSS_ZIC $(HOST_CFLAGS) $(compile-mkdep-flags)
+
+ $(objpfx)cross-zic: $(addprefix $(objpfx)cross-,$(zic-objs))
+ gcc $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@
diff --git a/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..70e7e60
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/libc/Makeconfig
++++ b/libc/Makeconfig
+@@ -539,6 +539,9 @@
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..5c0d45b
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch
@@ -0,0 +1,52 @@
+--- a/libc/sunrpc/rpc/types.h
++++ b/libc/sunrpc/rpc/types.h
+@@ -75,18 +75,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/libc/sunrpc/rpc_main.c
++++ b/libc/sunrpc/rpc_main.c
+@@ -958,9 +958,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..fa192ca
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/libc/Makeconfig
++++ b/libc/Makeconfig
+@@ -501,6 +501,9 @@ else
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch b/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch
new file mode 100644
index 0000000..623885c
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch
@@ -0,0 +1,13 @@
+Index: eglibc-2.19-r25243/libc/aclocal.m4
+===================================================================
+--- eglibc-2.19-r25243.orig/libc/aclocal.m4 2013-11-06 15:03:08.000000000 -0800
++++ eglibc-2.19-r25243/libc/aclocal.m4 2014-11-22 15:43:05.343256863 -0800
+@@ -1,7 +1,7 @@
+ dnl We require that everyone use exactly the same Autoconf version so that
+ dnl the internal functions defined and used by the main configure script
+ dnl match those expected by the fragments.
+-m4_define([GLIBC_AUTOCONF_VERSION], [2.68])
++m4_define([GLIBC_AUTOCONF_VERSION], [2.69])
+ m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [],
+ [m4_fatal(m4_flatten(
+ Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have
diff --git a/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..6a5e537
--- /dev/null
+++ b/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch
@@ -0,0 +1,52 @@
+--- a/sunrpc/rpc/types.h
++++ b/sunrpc/rpc/types.h
+@@ -75,18 +75,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/sunrpc/rpc_main.c
++++ b/sunrpc/rpc_main.c
+@@ -958,9 +958,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..a6200f7
--- /dev/null
+++ b/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/Makeconfig
++++ b/Makeconfig
+@@ -501,6 +501,9 @@ else
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/info.mk b/toolchain/info.mk
new file mode 100644
index 0000000..4f311c5
--- /dev/null
+++ b/toolchain/info.mk
@@ -0,0 +1,6 @@
+TARGET_CROSS=
+GCC_VERSION=unknown
+LIBC_TYPE=unknown
+LIBC_URL=unknown
+LIBC_VERSION=unknown
+LIBC_SO_VERSION=unknown
diff --git a/toolchain/insight/Makefile b/toolchain/insight/Makefile
new file mode 100644
index 0000000..3744f56
--- /dev/null
+++ b/toolchain/insight/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=insight
+PKG_VERSION:=6.8-1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)a.tar.bz2
+PKG_MD5SUM:=f7dd764a102beb75c2bb6b8d83455f8e
+PKG_SOURCE_URL:=ftp://sourceware.org/pub/insight/releases
+PKG_CAT:=bzcat
+
+STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
+BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+define Host/Configure
+ (cd $(HOST_BUILD_DIR); \
+ gdb_cv_func_sigsetjmp=yes \
+ CFLAGS="-O2" \
+ $(HOST_BUILD_DIR)/configure \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-threads \
+ --enable-werror=no \
+ );
+endef
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR)
+endef
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/gdb/insight $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight
+ ln -fs $(TARGET_CROSS)insight $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-insight
+ strip $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight \
+ $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-insight
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch b/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000..13b72bb
--- /dev/null
+++ b/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,31 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -272,7 +272,7 @@
+ PACKAGE_BUGREPORT=
+
+ ac_unique_file="main.c"
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ # Factoring default headers for most tests.
+ ac_includes_default="\
+ #include <stdio.h>
+@@ -3077,7 +3077,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
diff --git a/toolchain/kernel-headers/Makefile b/toolchain/kernel-headers/Makefile
new file mode 100644
index 0000000..90f8eb1
--- /dev/null
+++ b/toolchain/kernel-headers/Makefile
@@ -0,0 +1,100 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+KERNEL_BUILD_DIR := $(BUILD_DIR_TOOLCHAIN)
+BUILD_DIR := $(KERNEL_BUILD_DIR)
+
+override QUILT:=
+override HOST_QUILT:=
+
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=linux
+PKG_VERSION:=$(LINUX_VERSION)
+PKG_SOURCE:=$(LINUX_SOURCE)
+PKG_SOURCE_URL:=$(LINUX_SITE)
+HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
+PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
+LINUX_DIR := $(HOST_BUILD_DIR)
+FILES_DIR :=
+PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+include $(INCLUDE_DIR)/kernel-defaults.mk
+
+ifeq ($(strip $(BOARD)),uml)
+ LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
+endif
+
+HOST_EXTRACFLAGS=
+
+LINUX_HAS_HEADERS_INSTALL:=y
+
+KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
+ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
+ ARCH=$(LINUX_KARCH) \
+ CC="$(KERNEL_CC)" \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS_COMPILE=$(TARGET_CROSS) \
+ KBUILD_HAVE_NLS=no \
+ CONFIG_SHELL=$(BASH)
+
+define Host/Configure/all
+ mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
+ $(KMAKE) \
+ INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
+ headers_install
+endef
+
+# XXX: the following is needed to build lzma-loader
+ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
+ define Host/Configure/lzma
+ $(CP) \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
+ $(if $(call kernel_patchver_ge,3.15.0),$(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h) \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
+ endef
+endif
+
+define Host/Configure/post/mips
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Configure/post/mipsel
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Prepare
+ $(call Kernel/Prepare/Default)
+ ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
+ $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
+endef
+
+define Host/Configure
+ env
+ yes '' | $(KMAKE) oldconfig
+ $(call Host/Configure/all)
+ $(call Host/Configure/post/$(ARCH))
+endef
+
+define Host/Compile
+endef
+
+define Host/Install
+ $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/linux \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/musl/Config.in b/toolchain/musl/Config.in
new file mode 100644
index 0000000..05caa6a
--- /dev/null
+++ b/toolchain/musl/Config.in
@@ -0,0 +1,6 @@
+# Debug version.
+
+config MUSL_ENABLE_DEBUG
+ bool "Build with debug information"
+ depends on TOOLCHAINOPTS && USE_MUSL
+ default n
diff --git a/toolchain/musl/Config.version b/toolchain/musl/Config.version
new file mode 100644
index 0000000..72236db
--- /dev/null
+++ b/toolchain/musl/Config.version
@@ -0,0 +1,8 @@
+if USE_MUSL
+
+config MUSL_VERSION
+ string
+ depends on USE_MUSL
+ default "1.1.11"
+
+endif
diff --git a/toolchain/musl/Makefile b/toolchain/musl/Makefile
new file mode 100644
index 0000000..1533f51
--- /dev/null
+++ b/toolchain/musl/Makefile
@@ -0,0 +1,31 @@
+PATH_PREFIX=.
+
+include ./common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.musl_installed
+
+HOST_BUILD_PARALLEL:=1
+
+MUSL_MAKEOPTS = -C $(HOST_BUILD_DIR) \
+ DESTDIR="$(TOOLCHAIN_DIR)/" \
+ LIBCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))"
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.musl-libc.org/,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) $(MUSL_MAKEOPTS) all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(MAKE) $(MUSL_MAKEOPTS) DESTDIR="$(TOOLCHAIN_DIR)/" install
+ $(CP) ./include $(TOOLCHAIN_DIR)/
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/musl/common.mk b/toolchain/musl/common.mk
new file mode 100644
index 0000000..3045c63
--- /dev/null
+++ b/toolchain/musl/common.mk
@@ -0,0 +1,69 @@
+#
+# Copyright (C) 2012-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_NAME:=musl
+PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION))
+PKG_RELEASE=1
+
+PKG_MD5SUM:=48be0777e32f374d387e9cf85e36ec4d
+
+PKG_SOURCE_URL:=http://www.musl-libc.org/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+LIBC_SO_VERSION:=$(PKG_VERSION)
+PATCH_DIR:=$(PATH_PREFIX)/patches
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+include $(INCLUDE_DIR)/hardening.mk
+
+# Please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67260
+ifeq ($(CONFIG_sh3),y)
+TARGET_CFLAGS+= \
+ -fno-optimize-sibling-calls
+endif
+
+MUSL_CONFIGURE:= \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ $(HOST_BUILD_DIR)/configure \
+ --prefix=/ \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-gcc-wrapper
+
+ifeq ($(CONFIG_MUSL_ENABLE_DEBUG),y)
+MUSL_CONFIGURE+= \
+ --enable-debug
+endif
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ $(if $(strip $(QUILT)), \
+ cd $(HOST_BUILD_DIR); \
+ if $(QUILT_CMD) next >/dev/null 2>&1; then \
+ $(QUILT_CMD) push -a; \
+ fi
+ )
+ ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+define Host/Configure
+ ( cd $(HOST_BUILD_DIR); rm -f config.cache; \
+ $(MUSL_CONFIGURE) \
+ );
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
+endef
diff --git a/toolchain/musl/headers/Makefile b/toolchain/musl/headers/Makefile
new file mode 100644
index 0000000..21e6b3b
--- /dev/null
+++ b/toolchain/musl/headers/Makefile
@@ -0,0 +1,16 @@
+PATH_PREFIX:=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed
+
+define Host/Compile
+
+endef
+
+define Host/Install
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/musl/include/bits/wordsize.h b/toolchain/musl/include/bits/wordsize.h
new file mode 100644
index 0000000..2d4cbe8
--- /dev/null
+++ b/toolchain/musl/include/bits/wordsize.h
@@ -0,0 +1 @@
+#include <sys/user.h>
diff --git a/toolchain/musl/include/features.h b/toolchain/musl/include/features.h
new file mode 100644
index 0000000..edb8cc7
--- /dev/null
+++ b/toolchain/musl/include/features.h
@@ -0,0 +1,48 @@
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#ifdef _ALL_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+/* Convenience macros to test the versions of glibc and gcc.
+ Use them like this:
+ #if __GNUC_PREREQ (2,8)
+ ... code requiring gcc 2.8 or later ...
+ #endif
+ Note - they won't work for gcc1 or glibc1, since the _MINOR macros
+ were not defined then. */
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define __GNUC_PREREQ(maj, min) 0
+#endif
+
+#include <sys/glibc-types.h>
+
+#endif
diff --git a/toolchain/musl/include/sgidefs.h b/toolchain/musl/include/sgidefs.h
new file mode 100644
index 0000000..74509fd
--- /dev/null
+++ b/toolchain/musl/include/sgidefs.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 1996, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H 1
+
+/*
+ * A crude hack to stop <asm/sgidefs.h>
+ */
+#undef __ASM_SGIDEFS_H
+#define __ASM_SGIDEFS_H
+
+/*
+ * And remove any damage it might have already done
+ */
+#undef _MIPS_ISA_MIPS1
+#undef _MIPS_ISA_MIPS2
+#undef _MIPS_ISA_MIPS3
+#undef _MIPS_ISA_MIPS4
+#undef _MIPS_ISA_MIPS5
+#undef _MIPS_ISA_MIPS32
+#undef _MIPS_ISA_MIPS64
+
+#undef _MIPS_SIM_ABI32
+#undef _MIPS_SIM_NABI32
+#undef _MIPS_SIM_ABI64
+
+/*
+ * Definitions for the ISA level
+ */
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+#define _MIPS_ISA_MIPS32 6
+#define _MIPS_ISA_MIPS64 7
+
+/*
+ * Subprogram calling convention
+ */
+#ifndef _ABIO32
+# define _ABIO32 1
+#endif
+#define _MIPS_SIM_ABI32 _ABIO32
+
+#ifndef _ABIN32
+# define _ABIN32 2
+#endif
+#define _MIPS_SIM_NABI32 _ABIN32
+
+#ifndef _ABI64
+# define _ABI64 3
+#endif
+#define _MIPS_SIM_ABI64 _ABI64
+
+#endif /* sgidefs.h */
diff --git a/toolchain/musl/include/sys/cdefs.h b/toolchain/musl/include/sys/cdefs.h
new file mode 100644
index 0000000..e986670
--- /dev/null
+++ b/toolchain/musl/include/sys/cdefs.h
@@ -0,0 +1,378 @@
+/* Copyright (C) 1992-2002, 2004, 2005, 2006, 2007, 2009, 2011, 2012
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_CDEFS_H
+#define _SYS_CDEFS_H 1
+
+/* We are almost always included from features.h. */
+#ifndef _FEATURES_H
+# include <features.h>
+#endif
+
+/* The GNU libc does not support any K&R compilers or the traditional mode
+ of ISO C compilers anymore. Check for some of the combinations not
+ anymore supported. */
+#if defined __GNUC__ && !defined __STDC__
+# error "You need a ISO C conforming compiler to use the glibc headers"
+#endif
+
+/* Some user header file might have defined this before. */
+#undef __P
+#undef __PMT
+
+#ifdef __GNUC__
+
+/* All functions, except those with callbacks or those that
+ synchronize memory, are leaf functions. */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+# define __LEAF , __leaf__
+# define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+# define __LEAF
+# define __LEAF_ATTR
+# endif
+
+/* GCC can always grok prototypes. For C++ programs we add throw()
+ to help it optimize the function calls. But this works only with
+ gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
+ as non-throwing using a function attribute since programs can use
+ the -fexceptions options for C code as well. */
+# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
+# define __THROW __attribute__ ((__nothrow__ __LEAF))
+# define __THROWNL __attribute__ ((__nothrow__))
+# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
+# else
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# define __THROWNL throw ()
+# define __NTH(fct) __LEAF_ATTR fct throw ()
+# else
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+# endif
+# endif
+
+#else /* Not GCC. */
+
+# define __inline /* No inline functions. */
+
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+
+#endif /* GCC. */
+
+/* These two macros are not used in glibc anymore. They are kept here
+ only because some other projects expect the macros to be defined. */
+#define __P(args) args
+#define __PMT(args) args
+
+/* For these things, GCC behaves the ANSI way normally,
+ and the non-ANSI way under -traditional. */
+
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+/* This is not a typedef so `const __ptr_t' does the right thing. */
+#define __ptr_t void *
+#define __long_double_t long double
+
+
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+
+/* The standard library needs the functions from the ISO C90 standard
+ in the std namespace. At the same time we want to be safe for
+ future changes and we include the ISO C99 code in the non-standard
+ namespace __c99. The C++ wrapper header take case of adding the
+ definitions to the global namespace. */
+#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
+# define __BEGIN_NAMESPACE_STD namespace std {
+# define __END_NAMESPACE_STD }
+# define __USING_NAMESPACE_STD(name) using std::name;
+# define __BEGIN_NAMESPACE_C99 namespace __c99 {
+# define __END_NAMESPACE_C99 }
+# define __USING_NAMESPACE_C99(name) using __c99::name;
+#else
+/* For compatibility we do not add the declarations into any
+ namespace. They will end up in the global namespace which is what
+ old code expects. */
+# define __BEGIN_NAMESPACE_STD
+# define __END_NAMESPACE_STD
+# define __USING_NAMESPACE_STD(name)
+# define __BEGIN_NAMESPACE_C99
+# define __END_NAMESPACE_C99
+# define __USING_NAMESPACE_C99(name)
+#endif
+
+
+/* Support for bounded pointers. */
+#ifndef __BOUNDED_POINTERS__
+# define __bounded /* nothing */
+# define __unbounded /* nothing */
+# define __ptrvalue /* nothing */
+#endif
+
+
+/* Fortify support. */
+#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+#define __bos0(ptr) __builtin_object_size (ptr, 0)
+#define __fortify_function __extern_always_inline __attribute_artificial__
+
+#if __GNUC_PREREQ (4,3)
+# define __warndecl(name, msg) \
+ extern void name (void) __attribute__((__warning__ (msg)))
+# define __warnattr(msg) __attribute__((__warning__ (msg)))
+# define __errordecl(name, msg) \
+ extern void name (void) __attribute__((__error__ (msg)))
+#else
+# define __warndecl(name, msg) extern void name (void)
+# define __warnattr(msg)
+# define __errordecl(name, msg) extern void name (void)
+#endif
+
+/* Support for flexible arrays. */
+#if __GNUC_PREREQ (2,97)
+/* GCC 2.97 supports C99 flexible array members. */
+# define __flexarr []
+#else
+# ifdef __GNUC__
+# define __flexarr [0]
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __flexarr []
+# else
+/* Some other non-C99 compiler. Approximate with [1]. */
+# define __flexarr [1]
+# endif
+# endif
+#endif
+
+
+/* __asm__ ("xyz") is used throughout the headers to rename functions
+ at the assembly language level. This is wrapped by the __REDIRECT
+ macro, in order to support compilers that can do this some other
+ way. When compilers don't support asm-names at all, we have to do
+ preprocessor tricks instead (which don't have exactly the right
+ semantics, but it's the best we can do).
+
+ Example:
+ int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# ifdef __cplusplus
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __THROW __asm__ (__ASMNAME (#alias))
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __THROWNL __asm__ (__ASMNAME (#alias))
+# else
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROW
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+# endif
+# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+
+/*
+#elif __SOME_OTHER_COMPILER__
+
+# define __REDIRECT(name, proto, alias) name proto; \
+ _Pragma("let " #name " = " #alias)
+*/
+#endif
+
+/* GCC has various useful declarations that can be made with the
+ `__attribute__' syntax. All of the ways we use this do fine if
+ they are omitted for compilers that don't understand it. */
+#if !defined __GNUC__ || __GNUC__ < 2
+# define __attribute__(xyz) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+#else
+# define __attribute_malloc__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `pure' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_pure__ __attribute__ ((__pure__))
+#else
+# define __attribute_pure__ /* Ignore */
+#endif
+
+/* This declaration tells the compiler that the value is constant. */
+#if __GNUC_PREREQ (2,5)
+# define __attribute_const__ __attribute__ ((__const__))
+#else
+# define __attribute_const__ /* Ignore */
+#endif
+
+/* At some point during the gcc 3.1 development the `used' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+# define __attribute_noinline__ /* Ignore */
+#endif
+
+/* gcc allows marking deprecated functions. */
+#if __GNUC_PREREQ (3,2)
+# define __attribute_deprecated__ __attribute__ ((__deprecated__))
+#else
+# define __attribute_deprecated__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.8 development the `format_arg' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings.
+ If several `format_arg' attributes are given for the same function, in
+ gcc-3.0 and older, all but the last one are ignored. In newer gccs,
+ all designated arguments are considered. */
+#if __GNUC_PREREQ (2,8)
+# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+#else
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) \
+ __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
+/* The nonull function attribute allows to mark pointer parameters which
+ must not be NULL. */
+#if __GNUC_PREREQ (3,3)
+# define __nonnull(params) __attribute__ ((__nonnull__ params))
+#else
+# define __nonnull(params)
+#endif
+
+/* If fortification mode, we warn about unused results of certain
+ function calls which can lead to problems. */
+#if __GNUC_PREREQ (3,4)
+# define __attribute_warn_unused_result__ \
+ __attribute__ ((__warn_unused_result__))
+# if __USE_FORTIFY_LEVEL > 0
+# define __wur __attribute_warn_unused_result__
+# endif
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+#ifndef __wur
+# define __wur /* Ignore */
+#endif
+
+/* Forces a function to be always inlined. */
+#if __GNUC_PREREQ (3,2)
+# define __always_inline __inline __attribute__ ((__always_inline__))
+#else
+# define __always_inline __inline
+#endif
+
+/* Associate error messages with the source location of the call site rather
+ than with the source location inside the function. */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
+/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+ inline semantics, unless -fgnu89-inline is used. */
+#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__))
+# else
+# define __extern_inline extern __inline
+# define __extern_always_inline extern __always_inline
+# endif
+#endif
+
+/* GCC 4.3 and above allow passing all anonymous arguments of an
+ __extern_always_inline function to some other vararg function. */
+#if __GNUC_PREREQ (4,3)
+# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
+#endif
+
+/* It is possible to compile containing GCC extensions even if GCC is
+ run in pedantic mode if the uses are carefully marked using the
+ `__extension__' keyword. But this is not generally available before
+ version 2.8. */
+#if !__GNUC_PREREQ (2,8)
+# define __extension__ /* Ignore */
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# define __restrict /* Ignore */
+#endif
+
+/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
+ array_name[restrict]
+ GCC 3.1 supports this. */
+#if __GNUC_PREREQ (3,1) && !defined __GNUG__
+# define __restrict_arr __restrict
+#else
+# ifdef __GNUC__
+# define __restrict_arr /* Not supported in old GCC. */
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict_arr restrict
+# else
+/* Some other non-C99 compiler. */
+# define __restrict_arr /* Not supported. */
+# endif
+# endif
+#endif
+
+#if __GNUC__ >= 3
+# define __glibc_unlikely(cond) __builtin_expect((cond), 0)
+#else
+# define __glibc_unlikely(cond) (cond)
+#endif
+
+#endif /* sys/cdefs.h */
diff --git a/toolchain/musl/include/sys/glibc-types.h b/toolchain/musl/include/sys/glibc-types.h
new file mode 100644
index 0000000..fa0684c
--- /dev/null
+++ b/toolchain/musl/include/sys/glibc-types.h
@@ -0,0 +1,35 @@
+#ifndef __MUSL_GLIBC_TYPES_H
+#define __MUSL_GLIBC_TYPES_H
+
+#include <sys/cdefs.h>
+
+/* Convenience types. */
+typedef unsigned char __u_char;
+typedef unsigned short int __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long int __u_long;
+
+/* Fixed-size types, underlying types depend on word size and compiler. */
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#if __WORDSIZE == 64
+typedef signed long int __int64_t;
+typedef unsigned long int __uint64_t;
+#else
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+#endif
+
+#define __off64_t off_t
+#define __loff_t off_t
+typedef char *__caddr_t;
+#define __locale_t locale_t
+
+#define __gid_t gid_t
+#define __uid_t uid_t
+
+#endif
diff --git a/toolchain/musl/include/sys/queue.h b/toolchain/musl/include/sys/queue.h
new file mode 100644
index 0000000..daf4553
--- /dev/null
+++ b/toolchain/musl/include/sys/queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef _SYS_QUEUE_H_
+#define _SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list. Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction. Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define LIST_HEAD(name, type) \
+struct name { \
+ struct type *lh_first; /* first element */ \
+}
+
+#define LIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+#define LIST_INIT(head) do { \
+ (head)->lh_first = NULL; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+ (head)->lh_first = (elm); \
+ (elm)->field.le_prev = &(head)->lh_first; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_FOREACH(var, head, field) \
+ for ((var) = ((head)->lh_first); \
+ (var); \
+ (var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define LIST_EMPTY(head) ((head)->lh_first == NULL)
+#define LIST_FIRST(head) ((head)->lh_first)
+#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define SLIST_HEAD(name, type) \
+struct name { \
+ struct type *slh_first; /* first element */ \
+}
+
+#define SLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define SLIST_ENTRY(type) \
+struct { \
+ struct type *sle_next; /* next element */ \
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define SLIST_INIT(head) do { \
+ (head)->slh_first = NULL; \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
+ (slistelm)->field.sle_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.sle_next = (head)->slh_first; \
+ (head)->slh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_REMOVE_HEAD(head, field) do { \
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_REMOVE(head, elm, type, field) do { \
+ if ((head)->slh_first == (elm)) { \
+ SLIST_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = (head)->slh_first; \
+ while(curelm->field.sle_next != (elm)) \
+ curelm = curelm->field.sle_next; \
+ curelm->field.sle_next = \
+ curelm->field.sle_next->field.sle_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_FOREACH(var, head, field) \
+ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
+#define SLIST_FIRST(head) ((head)->slh_first)
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define STAILQ_HEAD(name, type) \
+struct name { \
+ struct type *stqh_first; /* first element */ \
+ struct type **stqh_last; /* addr of last next element */ \
+}
+
+#define STAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).stqh_first }
+
+#define STAILQ_ENTRY(type) \
+struct { \
+ struct type *stqe_next; /* next element */ \
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define STAILQ_INIT(head) do { \
+ (head)->stqh_first = NULL; \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (head)->stqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.stqe_next = NULL; \
+ *(head)->stqh_last = (elm); \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (listelm)->field.stqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->stqh_first == (elm)) { \
+ STAILQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->stqh_first; \
+ while (curelm->field.stqe_next != (elm)) \
+ curelm = curelm->field.stqe_next; \
+ if ((curelm->field.stqe_next = \
+ curelm->field.stqe_next->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(curelm)->field.stqe_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->stqh_first); \
+ (var); \
+ (var) = ((var)->field.stqe_next))
+
+#define STAILQ_CONCAT(head1, head2) do { \
+ if (!STAILQ_EMPTY((head2))) { \
+ *(head1)->stqh_last = (head2)->stqh_first; \
+ (head1)->stqh_last = (head2)->stqh_last; \
+ STAILQ_INIT((head2)); \
+ } \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
+#define STAILQ_FIRST(head) ((head)->stqh_first)
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define SIMPLEQ_HEAD(name, type) \
+struct name { \
+ struct type *sqh_first; /* first element */ \
+ struct type **sqh_last; /* addr of last next element */ \
+}
+
+#define SIMPLEQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).sqh_first }
+
+#define SIMPLEQ_ENTRY(type) \
+struct { \
+ struct type *sqe_next; /* next element */ \
+}
+
+/*
+ * Simple queue functions.
+ */
+#define SIMPLEQ_INIT(head) do { \
+ (head)->sqh_first = NULL; \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (head)->sqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.sqe_next = NULL; \
+ *(head)->sqh_last = (elm); \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (listelm)->field.sqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->sqh_first == (elm)) { \
+ SIMPLEQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->sqh_first; \
+ while (curelm->field.sqe_next != (elm)) \
+ curelm = curelm->field.sqe_next; \
+ if ((curelm->field.sqe_next = \
+ curelm->field.sqe_next->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(curelm)->field.sqe_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->sqh_first); \
+ (var); \
+ (var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
+#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
+#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define _TAILQ_HEAD(name, type, qual) \
+struct name { \
+ qual type *tqh_first; /* first element */ \
+ qual type *qual *tqh_last; /* addr of last next element */ \
+}
+#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define _TAILQ_ENTRY(type, qual) \
+struct { \
+ qual type *tqe_next; /* next element */ \
+ qual type *qual *tqe_prev; /* address of previous next element */\
+}
+#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->tqh_first); \
+ (var); \
+ (var) = ((var)->field.tqe_next))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
+ (var); \
+ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define TAILQ_CONCAT(head1, head2, field) do { \
+ if (!TAILQ_EMPTY(head2)) { \
+ *(head1)->tqh_last = (head2)->tqh_first; \
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+ (head1)->tqh_last = (head2)->tqh_last; \
+ TAILQ_INIT((head2)); \
+ } \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define CIRCLEQ_HEAD(name, type) \
+struct name { \
+ struct type *cqh_first; /* first element */ \
+ struct type *cqh_last; /* last element */ \
+}
+
+#define CIRCLEQ_HEAD_INITIALIZER(head) \
+ { (void *)&head, (void *)&head }
+
+#define CIRCLEQ_ENTRY(type) \
+struct { \
+ struct type *cqe_next; /* next element */ \
+ struct type *cqe_prev; /* previous element */ \
+}
+
+/*
+ * Circular queue functions.
+ */
+#define CIRCLEQ_INIT(head) do { \
+ (head)->cqh_first = (void *)(head); \
+ (head)->cqh_last = (void *)(head); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \
+ (elm)->field.cqe_prev = (listelm); \
+ if ((listelm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \
+ (listelm)->field.cqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm); \
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
+ if ((listelm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \
+ (listelm)->field.cqe_prev = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.cqe_next = (head)->cqh_first; \
+ (elm)->field.cqe_prev = (void *)(head); \
+ if ((head)->cqh_last == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (head)->cqh_first->field.cqe_prev = (elm); \
+ (head)->cqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.cqe_next = (void *)(head); \
+ (elm)->field.cqe_prev = (head)->cqh_last; \
+ if ((head)->cqh_first == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (head)->cqh_last->field.cqe_next = (elm); \
+ (head)->cqh_last = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_REMOVE(head, elm, field) do { \
+ if ((elm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm)->field.cqe_prev; \
+ else \
+ (elm)->field.cqe_next->field.cqe_prev = \
+ (elm)->field.cqe_prev; \
+ if ((elm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm)->field.cqe_next; \
+ else \
+ (elm)->field.cqe_prev->field.cqe_next = \
+ (elm)->field.cqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->cqh_first); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_next))
+
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
+ for ((var) = ((head)->cqh_last); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
+ (((elm)->field.cqe_next == (void *)(head)) \
+ ? ((head)->cqh_first) \
+ : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field) \
+ (((elm)->field.cqe_prev == (void *)(head)) \
+ ? ((head)->cqh_last) \
+ : (elm->field.cqe_prev))
+
+#endif /* sys/queue.h */
diff --git a/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch b/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch
new file mode 100644
index 0000000..195c933
--- /dev/null
+++ b/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch
@@ -0,0 +1,154 @@
+From: Felix Fietkau <nbd@openwrt.org>
+Date: Wed, 8 Jul 2015 13:56:37 +0200
+Subject: [PATCH] Add PowerPC soft-float support
+
+Some PowerPC CPUs (e.g. Freescale MPC85xx) have a completely different
+instruction set for floating point operations (SPE).
+Executing regular PowerPC floating point instructions results in
+"Illegal instruction" errors.
+
+Make it possible to run these devices in soft-float mode.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+---
+ create mode 100644 src/fenv/powerpc-sf/fenv.sub
+ create mode 100644 src/setjmp/powerpc-sf/longjmp.s
+ create mode 100644 src/setjmp/powerpc-sf/longjmp.sub
+ create mode 100644 src/setjmp/powerpc-sf/setjmp.s
+ create mode 100644 src/setjmp/powerpc-sf/setjmp.sub
+
+--- a/arch/powerpc/reloc.h
++++ b/arch/powerpc/reloc.h
+@@ -1,4 +1,10 @@
+-#define LDSO_ARCH "powerpc"
++#ifdef _SOFT_FLOAT
++#define FP_SUFFIX "-sf"
++#else
++#define FP_SUFFIX ""
++#endif
++
++#define LDSO_ARCH "powerpc" FP_SUFFIX
+
+ #define TPOFF_K (-0x7000)
+
+--- a/configure
++++ b/configure
+@@ -538,6 +538,10 @@ trycppif "_MIPSEL || __MIPSEL || __MIPSE
+ trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf
+ fi
+
++if test "$ARCH" = "powerpc" ; then
++trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf
++fi
++
+ test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \
+ && SUBARCH=${SUBARCH}el
+
+--- /dev/null
++++ b/src/fenv/powerpc-sf/fenv.sub
+@@ -0,0 +1 @@
++../fenv.c
+--- /dev/null
++++ b/src/setjmp/powerpc-sf/longjmp.s
+@@ -0,0 +1,47 @@
++ .global _longjmp
++ .global longjmp
++ .type _longjmp,@function
++ .type longjmp,@function
++_longjmp:
++longjmp:
++# void longjmp(jmp_buf env, int val);
++# put val into return register and restore the env saved in setjmp
++# if val(r4) is 0, put 1 there.
++ # 0) move old return address into r0
++ lwz 0, 0(3)
++ # 1) put it into link reg
++ mtlr 0
++ #2 ) restore stack ptr
++ lwz 1, 4(3)
++ #3) restore control reg
++ lwz 0, 8(3)
++ mtcr 0
++ #4) restore r14-r31
++ lwz 14, 12(3)
++ lwz 15, 16(3)
++ lwz 16, 20(3)
++ lwz 17, 24(3)
++ lwz 18, 28(3)
++ lwz 19, 32(3)
++ lwz 20, 36(3)
++ lwz 21, 40(3)
++ lwz 22, 44(3)
++ lwz 23, 48(3)
++ lwz 24, 52(3)
++ lwz 25, 56(3)
++ lwz 26, 60(3)
++ lwz 27, 64(3)
++ lwz 28, 68(3)
++ lwz 29, 72(3)
++ lwz 30, 76(3)
++ lwz 31, 80(3)
++ #5) put val into return reg r3
++ mr 3, 4
++
++ #6) check if return value is 0, make it 1 in that case
++ cmpwi cr7, 4, 0
++ bne cr7, 1f
++ li 3, 1
++1:
++ blr
++
+--- /dev/null
++++ b/src/setjmp/powerpc-sf/longjmp.sub
+@@ -0,0 +1 @@
++longjmp.s
+--- /dev/null
++++ b/src/setjmp/powerpc-sf/setjmp.s
+@@ -0,0 +1,43 @@
++ .global ___setjmp
++ .hidden ___setjmp
++ .global __setjmp
++ .global _setjmp
++ .global setjmp
++ .type __setjmp,@function
++ .type _setjmp,@function
++ .type setjmp,@function
++___setjmp:
++__setjmp:
++_setjmp:
++setjmp:
++ # 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg)
++ mflr 0
++ stw 0, 0(3)
++ # 1) store reg1 (SP)
++ stw 1, 4(3)
++ # 2) store cr
++ mfcr 0
++ stw 0, 8(3)
++ # 3) store r14-31
++ stw 14, 12(3)
++ stw 15, 16(3)
++ stw 16, 20(3)
++ stw 17, 24(3)
++ stw 18, 28(3)
++ stw 19, 32(3)
++ stw 20, 36(3)
++ stw 21, 40(3)
++ stw 22, 44(3)
++ stw 23, 48(3)
++ stw 24, 52(3)
++ stw 25, 56(3)
++ stw 26, 60(3)
++ stw 27, 64(3)
++ stw 28, 68(3)
++ stw 29, 72(3)
++ stw 30, 76(3)
++ stw 31, 80(3)
++ # 4) set return value to 0
++ li 3, 0
++ # 5) return
++ blr
+--- /dev/null
++++ b/src/setjmp/powerpc-sf/setjmp.sub
+@@ -0,0 +1 @@
++setjmp.s
diff --git a/toolchain/musl/patches/020-upstream_open_memstream.patch b/toolchain/musl/patches/020-upstream_open_memstream.patch
new file mode 100644
index 0000000..3d14404
--- /dev/null
+++ b/toolchain/musl/patches/020-upstream_open_memstream.patch
@@ -0,0 +1,79 @@
+From 7b9f57f207b51132f188f750161953b7baf32154 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Thu, 8 Oct 2015 22:03:53 +0000
+Subject: fix open_[w]memstream behavior when no writes take place
+
+the specification for these functions requires that the buffer/size
+exposed to the caller be valid after any successful call to fflush or
+fclose on the stream. the implementation's approach is to update them
+only at flush time, but that misses the case where fflush or fclose is
+called without any writes having taken place, in which case the write
+flushing callback will not be called.
+
+to fix both the observable bug and the desired invariant, setup empty
+buffers at open time and fail the open operation if no memory is
+available.
+---
+ src/stdio/open_memstream.c | 11 +++++++++--
+ src/stdio/open_wmemstream.c | 11 +++++++++--
+ 2 files changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c
+index 58504c9..eab024d 100644
+--- a/src/stdio/open_memstream.c
++++ b/src/stdio/open_memstream.c
+@@ -59,14 +59,21 @@ FILE *open_memstream(char **bufp, size_t *sizep)
+ {
+ FILE *f;
+ struct cookie *c;
++ char *buf;
++
+ if (!(f=malloc(sizeof *f + sizeof *c + BUFSIZ))) return 0;
++ if (!(buf=malloc(sizeof *buf))) {
++ free(f);
++ return 0;
++ }
+ memset(f, 0, sizeof *f + sizeof *c);
+ f->cookie = c = (void *)(f+1);
+
+ c->bufp = bufp;
+ c->sizep = sizep;
+- c->pos = c->len = c->space = 0;
+- c->buf = 0;
++ c->pos = c->len = c->space = *sizep = 0;
++ c->buf = *bufp = buf;
++ *buf = 0;
+
+ f->flags = F_NORD;
+ f->fd = -1;
+diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c
+index 7ab2c64..4d90cd9 100644
+--- a/src/stdio/open_wmemstream.c
++++ b/src/stdio/open_wmemstream.c
+@@ -61,14 +61,21 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep)
+ {
+ FILE *f;
+ struct cookie *c;
++ wchar_t *buf;
++
+ if (!(f=malloc(sizeof *f + sizeof *c))) return 0;
++ if (!(buf=malloc(sizeof *buf))) {
++ free(f);
++ return 0;
++ }
+ memset(f, 0, sizeof *f + sizeof *c);
+ f->cookie = c = (void *)(f+1);
+
+ c->bufp = bufp;
+ c->sizep = sizep;
+- c->pos = c->len = c->space = 0;
+- c->buf = 0;
++ c->pos = c->len = c->space = *sizep = 0;
++ c->buf = *bufp = buf;
++ *buf = 0;
+
+ f->flags = F_NORD;
+ f->fd = -1;
+--
+cgit v0.11.2
+
diff --git a/toolchain/musl/patches/100-add_glob_onlydir.patch b/toolchain/musl/patches/100-add_glob_onlydir.patch
new file mode 100644
index 0000000..db0bc22
--- /dev/null
+++ b/toolchain/musl/patches/100-add_glob_onlydir.patch
@@ -0,0 +1,11 @@
+--- a/include/glob.h
++++ b/include/glob.h
+@@ -31,6 +31,8 @@ void globfree(glob_t *);
+ #define GLOB_NOESCAPE 0x40
+ #define GLOB_PERIOD 0x80
+
++#define GLOB_ONLYDIR 0x100
++
+ #define GLOB_NOSPACE 1
+ #define GLOB_ABORTED 2
+ #define GLOB_NOMATCH 3
diff --git a/toolchain/musl/patches/110-read_timezone_from_fs.patch b/toolchain/musl/patches/110-read_timezone_from_fs.patch
new file mode 100644
index 0000000..b4349e7
--- /dev/null
+++ b/toolchain/musl/patches/110-read_timezone_from_fs.patch
@@ -0,0 +1,28 @@
+--- a/src/time/__tz.c
++++ b/src/time/__tz.c
+@@ -23,6 +23,9 @@ static int r0[5], r1[5];
+ static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end;
+ static size_t map_size;
+
++static const char *tzfile;
++static size_t tzfile_size;
++
+ static char old_tz_buf[32];
+ static char *old_tz = old_tz_buf;
+ static size_t old_tz_size = sizeof old_tz_buf;
+@@ -125,6 +128,15 @@ static void do_tzset()
+ "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
+
+ s = getenv("TZ");
++
++ /* if TZ is empty try to read it from /etc/TZ */
++ if (!s || !*s) {
++ if (tzfile)
++ __munmap((void*)tzfile, tzfile_size);
++
++ s = tzfile = (void *)__map_file("/etc/TZ", &tzfile_size);
++ }
++
+ if (!s) s = "/etc/localtime";
+ if (!*s) s = __gmt;
+
diff --git a/toolchain/musl/patches/200-add_libssp_nonshared.patch b/toolchain/musl/patches/200-add_libssp_nonshared.patch
new file mode 100644
index 0000000..d0bf845
--- /dev/null
+++ b/toolchain/musl/patches/200-add_libssp_nonshared.patch
@@ -0,0 +1,50 @@
+From 7ec87fbbc3cac99b4173d082dd6195f47c9a32e7 Mon Sep 17 00:00:00 2001
+From: Steven Barth <steven@midlink.org>
+Date: Mon, 22 Jun 2015 11:01:56 +0200
+Subject: [PATCH] Add libssp_nonshared.a so GCC's is not needed
+
+Signed-off-by: Steven Barth <steven@midlink.org>
+---
+ Makefile | 10 ++++++++--
+ libssp_nonshared/__stack_chk_fail_local.c | 2 ++
+ 2 files changed, 10 insertions(+), 2 deletions(-)
+ create mode 100644 libssp_nonshared/__stack_chk_fail_local.c
+
+--- a/Makefile
++++ b/Makefile
+@@ -48,7 +48,7 @@ CRT_LIBS = lib/crt1.o lib/Scrt1.o lib/rc
+ STATIC_LIBS = lib/libc.a
+ SHARED_LIBS = lib/libc.so
+ TOOL_LIBS = lib/musl-gcc.specs
+-ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
++ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) lib/libssp_nonshared.a
+ ALL_TOOLS = tools/musl-gcc
+
+ WRAPCC_GCC = gcc
+@@ -106,7 +106,8 @@ NOSSP_SRCS = $(wildcard crt/*.c) \
+ src/env/__libc_start_main.c src/env/__init_tls.c \
+ src/thread/__set_thread_area.c src/env/__stack_chk_fail.c \
+ src/string/memset.c src/string/memcpy.c \
+- src/ldso/dlstart.c src/ldso/dynlink.c
++ src/ldso/dlstart.c src/ldso/dynlink.c \
++ libssp_nonshared/__stack_chk_fail_local.c
+ $(NOSSP_SRCS:%.c=%.o) $(NOSSP_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_NOSSP)
+
+ $(CRT_LIBS:lib/%=crt/%): CFLAGS += -DCRT
+@@ -155,6 +156,11 @@ lib/libc.a: $(OBJS)
+ $(AR) rc $@ $(OBJS)
+ $(RANLIB) $@
+
++lib/libssp_nonshared.a: libssp_nonshared/__stack_chk_fail_local.o
++ rm -f $@
++ $(AR) rc $@ $<
++ $(RANLIB) $@
++
+ $(EMPTY_LIBS):
+ rm -f $@
+ $(AR) rc $@
+--- /dev/null
++++ b/libssp_nonshared/__stack_chk_fail_local.c
+@@ -0,0 +1,2 @@
++#include "atomic.h"
++void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { a_crash(); }
diff --git a/toolchain/musl/patches/300-relative.patch b/toolchain/musl/patches/300-relative.patch
new file mode 100644
index 0000000..e2c22ba
--- /dev/null
+++ b/toolchain/musl/patches/300-relative.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -195,7 +195,7 @@ $(DESTDIR)$(includedir)/%: include/%
+ $(INSTALL) -D -m 644 $< $@
+
+ $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
+- $(INSTALL) -D -l $(libdir)/libc.so $@ || true
++ $(INSTALL) -D -l libc.so $@ || true
+
+ install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
+
diff --git a/toolchain/musl/patches/900-iconv_size_hack.patch b/toolchain/musl/patches/900-iconv_size_hack.patch
new file mode 100644
index 0000000..343915f
--- /dev/null
+++ b/toolchain/musl/patches/900-iconv_size_hack.patch
@@ -0,0 +1,68 @@
+--- a/src/locale/iconv.c
++++ b/src/locale/iconv.c
+@@ -39,6 +39,7 @@ static const unsigned char charmaps[] =
+ "ucs4\0ucs4be\0utf32\0utf32be\0\0\300"
+ "ucs4le\0utf32le\0\0\303"
+ "ascii\0usascii\0iso646\0iso646us\0\0\307"
++#ifdef FULL_ICONV
+ "eucjp\0\0\320"
+ "shiftjis\0sjis\0\0\321"
+ "gb18030\0\0\330"
+@@ -46,6 +47,7 @@ static const unsigned char charmaps[] =
+ "gb2312\0\0\332"
+ "big5\0bigfive\0cp950\0big5hkscs\0\0\340"
+ "euckr\0ksc5601\0ksx1001\0cp949\0\0\350"
++#endif
+ #include "codepages.h"
+ ;
+
+@@ -53,6 +55,7 @@ static const unsigned short legacy_chars
+ #include "legacychars.h"
+ };
+
++#ifdef FULL_ICONV
+ static const unsigned short jis0208[84][94] = {
+ #include "jis0208.h"
+ };
+@@ -72,6 +75,7 @@ static const unsigned short hkscs[] = {
+ static const unsigned short ksc[93][94] = {
+ #include "ksc.h"
+ };
++#endif
+
+ static int fuzzycmp(const unsigned char *a, const unsigned char *b)
+ {
+@@ -216,6 +220,7 @@ size_t iconv(iconv_t cd0, char **restric
+ c = ((c-0xd7c0)<<10) + (d-0xdc00);
+ }
+ break;
++#ifdef FULL_ICONV
+ case SHIFT_JIS:
+ if (c-0xa1 <= 0xdf-0xa1) {
+ c += 0xff61-0xa1;
+@@ -362,6 +367,7 @@ size_t iconv(iconv_t cd0, char **restric
+ c = ksc[c][d];
+ if (!c) goto ilseq;
+ break;
++#endif
+ default:
+ if (c < 128+type) break;
+ c -= 128+type;
+--- a/src/locale/codepages.h
++++ b/src/locale/codepages.h
+@@ -118,6 +118,7 @@
+ "\0\0\0\100\15\0\344\0\0\0\0\0\0\0\0\0\0\0\0\0\103\270\1\0\0\0\340\1\200\40"
+ "\230\0\0\0\0\0\44\341\12\0"
+
++#ifdef FULL_ICONV
+ "cp1250\0"
+ "windows1250\0"
+ "\0\0"
+@@ -214,6 +215,7 @@
+ "\0\0\0\0\0\0\0\0\0\15\0\0\0\0\0\0\0\0\0\0\266\0\0\0\0\102\0\220\13\0"
+ "\0\234\2\0\0\0\0\0\0\0\0\244\202\13\0\0\0\0\100\15\0\0\0\0\0\0\0\0\0\0"
+ "\267\0\0\0\0\103\0\240\13\0\0\240\2\0\0\0\0\0\0\0\0\250\62\45\0"
++#endif
+
+ "koi8r\0"
+ "\0\0"
diff --git a/toolchain/musl/patches/901-crypt_size_hack.patch b/toolchain/musl/patches/901-crypt_size_hack.patch
new file mode 100644
index 0000000..8cd7b19
--- /dev/null
+++ b/toolchain/musl/patches/901-crypt_size_hack.patch
@@ -0,0 +1,60 @@
+--- a/src/crypt/crypt_r.c
++++ b/src/crypt/crypt_r.c
+@@ -19,12 +19,6 @@ char *__crypt_r(const char *key, const c
+ if (salt[0] == '$' && salt[1] && salt[2]) {
+ if (salt[1] == '1' && salt[2] == '$')
+ return __crypt_md5(key, salt, output);
+- if (salt[1] == '2' && salt[3] == '$')
+- return __crypt_blowfish(key, salt, output);
+- if (salt[1] == '5' && salt[2] == '$')
+- return __crypt_sha256(key, salt, output);
+- if (salt[1] == '6' && salt[2] == '$')
+- return __crypt_sha512(key, salt, output);
+ }
+ return __crypt_des(key, salt, output);
+ }
+--- a/src/crypt/crypt_sha512.c
++++ b/src/crypt/crypt_sha512.c
+@@ -12,6 +12,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdint.h>
++#if 0
+
+ /* public domain sha512 implementation based on fips180-3 */
+ /* >=2^64 bits messages are not supported (about 2000 peta bytes) */
+@@ -369,3 +370,4 @@ char *__crypt_sha512(const char *key, co
+ return "*";
+ return p;
+ }
++#endif
+--- a/src/crypt/crypt_blowfish.c
++++ b/src/crypt/crypt_blowfish.c
+@@ -50,6 +50,7 @@
+ #include <string.h>
+ #include <stdint.h>
+
++#if 0
+ typedef uint32_t BF_word;
+ typedef int32_t BF_word_signed;
+
+@@ -796,3 +797,4 @@ char *__crypt_blowfish(const char *key,
+
+ return "*";
+ }
++#endif
+--- a/src/crypt/crypt_sha256.c
++++ b/src/crypt/crypt_sha256.c
+@@ -13,6 +13,7 @@
+ #include <string.h>
+ #include <stdint.h>
+
++#if 0
+ /* public domain sha256 implementation based on fips180-3 */
+
+ struct sha256 {
+@@ -320,3 +321,4 @@ char *__crypt_sha256(const char *key, co
+ return "*";
+ return p;
+ }
++#endif
diff --git a/toolchain/uClibc/Config.in b/toolchain/uClibc/Config.in
new file mode 100644
index 0000000..5793bb7
--- /dev/null
+++ b/toolchain/uClibc/Config.in
@@ -0,0 +1,6 @@
+# Debug version.
+
+config UCLIBC_ENABLE_DEBUG
+ bool "Build with debug information"
+ depends on TOOLCHAINOPTS && USE_UCLIBC
+ default n
diff --git a/toolchain/uClibc/Config.version b/toolchain/uClibc/Config.version
new file mode 100644
index 0000000..7804da4
--- /dev/null
+++ b/toolchain/uClibc/Config.version
@@ -0,0 +1,9 @@
+config UCLIBC_VERSION
+ string
+ depends on USE_UCLIBC
+ default "1.0.8"
+
+config UCLIBC_VERSION_NG
+ bool
+ depends on USE_UCLIBC
+ default y
diff --git a/toolchain/uClibc/Makefile b/toolchain/uClibc/Makefile
new file mode 100644
index 0000000..a5fb54b
--- /dev/null
+++ b/toolchain/uClibc/Makefile
@@ -0,0 +1,41 @@
+PATH_PREFIX=.
+
+include ./common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
+
+HOST_BUILD_PARALLEL:=1
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Compile
+ $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
+ $(UCLIBC_MAKE) PREFIX= all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
+ $(CP) $(HOST_BUILD_DIR)/libc/libc_so.a $(TOOLCHAIN_DIR)/lib/
+ $(CP) $(HOST_BUILD_DIR)/libpthread/*/libpthread_so.a $(TOOLCHAIN_DIR)/lib/
+ ( cd $(TOOLCHAIN_DIR) ; \
+ for d in lib usr/lib ; do \
+ for f in libc.so libpthread.so libgcc_s.so ; do \
+ if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
+ $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
+ fi \
+ done \
+ done \
+ )
+ rm -f \
+ $(TOOLCHAIN_DIR)/lib/libresolv*.so* \
+ $(TOOLCHAIN_DIR)/lib/libnsl*.so*
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/uClibc/common.mk b/toolchain/uClibc/common.mk
new file mode 100644
index 0000000..895022c
--- /dev/null
+++ b/toolchain/uClibc/common.mk
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
+
+PKG_NAME:=uClibc-ng
+PKG_SOURCE_URL = http://downloads.uclibc-ng.org/releases/$(PKG_VERSION)/
+PATCH_DIR:=$(PATH_PREFIX)/patches
+CONFIG_DIR:=$(PATH_PREFIX)/config
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+LIBC_SO_VERSION:=$(PKG_VERSION)
+
+PKG_MD5SUM=d7dbc8ddb0274beacbb48e6928d7b097
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh64/sh/' \
+ -e 's/sh[234].*/sh/' \
+ -e 's/mips.*/mips/' \
+ -e 's/mipsel.*/mips/' \
+)
+
+GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
+ $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
+ $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
+ $(CONFIG_DIR)/$(ARCH)$(strip \
+ $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
+ $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
+ $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500)))))
+
+CPU_CFLAGS = \
+ -funsigned-char -fno-builtin -fno-asm \
+ --std=gnu99 -ffunction-sections -fdata-sections \
+ -Wno-unused-but-set-variable \
+ $(TARGET_CFLAGS) -ggdb
+
+UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ DEVEL_PREFIX=/ \
+ RUNTIME_PREFIX=/ \
+ HOSTCC="$(HOSTCC)" \
+ CPU_CFLAGS="$(CPU_CFLAGS)" \
+ ARCH="$(CONFIG_ARCH)" \
+ LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
+ DOSTRIP=""
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ $(if $(strip $(QUILT)), \
+ cd $(HOST_BUILD_DIR); \
+ if $(QUILT_CMD) next >/dev/null 2>&1; then \
+ $(QUILT_CMD) push -a; \
+ fi
+ )
+ ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+define Host/Configure
+ $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
+ $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
+ -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
+ -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
+ -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \
+ $(HOST_BUILD_DIR)/.config.new
+ cmp -s $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last || { \
+ cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config && \
+ $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
+ $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
+ cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last; \
+ }
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
+endef
diff --git a/toolchain/uClibc/config/arm b/toolchain/uClibc/config/arm
new file mode 100644
index 0000000..41a60b1
--- /dev/null
+++ b/toolchain/uClibc/config/arm
@@ -0,0 +1,9 @@
+ARCH_ANY_ENDIAN=y
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# COMPILE_IN_THUMB_MODE is not set
+TARGET_ARCH="arm"
+TARGET_arm=y
+# USE_BX is not set
+CONFIG_ARM_EABI=y
+
diff --git a/toolchain/uClibc/config/armeb b/toolchain/uClibc/config/armeb
new file mode 100644
index 0000000..2e46dd6
--- /dev/null
+++ b/toolchain/uClibc/config/armeb
@@ -0,0 +1,9 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_WANTS_BIG_ENDIAN=y
+# COMPILE_IN_THUMB_MODE is not set
+TARGET_ARCH="arm"
+TARGET_arm=y
+# USE_BX is not set
+CONFIG_ARM_EABI=y
+
diff --git a/toolchain/uClibc/config/common b/toolchain/uClibc/config/common
new file mode 100644
index 0000000..ec72701
--- /dev/null
+++ b/toolchain/uClibc/config/common
@@ -0,0 +1,225 @@
+# ARCH_ANY_ENDIAN is not set
+ARCH_HAS_MMU=y
+# ARCH_HAS_NO_LDSO is not set
+# ARCH_HAS_NO_SHARED is not set
+# ARCH_LITTLE_ENDIAN is not set
+ARCH_USE_MMU=y
+# ARCH_WANTS_BIG_ENDIAN is not set
+# ARCH_WANTS_LITTLE_ENDIAN is not set
+ASSUME_DEVPTS=y
+# COMPAT_ATEXIT is not set
+CROSS_COMPILER_PREFIX=""
+DEVEL_PREFIX="/usr/"
+# DOASSERTS is not set
+# DODEBUG is not set
+# DODEBUG_PT is not set
+# DOMULTI is not set
+DOPIC=y
+DOSTRIP=y
+DO_C99_MATH=y
+# DO_XSI_MATH is not set
+# EXTRA_WARNINGS is not set
+FORCE_OPTIONS_FOR_ARCH=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+# HARDWIRED_ABSPATH is not set
+# HAS_NO_THREADS is not set
+HAVE_DOT_CONFIG=y
+# HAVE_NO_PIC is not set
+# HAVE_NO_SSP is not set
+HAVE_SHARED=y
+KERNEL_HEADERS="."
+LDSO_BASE_FILENAME="ld.so"
+LDSO_CACHE_SUPPORT=y
+# LDSO_GNU_HASH_SUPPORT is not set
+LDSO_LD_LIBRARY_PATH=y
+LDSO_LDD_SUPPORT=y
+# LDSO_NO_CLEANUP is not set
+# LDSO_PRELINK_SUPPORT is not set
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_PRELOAD_ENV_SUPPORT=y
+LDSO_RUNPATH=y
+LDSO_SAFE_RUNPATH=y
+# LDSO_RUNPATH_OF_EXECUTABLE is not set
+# LDSO_SEARCH_INTERP_PATH is not set
+# LDSO_STANDALONE_SUPPORT is not set
+# LINUXTHREADS_NEW is not set
+# LINUXTHREADS_OLD is not set
+# UCLIBC_HAS_BACKTRACE is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+# MALLOC is not set
+MALLOC_GLIBC_COMPAT=y
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MULTILIB_DIR="lib"
+PTHREADS_DEBUG_SUPPORT=y
+RUNTIME_PREFIX="/"
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+TARGET_SUBARCH=""
+# TARGET_alpha is not set
+# TARGET_arc is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_c6x is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_ia64 is not set
+# TARGET_lm32 is not set
+# TARGET_m68k is not set
+# TARGET_metag is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_or1k is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_vax is not set
+# TARGET_x86_64 is not set
+# TARGET_xtensa is not set
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_BUILD_NOEXECSTACK=y
+# UCLIBC_BUILD_NOW is not set
+# UCLIBC_BUILD_PIE is not set
+UCLIBC_BUILD_RELRO=y
+UCLIBC_CTOR_DTOR=y
+UCLIBC_DYNAMIC_ATEXIT=y
+UCLIBC_EXTRA_CFLAGS=""
+UCLIBC_GRP_BUFFER_SIZE=256
+UCLIBC_HAS_ADVANCED_REALTIME=y
+# UCLIBC_HAS_ARC4RANDOM is not set
+UCLIBC_HAS_BSD_ERR=y
+UCLIBC_HAS_BSD_RES_CLOSE=y
+# UCLIBC_HAS_COMPAT_RES_STATE is not set
+UCLIBC_HAS_CRYPT=y
+UCLIBC_HAS_CRYPT_IMPL=y
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_CTYPE_SIGNED=y
+UCLIBC_HAS_CTYPE_TABLES=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_EPOLL=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
+# UCLIBC_HAS_FENV is not set
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+# UCLIBC_HAS_FPU is not set
+UCLIBC_HAS_FTS=y
+UCLIBC_HAS_FTW=y
+# UCLIBC_HAS_FULL_RPC is not set
+UCLIBC_HAS_GETPT=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+# UCLIBC_HAS_GLIBC_DIGIT_GROUPING is not set
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_ERROR=y
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+UCLIBC_HAS_GNU_GLOB=y
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_IPV4=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_LFS=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBUTIL=y
+# UCLIBC_HAS_LOCALE is not set
+# UCLIBC_BUILD_ALL_LOCALE is not set
+# UCLIBC_BUILD_MINIMAL_LOCALE is not set
+# UCLIBC_PREGENERATED_LOCALE_DATA is not set
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
+UCLIBC_HAS_NETWORK_SUPPORT=y
+UCLIBC_HAS_NFTW=y
+# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set
+# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
+UCLIBC_HAS_PRINTF_M_SPEC=y
+# UCLIBC_HAS_PROFILING is not set
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_PTY=y
+UCLIBC_HAS_REALTIME=y
+# UCLIBC_HAS_REENTRANT_RPC is not set
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+# UCLIBC_HAS_RPC is not set
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_SHA256_CRYPT_IMPL is not set
+# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
+UCLIBC_HAS_SHADOW=y
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+UCLIBC_HAS_SOCKET=y
+UCLIBC_HAS_SOFT_FLOAT=y
+# UCLIBC_HAS_SSP is not set
+# UCLIBC_HAS_SSP_COMPAT is not set
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+# UCLIBC_HAS_STUBS is not set
+UCLIBC_HAS_SYSLOG=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_THREADS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_HAS_WCHAR=y
+UCLIBC_HAS_WORDEXP=y
+UCLIBC_HAS_XATTR=y
+# UCLIBC_HAS_XLOCALE is not set
+UCLIBC_HAS___PROGNAME=y
+# UCLIBC_LINUX_MODULE_24 is not set
+UCLIBC_LINUX_MODULE_26=y
+UCLIBC_LINUX_SPECIFIC=y
+# UCLIBC_MALLOC_DEBUGGING is not set
+# UCLIBC_MJN3_ONLY is not set
+# UCLIBC_NTP_LEGACY is not set
+# USE_OLD_VFPRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_PWD_BUFFER_SIZE=256
+# UCLIBC_STATIC_LDCONFIG is not set
+# UCLIBC_STRICT_HEADERS is not set
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV3_LEGACY_MACROS=y
+UCLIBC_SUSV4_LEGACY=y
+# UCLIBC_SV4_DEPRECATED is not set
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+# UCLIBC_FALLBACK_TO_ETC_LOCALTIME is not set
+UCLIBC_USE_NETLINK=y
+# UNIX98PTY_ONLY is not set
+USE_BX=y
+WARNINGS="-Wall"
+# UCLIBC_HAS_OBSTACK is not set
+# UCLIBC_SUSV2_LEGACY is not set
+# UCLIBC_HAS_CONTEXT_FUNCS is not set
+UCLIBC_HAS_GETOPT_LONG=y
diff --git a/toolchain/uClibc/config/debug b/toolchain/uClibc/config/debug
new file mode 100644
index 0000000..b366e66
--- /dev/null
+++ b/toolchain/uClibc/config/debug
@@ -0,0 +1,6 @@
+DODEBUG=y
+DODEBUG_PT=y
+PTHREADS_DEBUG_SUPPORT=y
+SUPPORT_LD_DEBUG=y
+SUPPORT_LD_DEBUG_EARLY=y
+UCLIBC_MALLOC_DEBUGGING=y
diff --git a/toolchain/uClibc/config/i386 b/toolchain/uClibc/config/i386
new file mode 100644
index 0000000..5ef264c
--- /dev/null
+++ b/toolchain/uClibc/config/i386
@@ -0,0 +1,21 @@
+ARCH_LITTLE_ENDIAN=y
+# CONFIG_386 is not set
+CONFIG_486=y
+# CONFIG_586 is not set
+# CONFIG_586MMX is not set
+# CONFIG_686 is not set
+# CONFIG_CRUSOE is not set
+# CONFIG_CYRIXIII is not set
+# CONFIG_ELAN is not set
+# CONFIG_GENERIC_386 is not set
+# CONFIG_K6 is not set
+# CONFIG_K7 is not set
+# CONFIG_NEHEMIAH is not set
+# CONFIG_PENTIUM4 is not set
+# CONFIG_PENTIUMII is not set
+# CONFIG_PENTIUMIII is not set
+# CONFIG_WINCHIP2 is not set
+# CONFIG_WINCHIPC6 is not set
+TARGET_ARCH="i386"
+TARGET_i386=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/i686 b/toolchain/uClibc/config/i686
new file mode 100644
index 0000000..ba615f6
--- /dev/null
+++ b/toolchain/uClibc/config/i686
@@ -0,0 +1,21 @@
+ARCH_LITTLE_ENDIAN=y
+# CONFIG_386 is not set
+# CONFIG_486 is not set
+# CONFIG_586 is not set
+# CONFIG_586MMX is not set
+CONFIG_686=y
+# CONFIG_CRUSOE is not set
+# CONFIG_CYRIXIII is not set
+# CONFIG_ELAN is not set
+# CONFIG_GENERIC_386 is not set
+# CONFIG_K6 is not set
+# CONFIG_K7 is not set
+# CONFIG_NEHEMIAH is not set
+# CONFIG_PENTIUM4 is not set
+# CONFIG_PENTIUMII is not set
+# CONFIG_PENTIUMIII is not set
+# CONFIG_WINCHIP2 is not set
+# CONFIG_WINCHIPC6 is not set
+TARGET_ARCH="i386"
+TARGET_i386=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/m68k b/toolchain/uClibc/config/m68k
new file mode 100644
index 0000000..14ce5ae
--- /dev/null
+++ b/toolchain/uClibc/config/m68k
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+LINUXTHREADS_OLD=y
+TARGET_ARCH="m68k"
+TARGET_SUBARCH=""
+TARGET_m68k=y
+# UCLIBC_HAS_THREADS_NATIVE is not set
diff --git a/toolchain/uClibc/config/mips b/toolchain/uClibc/config/mips
new file mode 100644
index 0000000..8cec22f
--- /dev/null
+++ b/toolchain/uClibc/config/mips
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+CONFIG_MIPS_ISA_MIPS32=y
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64 b/toolchain/uClibc/config/mips64
new file mode 100644
index 0000000..566d87a
--- /dev/null
+++ b/toolchain/uClibc/config/mips64
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64.32 b/toolchain/uClibc/config/mips64.32
new file mode 100644
index 0000000..b7ea8f4
--- /dev/null
+++ b/toolchain/uClibc/config/mips64.32
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64.64 b/toolchain/uClibc/config/mips64.64
new file mode 100644
index 0000000..2a0b755
--- /dev/null
+++ b/toolchain/uClibc/config/mips64.64
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64.n32 b/toolchain/uClibc/config/mips64.n32
new file mode 100644
index 0000000..f8def58
--- /dev/null
+++ b/toolchain/uClibc/config/mips64.n32
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+CONFIG_MIPS_N32_ABI=y
+# CONFIG_MIPS_N64_ABI is not set
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64el b/toolchain/uClibc/config/mips64el
new file mode 100644
index 0000000..5358078
--- /dev/null
+++ b/toolchain/uClibc/config/mips64el
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64el.32 b/toolchain/uClibc/config/mips64el.32
new file mode 100644
index 0000000..a10840b
--- /dev/null
+++ b/toolchain/uClibc/config/mips64el.32
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64el.64 b/toolchain/uClibc/config/mips64el.64
new file mode 100644
index 0000000..8b90a54
--- /dev/null
+++ b/toolchain/uClibc/config/mips64el.64
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mips64el.n32 b/toolchain/uClibc/config/mips64el.n32
new file mode 100644
index 0000000..4ac4d06
--- /dev/null
+++ b/toolchain/uClibc/config/mips64el.n32
@@ -0,0 +1,19 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+CONFIG_MIPS_N32_ABI=y
+# CONFIG_MIPS_N64_ABI is not set
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mipsel b/toolchain/uClibc/config/mipsel
new file mode 100644
index 0000000..d9dedbb
--- /dev/null
+++ b/toolchain/uClibc/config/mipsel
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+CONFIG_MIPS_ISA_MIPS32=y
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/mipsel.cobalt b/toolchain/uClibc/config/mipsel.cobalt
new file mode 100644
index 0000000..1d42a70
--- /dev/null
+++ b/toolchain/uClibc/config/mipsel.cobalt
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+CONFIG_MIPS_ISA_3=y
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_ISA_MIPS64R2 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config/powerpc b/toolchain/uClibc/config/powerpc
new file mode 100644
index 0000000..5b1292d
--- /dev/null
+++ b/toolchain/uClibc/config/powerpc
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+CONFIG_CLASSIC=y
+# CONFIG_E500 is not set
+TARGET_ARCH="powerpc"
+TARGET_SUBARCH="classic"
+TARGET_powerpc=y
diff --git a/toolchain/uClibc/config/powerpc.e500 b/toolchain/uClibc/config/powerpc.e500
new file mode 100644
index 0000000..a835c3d
--- /dev/null
+++ b/toolchain/uClibc/config/powerpc.e500
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_CLASSIC is not set
+CONFIG_E500=y
+TARGET_ARCH="powerpc"
+TARGET_SUBARCH="classic"
+TARGET_powerpc=y
diff --git a/toolchain/uClibc/config/sparc b/toolchain/uClibc/config/sparc
new file mode 100644
index 0000000..e1596c4
--- /dev/null
+++ b/toolchain/uClibc/config/sparc
@@ -0,0 +1,8 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_SPARC_V7 is not set
+# CONFIG_SPARC_V8 is not set
+CONFIG_SPARC_V9=y
+# CONFIG_SPARC_V9B is not set
+TARGET_ARCH="sparc"
+TARGET_sparc=y
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
diff --git a/toolchain/uClibc/config/sparc.leon b/toolchain/uClibc/config/sparc.leon
new file mode 100644
index 0000000..eb725ac
--- /dev/null
+++ b/toolchain/uClibc/config/sparc.leon
@@ -0,0 +1,8 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_SPARC_V7 is not set
+CONFIG_SPARC_V8=y
+# CONFIG_SPARC_V9 is not set
+# CONFIG_SPARC_V9B is not set
+TARGET_ARCH="sparc"
+TARGET_sparc=y
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
diff --git a/toolchain/uClibc/config/x86_64 b/toolchain/uClibc/config/x86_64
new file mode 100644
index 0000000..b6dc2c2
--- /dev/null
+++ b/toolchain/uClibc/config/x86_64
@@ -0,0 +1,6 @@
+ARCH_LITTLE_ENDIAN=y
+# LINUXTHREADS_NEW is not set
+TARGET_ARCH="x86_64"
+TARGET_x86_64=y
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/headers/Makefile b/toolchain/uClibc/headers/Makefile
new file mode 100644
index 0000000..67a2d95
--- /dev/null
+++ b/toolchain/uClibc/headers/Makefile
@@ -0,0 +1,26 @@
+PATH_PREFIX:=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
+ PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
+ DEVEL_PREFIX=/ \
+ RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
+ HOSTCC="$(HOSTCC)" \
+ CC="$(TARGET_CC)" \
+ CPU_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(CONFIG_ARCH)" \
+ pregen \
+ install_headers
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/uClibc/utils/Makefile b/toolchain/uClibc/utils/Makefile
new file mode 100644
index 0000000..83100d7
--- /dev/null
+++ b/toolchain/uClibc/utils/Makefile
@@ -0,0 +1,24 @@
+PATH_PREFIX=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.utils_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_utils_installed
+
+define Host/Compile
+ $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
+ $(UCLIBC_MAKE) PREFIX= utils
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) \
+ $(HOST_BUILD_DIR)/utils/ldd \
+ $(TOOLCHAIN_DIR)/bin/
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
+ $(INSTALL_BIN) \
+ $(HOST_BUILD_DIR)/utils/ldconfig \
+ $(TOOLCHAIN_DIR)/sbin/
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/wrapper/Makefile b/toolchain/wrapper/Makefile
new file mode 100644
index 0000000..3398e40
--- /dev/null
+++ b/toolchain/wrapper/Makefile
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=wrapper
+PKG_VERSION:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+
+# 1: args
+define toolchain_util
+$(strip $(SCRIPT_DIR)/ext-toolchain.sh --toolchain $(CONFIG_TOOLCHAIN_ROOT) \
+ --cflags $(CONFIG_TARGET_OPTIMIZATION) \
+ --cflags "$(if $(call qstrip,$(CONFIG_TOOLCHAIN_LIBC)),-m$(call qstrip,$(CONFIG_TOOLCHAIN_LIBC))) $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
+ --cflags "$(patsubst ./%,-I$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))" \
+ --cflags "$(patsubst ./%,-L$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))" \
+ $(1))
+endef
+
+# 1: config symbol
+# 2: feature
+define toolchain_test
+$$(if $$($(1)), \
+ @echo -n "Testing external toolchain for $(2) support ... "; \
+ if $(call toolchain_util,--test "$(2)"); then \
+ echo "ok"; exit 0; \
+ else \
+ echo "failed"; \
+ echo "ERROR: $(1) is enabled but the external toolchain does not support it"; \
+ exit 1; \
+ fi)
+endef
+
+
+define Host/Prepare
+ $(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
+ $(call toolchain_test,CONFIG_IPV6,ipv6)
+ $(call toolchain_test,CONFIG_NLS,wchar)
+ $(call toolchain_test,CONFIG_PACKAGE_libpthread,threads)
+endef
+
+define Host/Configure
+endef
+
+define Host/Compile
+endef
+
+define Host/Install
+ $(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
+endef
+
+define Host/Clean
+ rm -rf $(TOOLCHAIN_DIR)/bin
+endef
+
+$(eval $(call HostBuild))