This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See crosstool-NG for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/4] [libc/musl] Add musl-libc support


Bryan, All,

On 2014-07-31 19:01 -0700, Bryan Hundven spake thusly:
> This patch adds initial support for musl-libc.

Applied, with those changes discussed on IRC:
  - gcc musl patch has issues, so removed; we can add it back later,
  - do_get_arch() is dead code for now, dropped.

Thank you! :-)

Regards,
Yann E. MORIN.

> Musl-libc versions currently supported:
> * 1.0.3 (Stable)
> * 1.1.3 (Previous Mainline)
> * 1.1.4 (Mainline)
> 
> Futher improvements are needed.
> * gcc-4.9.x has issues (Might be fixed in musl-1.1.4).
> * Multilib support is needed.
> * Checks to make sure paths are correct.
> * Move to 2-step gcc build. 3-step build is not necessary.
> 
> Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> ---
>  config/libc/musl.in                                |  49 ++
>  patches/experimental/gcc/4.6.0/0001-musl.patch     | 304 +++++++++
>  patches/experimental/gcc/4.8.0/0001-musl.patch     | 401 +++++++++++
>  patches/experimental/gcc/4.8.1/0001-musl.patch     | 626 +++++++++++++++++
>  patches/experimental/gcc/4.8.2/0001-musl.patch     | 750 +++++++++++++++++++++
>  patches/experimental/gcc/4.8.3/0001-musl.patch     | 736 ++++++++++++++++++++
>  patches/experimental/gcc/4.9.0/0001-musl.patch     | 706 +++++++++++++++++++
>  .../musl/1.0.3/0001-fix_linker_regression.patch    |  64 ++
>  .../1.0.3/0002-fix_mips_linker_regression.patch    |  88 +++
>  .../musl/1.1.3/0001-fix_linker_regression.patch    |  64 ++
>  .../1.1.3/0002-fix_mips_linker_regression.patch    |  88 +++
>  scripts/build/arch/arm.sh                          |   1 +
>  scripts/build/libc/musl.sh                         | 128 ++++
>  scripts/functions                                  |   1 +
>  14 files changed, 4006 insertions(+)
>  create mode 100644 config/libc/musl.in
>  create mode 100644 patches/experimental/gcc/4.6.0/0001-musl.patch
>  create mode 100644 patches/experimental/gcc/4.8.0/0001-musl.patch
>  create mode 100644 patches/experimental/gcc/4.8.1/0001-musl.patch
>  create mode 100644 patches/experimental/gcc/4.8.2/0001-musl.patch
>  create mode 100644 patches/experimental/gcc/4.8.3/0001-musl.patch
>  create mode 100644 patches/experimental/gcc/4.9.0/0001-musl.patch
>  create mode 100644 patches/musl/1.0.3/0001-fix_linker_regression.patch
>  create mode 100644 patches/musl/1.0.3/0002-fix_mips_linker_regression.patch
>  create mode 100644 patches/musl/1.1.3/0001-fix_linker_regression.patch
>  create mode 100644 patches/musl/1.1.3/0002-fix_mips_linker_regression.patch
>  create mode 100644 scripts/build/libc/musl.sh
> 
> diff --git a/config/libc/musl.in b/config/libc/musl.in
> new file mode 100644
> index 0000000..7bab480
> --- /dev/null
> +++ b/config/libc/musl.in
> @@ -0,0 +1,49 @@
> +# musl options
> +
> +## depends on ! WINDOWS && ! BARE_METAL
> +##
> +## select LIBC_SUPPORT_THREADS_NATIVE
> +## select CC_CORE_PASSES_NEEDED
> +##
> +## help Musl is a new standard library to power a new generation of Linux-based
> +## help devices. musl is lightweight, fast, simple, free, and strives to be
> +## help correct in the sense of standards-conformance and safety.
> +
> +config THREADS
> +    default "musl"
> +
> +choice
> +    bool
> +    prompt "musl version"
> +# Don't remove next line
> +# CT_INSERT_VERSION_BELOW
> +
> +config LIBC_MUSL_V_1_1_4
> +    bool
> +    prompt "1.1.4 (Mainline)"
> +    depends on EXPERIMENTAL
> +
> +config LIBC_MUSL_V_1_1_3
> +    bool
> +    prompt "1.1.3"
> +    depends on EXPERIMENTAL
> +
> +config LIBC_MUSL_V_1_0_3
> +    bool
> +    prompt "1.0.3 (Stable)"
> +
> +config LIBC_MUSL_V_CUSTOM
> +    bool
> +    prompt "Custom musl"
> +    depends on EXPERIMENTAL
> +
> +endchoice
> +
> +config LIBC_VERSION
> +    string
> +# Don't remove next line
> +# CT_INSERT_VERSION_STRING_BELOW
> +    default "1.1.4" if LIBC_MUSL_V_1_1_4
> +    default "1.1.3" if LIBC_MUSL_V_1_1_3
> +    default "1.0.3" if LIBC_MUSL_V_1_0_3
> +    default "custom" if LIBC_MUSL_V_CUSTOM
> diff --git a/patches/experimental/gcc/4.6.0/0001-musl.patch b/patches/experimental/gcc/4.6.0/0001-musl.patch
> new file mode 100644
> index 0000000..b0b6c4b
> --- /dev/null
> +++ b/patches/experimental/gcc/4.6.0/0001-musl.patch
> @@ -0,0 +1,304 @@
> +diff --git a/patches/experimental/gcc/4.6.0/0001-musl.patch b/patches/experimental/gcc/4.6.0/0001-musl.patch
> +new file mode 100644
> +index 0000000..cee9948
> +--- /dev/null
> ++++ b/patches/experimental/gcc/4.6.0/0001-musl.patch
> +@@ -0,0 +1,231 @@
> ++diff --git a/config.sub b/config.sub
> ++--- 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* | \
> ++@@ -1310,6 +1311,7 @@ case $os in
> ++ 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
> ++ 	      | -mingw32* | -linux-gnu* | -linux-android* \
> ++ 	      | -linux-newlib* | -linux-uclibc* \
> +++	      | -linux-musl* \
> ++ 	      | -uxpv* | -beos* | -mpeix* | -udk* \
> ++ 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
> ++ 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
> ++diff --git a/gcc/config.gcc b/gcc/config.gcc
> ++--- a/gcc/config.gcc
> +++++ b/gcc/config.gcc
> ++@@ -478,7 +478,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
> ++@@ -591,6 +591,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"
> ++       ;;
> ++diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
> ++--- a/gcc/config/arm/linux-eabi.h
> +++++ b/gcc/config/arm/linux-eabi.h
> ++@@ -64,6 +64,10 @@
> ++ #undef  GLIBC_DYNAMIC_LINKER
> ++ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
> ++ 
> +++/* 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
> ++diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
> ++--- a/gcc/config/i386/linux.h
> +++++ b/gcc/config/i386/linux.h
> ++@@ -93,6 +93,7 @@ along with GCC; see the file COPYING3.  If not see
> ++ /* 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 \
> ++diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
> ++--- a/gcc/config/i386/linux64.h
> +++++ b/gcc/config/i386/linux64.h
> ++@@ -65,6 +65,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> ++ #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"
> ++diff --git a/gcc/config/linux.h b/gcc/config/linux.h
> ++--- a/gcc/config/linux.h
> +++++ b/gcc/config/linux.h
> ++@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> ++ #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.RUNTIME respectively.  If not, see
> ++    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.RUNTIME respectively.  If not, see
> ++ 
> ++ #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.  */
> ++diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
> ++--- 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
> ++diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
> ++--- a/gcc/config/mips/linux.h
> +++++ b/gcc/config/mips/linux.h
> ++@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3.  If not see
> ++ 
> ++ #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 \
> ++diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
> ++--- 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 */
> ++diff --git a/libgomp/config/posix/time.c b/libgomp/config/posix/time.c
> ++--- 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/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
> ++--- 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"
> ++     ;;
> +diff --git a/patches/experimental/musl/1.1.3/0001-add_missing_signal_limits.patch b/patches/experimental/musl/1.1.3/0001-add_missing_signal_limits.patch
> +new file mode 100644
> +index 0000000..e28232d
> +--- /dev/null
> ++++ b/patches/experimental/musl/1.1.3/0001-add_missing_signal_limits.patch
> +@@ -0,0 +1,12 @@
> ++--- musl-1.1.3.orig/include/signal.h	2014-07-27 20:24:56.194773074 +0300
> +++++ musl-1.1.3/include/signal.h	2014-07-27 21:27:32.108772419 +0300
> ++@@ -246,6 +246,9 @@ typedef int sig_atomic_t;
> ++ void (*signal(int, void (*)(int)))(int);
> ++ int raise(int);
> ++ 
> +++#define __SIGRTMIN      32
> +++#define __SIGRTMAX      (_NSIG - 1)
> +++
> ++ #ifdef __cplusplus
> ++ }
> ++ #endif
> +diff --git a/patches/experimental/musl/1.1.3/0002-add_missing_ISbit_defs.patch b/patches/experimental/musl/1.1.3/0002-add_missing_ISbit_defs.patch
> +new file mode 100644
> +index 0000000..a166cb5
> +--- /dev/null
> ++++ b/patches/experimental/musl/1.1.3/0002-add_missing_ISbit_defs.patch
> +@@ -0,0 +1,43 @@
> ++diff -Nupr musl-1.1.3.orig/include/ctype.h musl-1.1.3/include/ctype.h
> ++--- musl-1.1.3.orig/include/ctype.h	2014-07-30 10:06:03.630712195 +0300
> +++++ musl-1.1.3/include/ctype.h	2014-07-30 10:06:51.238713586 +0300
> ++@@ -7,6 +7,39 @@ extern "C" {
> ++ 
> ++ #include <features.h>
> ++ 
> +++#ifndef _ISbit
> +++/* These are all the characteristics of characters.
> +++   If there get to be more than 16 distinct characteristics,
> +++   many things must be changed that use `unsigned short int's.
> +++
> +++   The characteristics are stored always in network byte order (big
> +++   endian).  We define the bit value interpretations here dependent on the
> +++   machine's byte order.  */
> +++
> +++# include <endian.h>
> +++# if __BYTE_ORDER == __BIG_ENDIAN
> +++#  define _ISbit(bit)   (1 << (bit))
> +++# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
> +++#  define _ISbit(bit)   ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
> +++# endif
> +++
> +++enum
> +++{
> +++  _ISupper = _ISbit (0),        /* UPPERCASE.  */
> +++  _ISlower = _ISbit (1),        /* lowercase.  */
> +++  _ISalpha = _ISbit (2),        /* Alphabetic.  */
> +++  _ISdigit = _ISbit (3),        /* Numeric.  */
> +++  _ISxdigit = _ISbit (4),       /* Hexadecimal numeric.  */
> +++  _ISspace = _ISbit (5),        /* Whitespace.  */
> +++  _ISprint = _ISbit (6),        /* Printing.  */
> +++  _ISgraph = _ISbit (7),        /* Graphical.  */
> +++  _ISblank = _ISbit (8),        /* Blank (usually SPC and TAB).  */
> +++  _IScntrl = _ISbit (9),        /* Control character.  */
> +++  _ISpunct = _ISbit (10),       /* Punctuation.  */
> +++  _ISalnum = _ISbit (11)        /* Alphanumeric.  */
> +++};
> +++#endif /* ! _ISbit  */
> +++
> ++ int   isalnum(int);
> ++ int   isalpha(int);
> ++ int   isblank(int);
> diff --git a/patches/experimental/gcc/4.8.0/0001-musl.patch b/patches/experimental/gcc/4.8.0/0001-musl.patch
> new file mode 100644
> index 0000000..e250298
> --- /dev/null
> +++ b/patches/experimental/gcc/4.8.0/0001-musl.patch
> @@ -0,0 +1,401 @@
> +This patch enables support for musl-libc in gcc.
> +
> +This patch is not supported by crosstool-ng and was originally found here:
> +    https://bitbucket.org/GregorR/musl-cross/src/27953a1f7085/patches/gcc-4.8.0-musl.diff
> +
> +Added-By: Bryan Hundven <bryanhundven@gmail.com>
> +---
> +diff -r 6b1b8174ce29 gcc/config/arm/linux-eabi.h
> +--- a/gcc/config/arm/linux-eabi.h	Fri Mar 29 16:41:20 2013 -0400
> ++++ b/gcc/config/arm/linux-eabi.h	Fri Mar 29 16:41:23 2013 -0400
> +@@ -77,6 +77,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
> +diff -r 6b1b8174ce29 libitm/config/arm/hwcap.cc
> +--- a/libitm/config/arm/hwcap.cc	Fri Mar 29 16:41:20 2013 -0400
> ++++ b/libitm/config/arm/hwcap.cc	Fri Mar 29 16:41:23 2013 -0400
> +@@ -40,7 +40,11 @@
> + 
> + #ifdef __linux__
> + #include <unistd.h>
> ++#ifdef __GLIBC__
> + #include <sys/fcntl.h>
> ++#else
> ++#include <fcntl.h>
> ++#endif
> + #include <elf.h>
> + 
> + static void __attribute__((constructor))
> +# HG changeset patch
> +# Parent 2b29df135cf04fe23c38301f6d0fc5796366aecf
> +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
> +
> +diff -r 2b29df135cf0 gcc/config.gcc
> +--- a/gcc/config.gcc	Fri Mar 29 16:41:11 2013 -0400
> ++++ b/gcc/config.gcc	Fri Mar 29 16:41:14 2013 -0400
> +@@ -549,7 +549,7 @@
> + 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
> +@@ -652,6 +652,9 @@
> +     *-*-*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"
> +       ;;
> +diff -r 2b29df135cf0 gcc/config/linux.h
> +--- a/gcc/config/linux.h	Fri Mar 29 16:41:11 2013 -0400
> ++++ b/gcc/config/linux.h	Fri Mar 29 16:41:14 2013 -0400
> +@@ -32,10 +32,12 @@
> + #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> ++#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 @@
> +    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,16 +89,16 @@
> + 
> + #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.  */
> +diff -r 2b29df135cf0 gcc/config/linux.opt
> +--- a/gcc/config/linux.opt	Fri Mar 29 16:41:11 2013 -0400
> ++++ b/gcc/config/linux.opt	Fri Mar 29 16:41:14 2013 -0400
> +@@ -30,3 +30,7 @@
> + 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
> +diff -r 2b29df135cf0 gcc/ginclude/stddef.h
> +--- a/gcc/ginclude/stddef.h	Fri Mar 29 16:41:11 2013 -0400
> ++++ b/gcc/ginclude/stddef.h	Fri Mar 29 16:41:14 2013 -0400
> +@@ -181,6 +181,7 @@
> + #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 @@
> + #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 long ssize_t;
> + #endif /* __BEOS__ */
> + #endif /* !(defined (__GNUG__) && defined (size_t)) */
> ++#endif /* __DEFINED_size_t */
> + #endif /* __size_t */
> + #endif /* _SIZET_ */
> + #endif /* _GCC_SIZE_T */
> +# HG changeset patch
> +# Parent 2b94537ce2496c88e7e797c617e5b95e8d7e4785
> +A fix for libgomp to correctly request a POSIX version for time support.
> +
> +diff -r 2b94537ce249 libgomp/config/posix/time.c
> +--- a/libgomp/config/posix/time.c	Fri Mar 29 16:41:14 2013 -0400
> ++++ b/libgomp/config/posix/time.c	Fri Mar 29 16:41:17 2013 -0400
> +@@ -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
> +# HG changeset patch
> +# Parent f50bb54f331f73405131a30b4f353cfda1c70304
> +Use the generic implementation of libstdc++ primitives when we're on musl, not the glibc one.
> +
> +diff -r f50bb54f331f libstdc++-v3/configure.host
> +--- a/libstdc++-v3/configure.host	Fri Mar 29 16:38:52 2013 -0400
> ++++ b/libstdc++-v3/configure.host	Fri Mar 29 16:41:10 2013 -0400
> +@@ -264,6 +264,13 @@
> +     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 @@
> +       os_include_dir="os/gnu-linux"
> +     fi
> +     ;;
> ++
> ++    esac
> ++    ;;
> +   hpux*)
> +     os_include_dir="os/hpux"
> +     ;;
> +# HG changeset patch
> +# Parent 62831d7bf931658019ba16092c48375177d014b1
> +Support for mips-linux-musl.
> +
> +diff -r 62831d7bf931 gcc/config/mips/linux.h
> +--- a/gcc/config/mips/linux.h	Fri Mar 29 16:41:23 2013 -0400
> ++++ b/gcc/config/mips/linux.h	Fri Mar 29 16:41:25 2013 -0400
> +@@ -18,3 +18,5 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
> ++
> ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
> +# HG changeset patch
> +# Parent 2ffe76b215fdb082cbbc262536077627757fa9bf
> +Support for powerpc-linux-musl.
> +
> +diff -r 2ffe76b215fd gcc/config.gcc
> +--- a/gcc/config.gcc	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config.gcc	Fri Mar 29 16:41:28 2013 -0400
> +@@ -2112,6 +2112,10 @@
> + 	    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 -r 2ffe76b215fd gcc/config/rs6000/linux64.h
> +--- a/gcc/config/rs6000/linux64.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/linux64.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -364,17 +364,21 @@
> + #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.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)
> + 
> + 
> + #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
> +diff -r 2ffe76b215fd gcc/config/rs6000/secureplt.h
> +--- a/gcc/config/rs6000/secureplt.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/secureplt.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -18,3 +18,4 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
> ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
> +diff -r 2ffe76b215fd gcc/config/rs6000/sysv4.h
> +--- a/gcc/config/rs6000/sysv4.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/sysv4.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -551,6 +551,9 @@
> + #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) \
> +@@ -611,7 +614,8 @@
> + %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \
> + %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
> +     %{mcall-i960-old: --oformat elf32-powerpcle} \
> +-  }}}}"
> ++  }}}} \
> ++%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
> + 
> + /* Any specific OS flags.  */
> + #define LINK_OS_SPEC "\
> +@@ -789,15 +793,18 @@
> + 
> + #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.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} \
> +@@ -923,6 +930,7 @@
> +   { "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 -r 2ffe76b215fd libgcc/config/rs6000/linux-unwind.h
> +--- a/libgcc/config/rs6000/linux-unwind.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/libgcc/config/rs6000/linux-unwind.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -258,6 +258,7 @@
> + 
> +   return _URC_NO_REASON;
> + }
> ++#endif
> + 
> + #define MD_FROB_UPDATE_CONTEXT frob_update_context
> + 
> +# HG changeset patch
> +# Parent 3ea10cd626cb7abdfd56d3fe8d2c9ed58a82797b
> +Support for i386-linux-musl and x86_64-linux-musl.
> +
> +diff -r 3ea10cd626cb gcc/config/i386/linux.h
> +--- a/gcc/config/i386/linux.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/gcc/config/i386/linux.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -21,3 +21,4 @@
> + 
> + #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"
> +diff -r 3ea10cd626cb gcc/config/i386/linux64.h
> +--- a/gcc/config/i386/linux64.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/gcc/config/i386/linux64.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -30,3 +30,7 @@
> + #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"
> +diff -r 3ea10cd626cb libitm/config/linux/x86/tls.h
> +--- a/libitm/config/linux/x86/tls.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/libitm/config/linux/x86/tls.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -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 @@
> + 
> + } // namespace GTM
> + #endif /* >= GLIBC 2.10 */
> ++#endif
> + 
> + #endif // LIBITM_X86_TLS_H
> diff --git a/patches/experimental/gcc/4.8.1/0001-musl.patch b/patches/experimental/gcc/4.8.1/0001-musl.patch
> new file mode 100644
> index 0000000..2c1c0d3
> --- /dev/null
> +++ b/patches/experimental/gcc/4.8.1/0001-musl.patch
> @@ -0,0 +1,626 @@
> +This patch enables support for musl-libc in gcc.
> +
> +This patch is not supported by crosstool-ng and was originally found here:
> +    https://bitbucket.org/GregorR/musl-cross/src/27953a1f7085/patches/gcc-4.8.1-musl.diff
> +
> +Added-By: Bryan Hundven <bryanhundven@gmail.com>
> +---
> +diff -r f50bb54f331f libstdc++-v3/configure.host
> +--- a/libstdc++-v3/configure.host	Fri Mar 29 16:38:52 2013 -0400
> ++++ b/libstdc++-v3/configure.host	Fri Mar 29 16:41:10 2013 -0400
> +@@ -264,6 +264,13 @@
> +     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 @@
> +       os_include_dir="os/gnu-linux"
> +     fi
> +     ;;
> ++
> ++    esac
> ++    ;;
> +   hpux*)
> +     os_include_dir="os/hpux"
> +     ;;
> +# HG changeset patch
> +# Parent 572f7b4d1c50cefde3aa2c43d06040fc308ad989
> +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
> +
> +diff -r 572f7b4d1c50 gcc/config.gcc
> +--- a/gcc/config.gcc	Sun Sep 08 22:58:18 2013 -0400
> ++++ b/gcc/config.gcc	Mon Sep 09 12:48:34 2013 -0400
> +@@ -549,7 +549,7 @@
> + 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
> +@@ -652,6 +652,9 @@
> +     *-*-*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"
> +       ;;
> +diff -r 572f7b4d1c50 gcc/config/linux.h
> +--- a/gcc/config/linux.h	Sun Sep 08 22:58:18 2013 -0400
> ++++ b/gcc/config/linux.h	Mon Sep 09 12:48:34 2013 -0400
> +@@ -32,10 +32,12 @@
> + #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> ++#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 @@
> +    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 @@
> + 
> + #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 @@
> + /* 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
> +diff -r 572f7b4d1c50 gcc/config/linux.opt
> +--- a/gcc/config/linux.opt	Sun Sep 08 22:58:18 2013 -0400
> ++++ b/gcc/config/linux.opt	Mon Sep 09 12:48:34 2013 -0400
> +@@ -30,3 +30,7 @@
> + 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
> +diff -r 572f7b4d1c50 gcc/ginclude/stddef.h
> +--- a/gcc/ginclude/stddef.h	Sun Sep 08 22:58:18 2013 -0400
> ++++ b/gcc/ginclude/stddef.h	Mon Sep 09 12:48:34 2013 -0400
> +@@ -181,6 +181,7 @@
> + #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 @@
> + #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 long ssize_t;
> + #endif /* __BEOS__ */
> + #endif /* !(defined (__GNUG__) && defined (size_t)) */
> ++#endif /* __DEFINED_size_t */
> + #endif /* __size_t */
> + #endif /* _SIZET_ */
> + #endif /* _GCC_SIZE_T */
> +# HG changeset patch
> +# Parent 2b94537ce2496c88e7e797c617e5b95e8d7e4785
> +A fix for libgomp to correctly request a POSIX version for time support.
> +
> +diff -r 2b94537ce249 libgomp/config/posix/time.c
> +--- a/libgomp/config/posix/time.c	Fri Mar 29 16:41:14 2013 -0400
> ++++ b/libgomp/config/posix/time.c	Fri Mar 29 16:41:17 2013 -0400
> +@@ -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 -r 7cba4201a2ae libgcc/unwind-dw2-fde-dip.c
> +--- a/libgcc/unwind-dw2-fde-dip.c	Sat Jul 27 22:53:05 2013 -0400
> ++++ b/libgcc/unwind-dw2-fde-dip.c	Sat Jul 27 22:57:08 2013 -0400
> +@@ -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)))
> ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
> + # 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__)
> +-# define USE_PT_GNU_EH_FRAME
> ++# ifdef __OpenBSD__
> ++#  define ElfW(type) Elf_##typ
> ++# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
> ++#  define ElfW __ElfN
> ++# endif
> + #endif
> + 
> + #if defined(USE_PT_GNU_EH_FRAME)
> +diff -r 75d9c38318a7 gcc/configure
> +--- a/gcc/configure	Tue Sep 24 06:52:49 2013 -0400
> ++++ b/gcc/configure	Tue Sep 24 06:54:33 2013 -0400
> +@@ -26736,6 +26736,9 @@
> + 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.
> +@@ -26769,6 +26772,7 @@
> + 	 # <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"
> +@@ -26851,6 +26855,9 @@
> +       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
> +diff -r 75d9c38318a7 gcc/configure.ac
> +--- a/gcc/configure.ac	Tue Sep 24 06:52:49 2013 -0400
> ++++ b/gcc/configure.ac	Tue Sep 24 06:54:33 2013 -0400
> +@@ -4719,6 +4719,9 @@
> +       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.
> +@@ -4752,6 +4755,7 @@
> + 	 # <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],
> +@@ -4817,6 +4821,9 @@
> +       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
> +# HG changeset patch
> +# Parent 94e435662aff38e86c9ca0dff4bbf451e0190b34
> +Get rid of ever-broken fixincludes on musl.
> +
> +
> +diff -r 94e435662aff -r e27957848dc8 fixincludes/mkfixinc.sh
> +--- a/fixincludes/mkfixinc.sh	Sat Jul 27 23:37:20 2013 -0400
> ++++ b/fixincludes/mkfixinc.sh	Sat Jul 27 23:43:03 2013 -0400
> +@@ -19,7 +19,8 @@
> +     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}
> +# HG changeset patch
> +# Parent 3ea10cd626cb7abdfd56d3fe8d2c9ed58a82797b
> +Support for i386-linux-musl and x86_64-linux-musl.
> +
> +diff -r 3ea10cd626cb gcc/config/i386/linux.h
> +--- a/gcc/config/i386/linux.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/gcc/config/i386/linux.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -21,3 +21,4 @@
> + 
> + #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"
> +diff -r 3ea10cd626cb gcc/config/i386/linux64.h
> +--- a/gcc/config/i386/linux64.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/gcc/config/i386/linux64.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -30,3 +30,7 @@
> + #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"
> +diff -r 3ea10cd626cb libitm/config/linux/x86/tls.h
> +--- a/libitm/config/linux/x86/tls.h	Fri Mar 29 16:41:17 2013 -0400
> ++++ b/libitm/config/linux/x86/tls.h	Fri Mar 29 16:41:20 2013 -0400
> +@@ -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 @@
> + 
> + } // namespace GTM
> + #endif /* >= GLIBC 2.10 */
> ++#endif
> + 
> + #endif // LIBITM_X86_TLS_H
> +# HG changeset patch
> +# Parent c3eb69047e35491fda9cd9ab1ee2ace1299c793c
> +Support for arm-linux-musl.
> +
> +diff -r c3eb69047e35 gcc/config/arm/linux-eabi.h
> +--- a/gcc/config/arm/linux-eabi.h	Thu Sep 19 07:11:38 2013 -0400
> ++++ b/gcc/config/arm/linux-eabi.h	Thu Sep 19 08:56:47 2013 -0400
> +@@ -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 -r c3eb69047e35 libitm/config/arm/hwcap.cc
> +--- a/libitm/config/arm/hwcap.cc	Thu Sep 19 07:11:38 2013 -0400
> ++++ b/libitm/config/arm/hwcap.cc	Thu Sep 19 08:56:47 2013 -0400
> +@@ -40,7 +40,11 @@
> + 
> + #ifdef __linux__
> + #include <unistd.h>
> ++#ifdef __GLIBC__
> + #include <sys/fcntl.h>
> ++#else
> ++#include <fcntl.h>
> ++#endif
> + #include <elf.h>
> + 
> + static void __attribute__((constructor))
> +# HG changeset patch
> +# Parent 4618ad6f036f1e944a5262ae5875dcdf62c41f8b
> +Support for mips-linux-musl.
> +
> +diff -r 4618ad6f036f gcc/config/mips/linux.h
> +--- a/gcc/config/mips/linux.h	Thu Sep 19 08:56:47 2013 -0400
> ++++ b/gcc/config/mips/linux.h	Thu Sep 19 09:08:11 2013 -0400
> +@@ -18,3 +18,10 @@
> + <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"
> +# HG changeset patch
> +# Parent 2ffe76b215fdb082cbbc262536077627757fa9bf
> +Support for powerpc-linux-musl.
> +
> +diff -r 2ffe76b215fd gcc/config.gcc
> +--- a/gcc/config.gcc	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config.gcc	Fri Mar 29 16:41:28 2013 -0400
> +@@ -2112,6 +2112,10 @@
> + 	    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 -r 2ffe76b215fd gcc/config/rs6000/linux64.h
> +--- a/gcc/config/rs6000/linux64.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/linux64.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -364,17 +364,21 @@
> + #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.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)
> + 
> + 
> + #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
> +diff -r 2ffe76b215fd gcc/config/rs6000/secureplt.h
> +--- a/gcc/config/rs6000/secureplt.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/secureplt.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -18,3 +18,4 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
> ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
> +diff -r 2ffe76b215fd gcc/config/rs6000/sysv4.h
> +--- a/gcc/config/rs6000/sysv4.h	Fri Mar 29 16:41:26 2013 -0400
> ++++ b/gcc/config/rs6000/sysv4.h	Fri Mar 29 16:41:28 2013 -0400
> +@@ -551,6 +551,9 @@
> + #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) \
> +@@ -611,7 +614,8 @@
> + %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \
> + %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
> +     %{mcall-i960-old: --oformat elf32-powerpcle} \
> +-  }}}}"
> ++  }}}} \
> ++%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
> + 
> + /* Any specific OS flags.  */
> + #define LINK_OS_SPEC "\
> +@@ -789,15 +793,18 @@
> + 
> + #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.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} \
> +@@ -923,6 +930,7 @@
> +   { "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 },			\
> +--- a/gcc/config/aarch64/aarch64-linux.h	2013-01-10 21:38:27.000000000 +0100
> ++++ b/gcc/config/aarch64/aarch64-linux.h	2013-09-12 21:39:34.004829498 +0200
> +@@ -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 LINUX_TARGET_LINK_SPEC  "%{h*}		\
> +    %{static:-Bstatic}				\
> diff --git a/patches/experimental/gcc/4.8.2/0001-musl.patch b/patches/experimental/gcc/4.8.2/0001-musl.patch
> new file mode 100644
> index 0000000..3ff2e30
> --- /dev/null
> +++ b/patches/experimental/gcc/4.8.2/0001-musl.patch
> @@ -0,0 +1,750 @@
> +This patch enables support for musl-libc in gcc.
> +
> +This patch is not supported by crosstool-ng and was originally found here:
> +    https://bitbucket.org/GregorR/musl-cross/src/27953a1f7085/patches/gcc-4.8.2-musl.diff
> +
> +Added-By: Bryan Hundven <bryanhundven@gmail.com>
> +---
> +diff -r df1a439b9058 libstdc++-v3/configure.host
> +--- a/libstdc++-v3/configure.host	Tue Dec 31 14:52:24 2013 -0500
> ++++ b/libstdc++-v3/configure.host	Tue Dec 31 14:54:49 2013 -0500
> +@@ -264,6 +264,13 @@
> +     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 @@
> +       os_include_dir="os/gnu-linux"
> +     fi
> +     ;;
> ++
> ++    esac
> ++    ;;
> +   hpux*)
> +     os_include_dir="os/hpux"
> +     ;;
> +# HG changeset patch
> +# Parent e5b4564f249f8634194bdabef4b3057d0e54ee97
> +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
> +
> +diff -r e5b4564f249f gcc/config.gcc
> +--- a/gcc/config.gcc	Tue Dec 31 14:54:49 2013 -0500
> ++++ b/gcc/config.gcc	Tue Dec 31 14:54:52 2013 -0500
> +@@ -550,7 +550,7 @@
> + 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
> +@@ -653,6 +653,9 @@
> +     *-*-*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"
> +       ;;
> +diff -r e5b4564f249f gcc/config/linux.h
> +--- a/gcc/config/linux.h	Tue Dec 31 14:54:49 2013 -0500
> ++++ b/gcc/config/linux.h	Tue Dec 31 14:54:52 2013 -0500
> +@@ -32,10 +32,12 @@
> + #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> ++#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 @@
> +    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 @@
> + 
> + #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 @@
> + /* 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
> +diff -r e5b4564f249f gcc/config/linux.opt
> +--- a/gcc/config/linux.opt	Tue Dec 31 14:54:49 2013 -0500
> ++++ b/gcc/config/linux.opt	Tue Dec 31 14:54:52 2013 -0500
> +@@ -30,3 +30,7 @@
> + 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
> +diff -r e5b4564f249f gcc/ginclude/stddef.h
> +--- a/gcc/ginclude/stddef.h	Tue Dec 31 14:54:49 2013 -0500
> ++++ b/gcc/ginclude/stddef.h	Tue Dec 31 14:54:52 2013 -0500
> +@@ -181,6 +181,7 @@
> + #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 @@
> + #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 long ssize_t;
> + #endif /* __BEOS__ */
> + #endif /* !(defined (__GNUG__) && defined (size_t)) */
> ++#endif /* __DEFINED_size_t */
> + #endif /* __size_t */
> + #endif /* _SIZET_ */
> + #endif /* _GCC_SIZE_T */
> +# HG changeset patch
> +# Parent e08e44e39f5edde422f444487422046147d5821e
> +A fix for libgomp to correctly request a POSIX version for time support.
> +
> +diff -r e08e44e39f5e libgomp/config/posix/time.c
> +--- a/libgomp/config/posix/time.c	Tue Dec 31 14:54:52 2013 -0500
> ++++ b/libgomp/config/posix/time.c	Tue Dec 31 14:54:55 2013 -0500
> +@@ -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 -r 809c85574bfe libgcc/unwind-dw2-fde-dip.c
> +--- a/libgcc/unwind-dw2-fde-dip.c	Tue Dec 31 14:54:55 2013 -0500
> ++++ b/libgcc/unwind-dw2-fde-dip.c	Tue Dec 31 14:54:58 2013 -0500
> +@@ -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)))
> ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
> + # 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__)
> +-# 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 -r 03604918697c gcc/configure
> +--- a/gcc/configure	Tue Dec 31 14:54:58 2013 -0500
> ++++ b/gcc/configure	Tue Dec 31 14:55:01 2013 -0500
> +@@ -26739,6 +26739,9 @@
> + 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.
> +@@ -26772,6 +26775,7 @@
> + 	 # <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"
> +@@ -26854,6 +26858,9 @@
> +       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
> +diff -r 03604918697c gcc/configure.ac
> +--- a/gcc/configure.ac	Tue Dec 31 14:54:58 2013 -0500
> ++++ b/gcc/configure.ac	Tue Dec 31 14:55:01 2013 -0500
> +@@ -4722,6 +4722,9 @@
> +       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.
> +@@ -4755,6 +4758,7 @@
> + 	 # <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],
> +@@ -4820,6 +4824,9 @@
> +       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
> +# HG changeset patch
> +# Parent 600a8a422ccaf5627ad1f5a138e7398df2b9e9d8
> +Get rid of ever-broken fixincludes on musl.
> +
> +diff -r 600a8a422cca fixincludes/mkfixinc.sh
> +--- a/fixincludes/mkfixinc.sh	Tue Dec 31 14:55:01 2013 -0500
> ++++ b/fixincludes/mkfixinc.sh	Tue Dec 31 14:55:04 2013 -0500
> +@@ -19,7 +19,8 @@
> +     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}
> +# HG changeset patch
> +# Parent 4696c3bf3d913eca88e9385ea9717541dfe1e033
> +Support for i386-linux-musl and x86_64-linux-musl.
> +
> +diff -r 4696c3bf3d91 gcc/config/i386/linux.h
> +--- a/gcc/config/i386/linux.h	Tue Dec 31 14:55:04 2013 -0500
> ++++ b/gcc/config/i386/linux.h	Tue Dec 31 14:55:08 2013 -0500
> +@@ -21,3 +21,4 @@
> + 
> + #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"
> +diff -r 4696c3bf3d91 gcc/config/i386/linux64.h
> +--- a/gcc/config/i386/linux64.h	Tue Dec 31 14:55:04 2013 -0500
> ++++ b/gcc/config/i386/linux64.h	Tue Dec 31 14:55:08 2013 -0500
> +@@ -30,3 +30,7 @@
> + #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"
> +diff -r 4696c3bf3d91 libitm/config/linux/x86/tls.h
> +--- a/libitm/config/linux/x86/tls.h	Tue Dec 31 14:55:04 2013 -0500
> ++++ b/libitm/config/linux/x86/tls.h	Tue Dec 31 14:55:08 2013 -0500
> +@@ -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 @@
> + 
> + } // namespace GTM
> + #endif /* >= GLIBC 2.10 */
> ++#endif
> + 
> + #endif // LIBITM_X86_TLS_H
> +# HG changeset patch
> +# Parent 6738fd6f6fcc2a72f2ba527bda3325642af26885
> +Support for arm-linux-musl.
> +
> +diff -r 6738fd6f6fcc gcc/config/arm/linux-eabi.h
> +--- a/gcc/config/arm/linux-eabi.h	Tue Dec 31 14:55:08 2013 -0500
> ++++ b/gcc/config/arm/linux-eabi.h	Tue Dec 31 14:55:11 2013 -0500
> +@@ -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 -r 6738fd6f6fcc libitm/config/arm/hwcap.cc
> +--- a/libitm/config/arm/hwcap.cc	Tue Dec 31 14:55:08 2013 -0500
> ++++ b/libitm/config/arm/hwcap.cc	Tue Dec 31 14:55:11 2013 -0500
> +@@ -40,7 +40,11 @@
> + 
> + #ifdef __linux__
> + #include <unistd.h>
> ++#ifdef __GLIBC__
> + #include <sys/fcntl.h>
> ++#else
> ++#include <fcntl.h>
> ++#endif
> + #include <elf.h>
> + 
> + static void __attribute__((constructor))
> +# HG changeset patch
> +# Parent 7d7383f638705a01fdc18e0e7e0c9cdb6387fc5d
> +Support for mips-linux-musl.
> +
> +diff -r 7d7383f63870 gcc/config/mips/linux.h
> +--- a/gcc/config/mips/linux.h	Tue Dec 31 14:55:11 2013 -0500
> ++++ b/gcc/config/mips/linux.h	Tue Dec 31 14:55:14 2013 -0500
> +@@ -18,3 +18,10 @@
> + <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"
> +# HG changeset patch
> +# Parent 89df6d7e91c686da676ce27ef9b9d10522810c26
> +Support for powerpc-linux-musl.
> +
> +diff -r 89df6d7e91c6 gcc/config.gcc
> +--- a/gcc/config.gcc	Tue Dec 31 14:55:14 2013 -0500
> ++++ b/gcc/config.gcc	Tue Dec 31 14:55:17 2013 -0500
> +@@ -2117,6 +2117,10 @@
> + 	    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 -r 89df6d7e91c6 gcc/config/rs6000/linux64.h
> +--- a/gcc/config/rs6000/linux64.h	Tue Dec 31 14:55:14 2013 -0500
> ++++ b/gcc/config/rs6000/linux64.h	Tue Dec 31 14:55:17 2013 -0500
> +@@ -354,17 +354,21 @@
> + #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.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)
> +diff -r 89df6d7e91c6 gcc/config/rs6000/secureplt.h
> +--- a/gcc/config/rs6000/secureplt.h	Tue Dec 31 14:55:14 2013 -0500
> ++++ b/gcc/config/rs6000/secureplt.h	Tue Dec 31 14:55:17 2013 -0500
> +@@ -18,3 +18,4 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
> ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
> +diff -r 89df6d7e91c6 gcc/config/rs6000/sysv4.h
> +--- a/gcc/config/rs6000/sysv4.h	Tue Dec 31 14:55:14 2013 -0500
> ++++ b/gcc/config/rs6000/sysv4.h	Tue Dec 31 14:55:17 2013 -0500
> +@@ -550,6 +550,9 @@
> + #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 @@
> + 
> + /* 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 @@
> + 
> + #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.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 @@
> +   { "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 -r d7ce17b2f2d6 gcc/config/aarch64/aarch64-linux.h
> +--- a/gcc/config/aarch64/aarch64-linux.h	Tue Dec 31 14:55:17 2013 -0500
> ++++ b/gcc/config/aarch64/aarch64-linux.h	Tue Dec 31 14:55:20 2013 -0500
> +@@ -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}"
> + 
> +# HG changeset patch
> +# Parent f2601e4063d0d58d8ab04185e8baefd560d09496
> +Microblaze support (again).
> +
> +
> +diff -r f2601e4063d0 -r 0736dfe1aa0d gcc/config/microblaze/linux.h
> +--- a/gcc/config/microblaze/linux.h	Tue Dec 31 14:55:20 2013 -0500
> ++++ b/gcc/config/microblaze/linux.h	Tue Dec 31 15:09:52 2013 -0500
> +@@ -25,7 +25,22 @@
> + #undef TLS_NEEDS_GOT
> + #define TLS_NEEDS_GOT 1
> + 
> +-#define DYNAMIC_LINKER "/lib/ld.so.1"
> ++#if TARGET_BIG_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-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
> ++#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
> ++
> ++#if DEFAULT_LIBC == LIBC_MUSL
> ++#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
> ++#else
> ++#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
> ++#endif
> ++
> ++
> + #undef  SUBTARGET_EXTRA_SPECS
> + #define SUBTARGET_EXTRA_SPECS \
> +   { "dynamic_linker", DYNAMIC_LINKER }
> +From 478ee0c03a08e2ef9371fd88d516738936943e78 Mon Sep 17 00:00:00 2001
> +From: David Holsgrove <david.holsgrove@xilinx.com>
> +Date: Fri, 28 Sep 2012 16:32:03 +1000
> +Subject: [PATCH 06/11] [Patch, microblaze]: Add SIZE_TYPE and PTRDIFF_TYPE to
> + microblaze.h
> +
> +Fixes warnings like;
> +
> +warning: format '%zX' expects argument of type 'size_t',
> +but argument 3 has type 'unsigned int' [-Wformat]
> +
> +Changelog
> +
> +2013-03-18  David Holsgrove <david.holsgrove@xilinx.com>
> +
> + * gcc/config/microblaze/microblaze.h: Define SIZE_TYPE
> +   and PTRDIFF_TYPE.
> +
> +Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
> +---
> + gcc/config/microblaze/microblaze.h |    6 ++++++
> + 1 file changed, 6 insertions(+)
> +
> +diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
> +index 19cdfed..e772a3f 100644
> +--- a/gcc/config/microblaze/microblaze.h
> ++++ b/gcc/config/microblaze/microblaze.h
> +@@ -213,6 +213,12 @@ extern enum pipeline_type microblaze_pipe;
> + #define STRICT_ALIGNMENT        1
> + #define PCC_BITFIELD_TYPE_MATTERS 1
> + 
> ++#undef SIZE_TYPE
> ++#define SIZE_TYPE "unsigned int"
> ++
> ++#undef PTRDIFF_TYPE
> ++#define PTRDIFF_TYPE "int"
> ++
> + #define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
> +   ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
> +    && (ALIGN) < BITS_PER_WORD						\
> +-- 
> +1.7.9.5
> +
> +--- gcc-4.8.2.org/gcc/config/sh/linux.h
> ++++ gcc-4.8.2/gcc/config/sh/linux.h
> +@@ -43,7 +43,14 @@
> + 
> + #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"
> +--- gcc-4.8.2.org/gcc/config/sh/sh.c
> ++++ gcc-4.8.2/gcc/config/sh/sh.c
> +@@ -22,8 +22,17 @@
> + /* FIXME: This is a temporary hack, so that we can include <algorithm>
> +    below.  <algorithm> will try to include <cstdlib> which will reference
> +    malloc & co, which are poisoned by "system.h".  The proper solution is
> +-   to include <cstdlib> in "system.h" instead of <stdlib.h>.  */
> ++   to include <cstdlib> in "system.h" instead of <stdlib.h>.
> ++   It's also a temporary hack as the inclusion of sstream will cause inclusion
> ++   of libc's pthread.h (istream->ios->ios_base->atomicity->gth->gthr-default)
> ++   which in turn includes sched.h, which defines the CPU_ALLOC, which uses
> ++   the poisoned calloc. the proper fix would be to shield the poison pragmas
> ++   with some define that is only set when gcc developers do testing.
> ++*/
> + #include <cstdlib>
> ++#include <sstream>
> ++#include <vector>
> ++#include <algorithm>
> + 
> + #include "config.h"
> + #include "system.h"
> +@@ -59,10 +68,6 @@
> + #include "alloc-pool.h"
> + #include "tm-constrs.h"
> + #include "opts.h"
> +-
> +-#include <sstream>
> +-#include <vector>
> +-#include <algorithm>
> + 
> + int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch;
> + 
> diff --git a/patches/experimental/gcc/4.8.3/0001-musl.patch b/patches/experimental/gcc/4.8.3/0001-musl.patch
> new file mode 100644
> index 0000000..3e23402
> --- /dev/null
> +++ b/patches/experimental/gcc/4.8.3/0001-musl.patch
> @@ -0,0 +1,736 @@
> +This patch enables support for musl-libc in gcc.
> +
> +This patch is not supported by crosstool-ng and was originally found here:
> +    https://bitbucket.org/GregorR/musl-cross/src/27953a1f7085/patches/gcc-4.8.3-musl.diff
> +
> +Added-By: Bryan Hundven <bryanhundven@gmail.com>
> +---
> +diff -r 3265a3936a0f libstdc++-v3/configure.host
> +--- a/libstdc++-v3/configure.host	Tue May 27 17:11:50 2014 -0400
> ++++ b/libstdc++-v3/configure.host	Tue May 27 17:18:49 2014 -0400
> +@@ -264,6 +264,13 @@
> +     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 @@
> +       os_include_dir="os/gnu-linux"
> +     fi
> +     ;;
> ++
> ++    esac
> ++    ;;
> +   hpux*)
> +     os_include_dir="os/hpux"
> +     ;;
> +# HG changeset patch
> +# Parent feba6705f7e390f69e474a7c761a0eb7add7d414
> +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
> +
> +diff -r feba6705f7e3 gcc/config.gcc
> +--- a/gcc/config.gcc	Tue May 27 17:18:49 2014 -0400
> ++++ b/gcc/config.gcc	Tue May 27 17:18:52 2014 -0400
> +@@ -550,7 +550,7 @@
> + 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
> +@@ -653,6 +653,9 @@
> +     *-*-*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"
> +       ;;
> +diff -r feba6705f7e3 gcc/config/linux.h
> +--- a/gcc/config/linux.h	Tue May 27 17:18:49 2014 -0400
> ++++ b/gcc/config/linux.h	Tue May 27 17:18:52 2014 -0400
> +@@ -32,10 +32,12 @@
> + #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> ++#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 @@
> +    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 @@
> + 
> + #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 @@
> + /* 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
> +diff -r feba6705f7e3 gcc/config/linux.opt
> +--- a/gcc/config/linux.opt	Tue May 27 17:18:49 2014 -0400
> ++++ b/gcc/config/linux.opt	Tue May 27 17:18:52 2014 -0400
> +@@ -30,3 +30,7 @@
> + 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
> +diff -r feba6705f7e3 gcc/ginclude/stddef.h
> +--- a/gcc/ginclude/stddef.h	Tue May 27 17:18:49 2014 -0400
> ++++ b/gcc/ginclude/stddef.h	Tue May 27 17:18:52 2014 -0400
> +@@ -181,6 +181,7 @@
> + #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 @@
> + #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 long ssize_t;
> + #endif /* __BEOS__ */
> + #endif /* !(defined (__GNUG__) && defined (size_t)) */
> ++#endif /* __DEFINED_size_t */
> + #endif /* __size_t */
> + #endif /* _SIZET_ */
> + #endif /* _GCC_SIZE_T */
> +# HG changeset patch
> +# Parent 77fd601051c4644b37838a8e5305c6971feab94f
> +A fix for libgomp to correctly request a POSIX version for time support.
> +
> +diff -r 77fd601051c4 libgomp/config/posix/time.c
> +--- a/libgomp/config/posix/time.c	Tue May 27 17:18:52 2014 -0400
> ++++ b/libgomp/config/posix/time.c	Tue May 27 17:18:55 2014 -0400
> +@@ -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 -r abebeb8818d8 libgcc/unwind-dw2-fde-dip.c
> +--- a/libgcc/unwind-dw2-fde-dip.c	Tue May 27 17:18:55 2014 -0400
> ++++ b/libgcc/unwind-dw2-fde-dip.c	Tue May 27 17:18:58 2014 -0400
> +@@ -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)))
> ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
> + # 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__)
> +-# 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 -r 68e6894cdeea gcc/configure
> +--- a/gcc/configure	Tue May 27 17:18:58 2014 -0400
> ++++ b/gcc/configure	Tue May 27 17:19:01 2014 -0400
> +@@ -26821,6 +26821,9 @@
> + 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.
> +@@ -26854,6 +26857,7 @@
> + 	 # <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"
> +@@ -26936,6 +26940,9 @@
> +       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
> +diff -r 68e6894cdeea gcc/configure.ac
> +--- a/gcc/configure.ac	Tue May 27 17:18:58 2014 -0400
> ++++ b/gcc/configure.ac	Tue May 27 17:19:01 2014 -0400
> +@@ -4750,6 +4750,9 @@
> +       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.
> +@@ -4783,6 +4786,7 @@
> + 	 # <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],
> +@@ -4848,6 +4852,9 @@
> +       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
> +# HG changeset patch
> +# Parent 5e0be25b469181f67d89382c7da201510c229f90
> +Get rid of ever-broken fixincludes on musl.
> +
> +diff -r 5e0be25b4691 fixincludes/mkfixinc.sh
> +--- a/fixincludes/mkfixinc.sh	Tue May 27 17:19:01 2014 -0400
> ++++ b/fixincludes/mkfixinc.sh	Tue May 27 17:19:04 2014 -0400
> +@@ -19,7 +19,8 @@
> +     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}
> +# HG changeset patch
> +# Parent dd2004fbd61c182919b800cec63806060b4228e5
> +Support for i386-linux-musl and x86_64-linux-musl.
> +
> +diff -r dd2004fbd61c gcc/config/i386/linux.h
> +--- a/gcc/config/i386/linux.h	Tue May 27 17:19:04 2014 -0400
> ++++ b/gcc/config/i386/linux.h	Tue May 27 17:19:07 2014 -0400
> +@@ -21,3 +21,4 @@
> + 
> + #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"
> +diff -r dd2004fbd61c gcc/config/i386/linux64.h
> +--- a/gcc/config/i386/linux64.h	Tue May 27 17:19:04 2014 -0400
> ++++ b/gcc/config/i386/linux64.h	Tue May 27 17:19:07 2014 -0400
> +@@ -30,3 +30,7 @@
> + #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"
> +diff -r dd2004fbd61c libitm/config/linux/x86/tls.h
> +--- a/libitm/config/linux/x86/tls.h	Tue May 27 17:19:04 2014 -0400
> ++++ b/libitm/config/linux/x86/tls.h	Tue May 27 17:19:07 2014 -0400
> +@@ -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 @@
> + 
> + } // namespace GTM
> + #endif /* >= GLIBC 2.10 */
> ++#endif
> + 
> + #endif // LIBITM_X86_TLS_H
> +# HG changeset patch
> +# Parent 42eeea84a212601568b5a6d17eb28cfba4b45e1d
> +Support for arm-linux-musl.
> +
> +diff -r 42eeea84a212 gcc/config/arm/linux-eabi.h
> +--- a/gcc/config/arm/linux-eabi.h	Tue May 27 17:19:07 2014 -0400
> ++++ b/gcc/config/arm/linux-eabi.h	Tue May 27 17:19:11 2014 -0400
> +@@ -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 -r 42eeea84a212 libitm/config/arm/hwcap.cc
> +--- a/libitm/config/arm/hwcap.cc	Tue May 27 17:19:07 2014 -0400
> ++++ b/libitm/config/arm/hwcap.cc	Tue May 27 17:19:11 2014 -0400
> +@@ -40,7 +40,11 @@
> + 
> + #ifdef __linux__
> + #include <unistd.h>
> ++#ifdef __GLIBC__
> + #include <sys/fcntl.h>
> ++#else
> ++#include <fcntl.h>
> ++#endif
> + #include <elf.h>
> + 
> + static void __attribute__((constructor))
> +# HG changeset patch
> +# Parent fae0f2a79418e010ac48deb6dc84b16524158f4d
> +Support for mips-linux-musl.
> +
> +diff -r fae0f2a79418 gcc/config/mips/linux.h
> +--- a/gcc/config/mips/linux.h	Tue May 27 17:19:10 2014 -0400
> ++++ b/gcc/config/mips/linux.h	Tue May 27 17:19:14 2014 -0400
> +@@ -18,3 +18,10 @@
> + <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"
> +# HG changeset patch
> +# Parent 5f732d28ac6e18a515050808509c12a97a63af48
> +Support for powerpc-linux-musl.
> +
> +diff -r 5f732d28ac6e gcc/config.gcc
> +--- a/gcc/config.gcc	Tue May 27 17:19:13 2014 -0400
> ++++ b/gcc/config.gcc	Tue May 27 17:19:17 2014 -0400
> +@@ -2138,6 +2138,10 @@
> + 	    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 -r 5f732d28ac6e gcc/config/rs6000/linux64.h
> +--- a/gcc/config/rs6000/linux64.h	Tue May 27 17:19:13 2014 -0400
> ++++ b/gcc/config/rs6000/linux64.h	Tue May 27 17:19:17 2014 -0400
> +@@ -374,17 +374,21 @@
> + #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.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)
> +diff -r 5f732d28ac6e gcc/config/rs6000/secureplt.h
> +--- a/gcc/config/rs6000/secureplt.h	Tue May 27 17:19:13 2014 -0400
> ++++ b/gcc/config/rs6000/secureplt.h	Tue May 27 17:19:17 2014 -0400
> +@@ -18,3 +18,4 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
> ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
> +diff -r 5f732d28ac6e gcc/config/rs6000/sysv4.h
> +--- a/gcc/config/rs6000/sysv4.h	Tue May 27 17:19:13 2014 -0400
> ++++ b/gcc/config/rs6000/sysv4.h	Tue May 27 17:19:17 2014 -0400
> +@@ -537,6 +537,9 @@
> + #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.  */
> + #define	CC1_SPEC "%{G*} %(cc1_cpu)" \
> +@@ -585,7 +588,8 @@
> + 
> + /* 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 "\
> +@@ -763,15 +767,18 @@
> + 
> + #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.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} \
> +@@ -894,6 +901,7 @@
> +   { "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 },			\
> +diff -r 4d2277f95a50 gcc/config/aarch64/aarch64-linux.h
> +--- a/gcc/config/aarch64/aarch64-linux.h	Tue May 27 17:19:17 2014 -0400
> ++++ b/gcc/config/aarch64/aarch64-linux.h	Tue May 27 17:19:20 2014 -0400
> +@@ -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}"
> + 
> +# HG changeset patch
> +# Parent 11f8f95e9940bff12445f189dae33a4a8074ed1a
> +Microblaze support (again).
> +
> +diff -r 11f8f95e9940 gcc/config/microblaze/linux.h
> +--- a/gcc/config/microblaze/linux.h	Tue May 27 17:19:20 2014 -0400
> ++++ b/gcc/config/microblaze/linux.h	Tue May 27 17:19:23 2014 -0400
> +@@ -25,7 +25,22 @@
> + #undef TLS_NEEDS_GOT
> + #define TLS_NEEDS_GOT 1
> + 
> +-#define DYNAMIC_LINKER "/lib/ld.so.1"
> ++#if TARGET_BIG_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-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
> ++#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
> ++
> ++#if DEFAULT_LIBC == LIBC_MUSL
> ++#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
> ++#else
> ++#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
> ++#endif
> ++
> ++
> + #undef  SUBTARGET_EXTRA_SPECS
> + #define SUBTARGET_EXTRA_SPECS \
> +   { "dynamic_linker", DYNAMIC_LINKER }
> +From 478ee0c03a08e2ef9371fd88d516738936943e78 Mon Sep 17 00:00:00 2001
> +From: David Holsgrove <david.holsgrove@xilinx.com>
> +Date: Fri, 28 Sep 2012 16:32:03 +1000
> +Subject: [PATCH 06/11] [Patch, microblaze]: Add SIZE_TYPE and PTRDIFF_TYPE to
> + microblaze.h
> +
> +Fixes warnings like;
> +
> +warning: format '%zX' expects argument of type 'size_t',
> +but argument 3 has type 'unsigned int' [-Wformat]
> +
> +Changelog
> +
> +2013-03-18  David Holsgrove <david.holsgrove@xilinx.com>
> +
> + * gcc/config/microblaze/microblaze.h: Define SIZE_TYPE
> +   and PTRDIFF_TYPE.
> +
> +Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
> +---
> + gcc/config/microblaze/microblaze.h |    6 ++++++
> + 1 file changed, 6 insertions(+)
> +
> +diff -r 2af2905d4b10 gcc/config/microblaze/microblaze.h
> +--- a/gcc/config/microblaze/microblaze.h	Tue May 27 17:19:22 2014 -0400
> ++++ b/gcc/config/microblaze/microblaze.h	Tue May 27 17:19:26 2014 -0400
> +@@ -219,6 +219,12 @@
> + #undef PTRDIFF_TYPE
> + #define PTRDIFF_TYPE "int"
> + 
> ++#undef SIZE_TYPE
> ++#define SIZE_TYPE "unsigned int"
> ++
> ++#undef PTRDIFF_TYPE
> ++#define PTRDIFF_TYPE "int"
> ++
> + #define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
> +   ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
> +    && (ALIGN) < BITS_PER_WORD						\
> +diff -Nur gcc-4.8.3.orig/gcc/config/microblaze/microblaze.md gcc-4.8.3/gcc/config/microblaze/microblaze.md
> +--- gcc-4.8.3.orig/gcc/config/microblaze/microblaze.md	2014-02-23 19:59:26.000000000 +0100
> ++++ gcc-4.8.3/gcc/config/microblaze/microblaze.md	2014-05-31 20:39:29.978608468 +0200
> +@@ -1119,18 +1119,6 @@
> +   }
> + )
> + 
> +-;;Load and store reverse
> +-(define_insn "movsi4_rev"
> +-  [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Q")
> +-        (bswap:SI (match_operand:SF 1 "reg_or_mem_operand" "Q,r")))]
> +-  "TARGET_REORDER"
> +-  "@
> +-   lwr\t%0,%y1,r0
> +-   swr\t%1,%y0,r0"
> +-  [(set_attr "type"     "load,store")
> +-  (set_attr "mode"      "SI")
> +-  (set_attr "length"    "4,4")])
> +-
> + ;; 32-bit floating point moves
> + 
> + (define_expand "movsf"
> +diff -r 596e2430c627 gcc/config/sh/linux.h
> +--- a/gcc/config/sh/linux.h	Fri Sep 28 16:32:03 2012 +1000
> ++++ b/gcc/config/sh/linux.h	Tue May 27 17:19:29 2014 -0400
> +@@ -43,7 +43,14 @@
> + 
> + #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/patches/experimental/gcc/4.9.0/0001-musl.patch b/patches/experimental/gcc/4.9.0/0001-musl.patch
> new file mode 100644
> index 0000000..de6f532
> --- /dev/null
> +++ b/patches/experimental/gcc/4.9.0/0001-musl.patch
> @@ -0,0 +1,706 @@
> +This patch enables support for musl-libc in gcc.
> +
> +This patch is not supported by crosstool-ng and was originally found here:
> +    https://bitbucket.org/GregorR/musl-cross/src/27953a1f7085/patches/gcc-4.9.0-musl.diff
> +
> +Added-By: Bryan Hundven <bryanhundven@gmail.com>
> +---
> +diff -r 2f9df662aaab libstdc++-v3/configure.host
> +--- a/libstdc++-v3/configure.host	Tue May 20 11:00:21 2014 -0400
> ++++ b/libstdc++-v3/configure.host	Tue May 20 11:05:42 2014 -0400
> +@@ -264,6 +264,13 @@
> +     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 @@
> +       os_include_dir="os/gnu-linux"
> +     fi
> +     ;;
> ++
> ++    esac
> ++    ;;
> +   hpux*)
> +     os_include_dir="os/hpux"
> +     ;;
> +# HG changeset patch
> +# Parent b6f4ce05a3155dbcbc06d72aebdb67e2f8abc094
> +Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
> +
> +diff -r b6f4ce05a315 gcc/config.gcc
> +--- a/gcc/config.gcc	Tue May 20 11:05:42 2014 -0400
> ++++ b/gcc/config.gcc	Tue May 20 11:05:45 2014 -0400
> +@@ -594,7 +594,7 @@
> + 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.
> +@@ -719,6 +719,9 @@
> +     *-*-*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"
> +       ;;
> +diff -r b6f4ce05a315 gcc/config/linux.h
> +--- a/gcc/config/linux.h	Tue May 20 11:05:42 2014 -0400
> ++++ b/gcc/config/linux.h	Tue May 20 11:05:45 2014 -0400
> +@@ -32,10 +32,12 @@
> + #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> + #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> + #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> ++#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 @@
> +    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,92 @@
> + 
> + #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
> +diff -r b6f4ce05a315 gcc/config/linux.opt
> +--- a/gcc/config/linux.opt	Tue May 20 11:05:42 2014 -0400
> ++++ b/gcc/config/linux.opt	Tue May 20 11:05:45 2014 -0400
> +@@ -30,3 +30,7 @@
> + 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
> +diff -r b6f4ce05a315 gcc/ginclude/stddef.h
> +--- a/gcc/ginclude/stddef.h	Tue May 20 11:05:42 2014 -0400
> ++++ b/gcc/ginclude/stddef.h	Tue May 20 11:05:45 2014 -0400
> +@@ -181,6 +181,7 @@
> + #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 @@
> + #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 long ssize_t;
> + #endif /* __BEOS__ */
> + #endif /* !(defined (__GNUG__) && defined (size_t)) */
> ++#endif /* __DEFINED_size_t */
> + #endif /* __size_t */
> + #endif /* _SIZET_ */
> + #endif /* _GCC_SIZE_T */
> +# HG changeset patch
> +# Parent 65d595ef9fc3cdbbde4894d927593f1b0f5bbcb7
> +A fix for libgomp to correctly request a POSIX version for time support.
> +
> +diff -r 65d595ef9fc3 libgomp/config/posix/time.c
> +--- a/libgomp/config/posix/time.c	Tue May 20 11:05:45 2014 -0400
> ++++ b/libgomp/config/posix/time.c	Tue May 20 11:05:48 2014 -0400
> +@@ -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 -r 95f4f1d7668b libgcc/unwind-dw2-fde-dip.c
> +--- a/libgcc/unwind-dw2-fde-dip.c	Tue May 20 11:05:48 2014 -0400
> ++++ b/libgcc/unwind-dw2-fde-dip.c	Tue May 20 11:05:52 2014 -0400
> +@@ -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)))
> ++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
> + # 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__)
> +-# 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 -r ff03fa61c6b3 gcc/configure
> +--- a/gcc/configure	Tue May 20 11:05:51 2014 -0400
> ++++ b/gcc/configure	Tue May 20 11:05:55 2014 -0400
> +@@ -27300,6 +27300,9 @@
> + 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.
> +@@ -27332,6 +27335,7 @@
> + 	 # <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"
> +@@ -27421,6 +27425,9 @@
> +       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
> +diff -r ff03fa61c6b3 gcc/configure.ac
> +--- a/gcc/configure.ac	Tue May 20 11:05:51 2014 -0400
> ++++ b/gcc/configure.ac	Tue May 20 11:05:55 2014 -0400
> +@@ -5001,6 +5001,9 @@
> +       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.
> +@@ -5027,6 +5030,7 @@
> + 	 # <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],
> +@@ -5093,6 +5097,9 @@
> +       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
> +# HG changeset patch
> +# Parent 26f591b9e77e3df3d0f772b840bd9c13ec24bd4c
> +Get rid of ever-broken fixincludes on musl.
> +
> +diff -r 26f591b9e77e fixincludes/mkfixinc.sh
> +--- a/fixincludes/mkfixinc.sh	Tue May 20 11:05:55 2014 -0400
> ++++ b/fixincludes/mkfixinc.sh	Tue May 20 11:05:58 2014 -0400
> +@@ -19,7 +19,8 @@
> +     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}
> +# HG changeset patch
> +# Parent bc117c35705fcc39396c19af046101411f251161
> +Support for i386-linux-musl and x86_64-linux-musl.
> +
> +diff -r bc117c35705f gcc/config/i386/linux.h
> +--- a/gcc/config/i386/linux.h	Tue May 20 11:05:58 2014 -0400
> ++++ b/gcc/config/i386/linux.h	Tue May 20 11:06:01 2014 -0400
> +@@ -21,3 +21,4 @@
> + 
> + #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"
> +diff -r bc117c35705f gcc/config/i386/linux64.h
> +--- a/gcc/config/i386/linux64.h	Tue May 20 11:05:58 2014 -0400
> ++++ b/gcc/config/i386/linux64.h	Tue May 20 11:06:01 2014 -0400
> +@@ -30,3 +30,7 @@
> + #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"
> +diff -r bc117c35705f libitm/config/linux/x86/tls.h
> +--- a/libitm/config/linux/x86/tls.h	Tue May 20 11:05:58 2014 -0400
> ++++ b/libitm/config/linux/x86/tls.h	Tue May 20 11:06:01 2014 -0400
> +@@ -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 @@
> + 
> + } // namespace GTM
> + #endif /* >= GLIBC 2.10 */
> ++#endif
> + 
> + #endif // LIBITM_X86_TLS_H
> +# HG changeset patch
> +# Parent 933c4f064622eb96a0b2ab213abd0cddbd977d1a
> +Support for arm-linux-musl.
> +
> +diff -r 933c4f064622 gcc/config/arm/linux-eabi.h
> +--- a/gcc/config/arm/linux-eabi.h	Tue May 20 11:06:01 2014 -0400
> ++++ b/gcc/config/arm/linux-eabi.h	Tue May 20 11:06:04 2014 -0400
> +@@ -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 -r 933c4f064622 libitm/config/arm/hwcap.cc
> +--- a/libitm/config/arm/hwcap.cc	Tue May 20 11:06:01 2014 -0400
> ++++ b/libitm/config/arm/hwcap.cc	Tue May 20 11:06:04 2014 -0400
> +@@ -40,7 +40,11 @@
> + 
> + #ifdef __linux__
> + #include <unistd.h>
> ++#ifdef __GLIBC__
> + #include <sys/fcntl.h>
> ++#else
> ++#include <fcntl.h>
> ++#endif
> + #include <elf.h>
> + 
> + static void __attribute__((constructor))
> +# HG changeset patch
> +# Parent 03fe896f3acaa911e935a8e999d15c7542ee73d1
> +Support for mips-linux-musl.
> +
> +diff -r 03fe896f3aca gcc/config/mips/linux.h
> +--- a/gcc/config/mips/linux.h	Tue May 20 11:06:04 2014 -0400
> ++++ b/gcc/config/mips/linux.h	Tue May 20 11:06:08 2014 -0400
> +@@ -23,3 +23,10 @@
> + #undef UCLIBC_DYNAMIC_LINKER
> + #define UCLIBC_DYNAMIC_LINKER \
> +   "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
> ++
> ++#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"
> +# HG changeset patch
> +# Parent 6097333f2ab47a4ce37ccfb18b0f07a0cdcfec49
> +Support for powerpc-linux-musl.
> +
> +diff -r 6097333f2ab4 gcc/config.gcc
> +--- a/gcc/config.gcc	Tue May 20 11:06:08 2014 -0400
> ++++ b/gcc/config.gcc	Tue May 20 11:06:11 2014 -0400
> +@@ -2326,6 +2326,10 @@
> + 	    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 -r 6097333f2ab4 gcc/config/rs6000/linux64.h
> +--- a/gcc/config/rs6000/linux64.h	Tue May 20 11:06:08 2014 -0400
> ++++ b/gcc/config/rs6000/linux64.h	Tue May 20 11:06:11 2014 -0400
> +@@ -375,17 +375,21 @@
> + #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.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)
> +diff -r 6097333f2ab4 gcc/config/rs6000/secureplt.h
> +--- a/gcc/config/rs6000/secureplt.h	Tue May 20 11:06:08 2014 -0400
> ++++ b/gcc/config/rs6000/secureplt.h	Tue May 20 11:06:11 2014 -0400
> +@@ -18,3 +18,4 @@
> + <http://www.gnu.org/licenses/>.  */
> + 
> + #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
> ++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
> +diff -r 6097333f2ab4 gcc/config/rs6000/sysv4.h
> +--- a/gcc/config/rs6000/sysv4.h	Tue May 20 11:06:08 2014 -0400
> ++++ b/gcc/config/rs6000/sysv4.h	Tue May 20 11:06:11 2014 -0400
> +@@ -537,6 +537,9 @@
> + #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.  */
> + #define	CC1_SPEC "%{G*} %(cc1_cpu)" \
> +@@ -585,7 +588,8 @@
> + 
> + /* 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 "\
> +@@ -763,15 +767,18 @@
> + 
> + #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.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} \
> +@@ -894,6 +901,7 @@
> +   { "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 },			\
> +diff -r 813971b9f083 gcc/config/aarch64/aarch64-linux.h
> +--- a/gcc/config/aarch64/aarch64-linux.h	Tue May 20 11:06:11 2014 -0400
> ++++ b/gcc/config/aarch64/aarch64-linux.h	Tue May 20 11:06:14 2014 -0400
> +@@ -23,6 +23,8 @@
> + 
> + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}.so.1"
> + 
> ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
> ++
> + #define CPP_SPEC "%{pthread:-D_REENTRANT}"
> + 
> + #define LINUX_TARGET_LINK_SPEC  "%{h*}		\
> +# HG changeset patch
> +# Parent 4a62a6813db995fe195d47ff73234d455975ac30
> +Microblaze support (again).
> +
> +diff -r 4a62a6813db9 gcc/config/microblaze/linux.h
> +--- a/gcc/config/microblaze/linux.h	Tue May 20 11:06:14 2014 -0400
> ++++ b/gcc/config/microblaze/linux.h	Tue May 20 11:06:17 2014 -0400
> +@@ -25,7 +25,22 @@
> + #undef TLS_NEEDS_GOT
> + #define TLS_NEEDS_GOT 1
> + 
> +-#define DYNAMIC_LINKER "/lib/ld.so.1"
> ++#if TARGET_BIG_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-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
> ++#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
> ++
> ++#if DEFAULT_LIBC == LIBC_MUSL
> ++#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
> ++#else
> ++#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
> ++#endif
> ++
> ++
> + #undef  SUBTARGET_EXTRA_SPECS
> + #define SUBTARGET_EXTRA_SPECS \
> +   { "dynamic_linker", DYNAMIC_LINKER }
> +From 478ee0c03a08e2ef9371fd88d516738936943e78 Mon Sep 17 00:00:00 2001
> +From: David Holsgrove <david.holsgrove@xilinx.com>
> +Date: Fri, 28 Sep 2012 16:32:03 +1000
> +Subject: [PATCH 06/11] [Patch, microblaze]: Add SIZE_TYPE and PTRDIFF_TYPE to
> + microblaze.h
> +
> +Fixes warnings like;
> +
> +warning: format '%zX' expects argument of type 'size_t',
> +but argument 3 has type 'unsigned int' [-Wformat]
> +
> +Changelog
> +
> +2013-03-18  David Holsgrove <david.holsgrove@xilinx.com>
> +
> + * gcc/config/microblaze/microblaze.h: Define SIZE_TYPE
> +   and PTRDIFF_TYPE.
> +
> +Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
> +---
> + gcc/config/microblaze/microblaze.h |    6 ++++++
> + 1 file changed, 6 insertions(+)
> +
> +diff -r 20d1c995f5de gcc/config/microblaze/microblaze.h
> +--- a/gcc/config/microblaze/microblaze.h	Tue May 20 11:06:17 2014 -0400
> ++++ b/gcc/config/microblaze/microblaze.h	Tue May 20 11:06:20 2014 -0400
> +@@ -218,6 +218,12 @@
> + #undef PTRDIFF_TYPE
> + #define PTRDIFF_TYPE "int"
> + 
> ++#undef SIZE_TYPE
> ++#define SIZE_TYPE "unsigned int"
> ++
> ++#undef PTRDIFF_TYPE
> ++#define PTRDIFF_TYPE "int"
> ++
> + #define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
> +   ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
> +    && (ALIGN) < BITS_PER_WORD						\
> +diff -r 2f999fc929da gcc/config/sh/linux.h
> +--- a/gcc/config/sh/linux.h	Fri Sep 28 16:32:03 2012 +1000
> ++++ b/gcc/config/sh/linux.h	Tue May 20 11:06:23 2014 -0400
> +@@ -43,7 +43,14 @@
> + 
> + #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/patches/musl/1.0.3/0001-fix_linker_regression.patch b/patches/musl/1.0.3/0001-fix_linker_regression.patch
> new file mode 100644
> index 0000000..801cb00
> --- /dev/null
> +++ b/patches/musl/1.0.3/0001-fix_linker_regression.patch
> @@ -0,0 +1,64 @@
> +From 9a4ad02214a859e93d2c980e4535378a6a74e3a6 Mon Sep 17 00:00:00 2001
> +From: Rich Felker <dalias@aerifal.cx>
> +Date: Mon, 30 Jun 2014 01:52:54 +0000
> +Subject: fix regression in dynamic linker error reporting
> +
> +due to a mistake when refactoring the error printing for the dynamic
> +linker (commit 7c73cacd09a51a87484db5689864743e4984a84d), all messages
> +were suppressed and replaced by blank lines.
> +---
> +diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
> +index bc4f2f6..a08300d 100644
> +--- a/src/ldso/dynlink.c
> ++++ b/src/ldso/dynlink.c
> +@@ -290,8 +290,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 		if (!astype) continue;
> + 		type = remap_rel(astype);
> + 		if (!type) {
> +-			error(errbuf, sizeof errbuf,
> +-				"Error relocating %s: unsupported relocation type %d",
> ++			error("Error relocating %s: unsupported relocation type %d",
> + 				dso->name, astype);
> + 			continue;
> + 		}
> +@@ -304,8 +303,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 			def = find_sym(ctx, name, type==REL_PLT);
> + 			if (!def.sym && (sym->st_shndx != SHN_UNDEF
> + 			    || sym->st_info>>4 != STB_WEAK)) {
> +-				error(errbuf, sizeof errbuf,
> +-					"Error relocating %s: %s: symbol not found",
> ++				error("Error relocating %s: %s: symbol not found",
> + 					dso->name, name);
> + 				continue;
> + 			}
> +@@ -366,7 +364,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 			if (stride<3) addend = reloc_addr[1];
> + 			if (runtime && def.dso->tls_id >= static_tls_cnt) {
> + 				struct td_index *new = malloc(sizeof *new);
> +-				if (!new) error(errbuf, sizeof errbuf,
> ++				if (!new) error(
> + 					"Error relocating %s: cannot allocate TLSDESC for %s",
> + 					dso->name, sym ? name : "(local)" );
> + 				new->next = dso->td_index;
> +@@ -839,8 +837,7 @@ static void load_deps(struct dso *p)
> + 			if (p->dynv[i] != DT_NEEDED) continue;
> + 			dep = load_library(p->strings + p->dynv[i+1], p);
> + 			if (!dep) {
> +-				error(errbuf, sizeof errbuf,
> +-					"Error loading shared library %s: %m (needed by %s)",
> ++				error("Error loading shared library %s: %m (needed by %s)",
> + 					p->strings + p->dynv[i+1], p->name);
> + 				continue;
> + 			}
> +@@ -890,8 +887,7 @@ static void reloc_all(struct dso *p)
> + 
> + 		if (p->relro_start != p->relro_end &&
> + 		    mprotect(p->base+p->relro_start, p->relro_end-p->relro_start, PROT_READ) < 0) {
> +-			error(errbuf, sizeof errbuf,
> +-				"Error relocating %s: RELRO protection failed: %m",
> ++			error("Error relocating %s: RELRO protection failed: %m",
> + 				p->name);
> + 		}
> + 
> +--
> +cgit v0.9.0.3-65-g4555
> diff --git a/patches/musl/1.0.3/0002-fix_mips_linker_regression.patch b/patches/musl/1.0.3/0002-fix_mips_linker_regression.patch
> new file mode 100644
> index 0000000..4891b4f
> --- /dev/null
> +++ b/patches/musl/1.0.3/0002-fix_mips_linker_regression.patch
> @@ -0,0 +1,88 @@
> +From 2d8cc92a7cb4a3256ed07d86843388ffd8a882b1 Mon Sep 17 00:00:00 2001
> +From: Rich Felker <dalias@aerifal.cx>
> +Date: Mon, 30 Jun 2014 05:18:14 +0000
> +Subject: fix regression in mips dynamic linker
> +
> +this issue caused the address of functions in shared libraries to
> +resolve to their PLT thunks in the main program rather than their
> +correct addresses. it was observed causing crashes, though the
> +mechanism of the crash was not thoroughly investigated. since the
> +issue is very subtle, it calls for some explanation:
> +
> +on all well-behaved archs, GOT entries that belong to the PLT use a
> +special relocation type, typically called JMP_SLOT, so that the
> +dynamic linker can avoid having the jump destinations for the PLT
> +resolve to PLT thunks themselves (they also provide a definition for
> +the symbol, which must be used whenever the address of the function is
> +taken so that all DSOs see the same address).
> +
> +however, the traditional mips PIC ABI lacked such a JMP_SLOT
> +relocation type, presumably because, due to the way PIC works, the
> +address of the PLT thunk was never needed and could always be ignored.
> +
> +prior to commit adf94c19666e687a728bbf398f9a88ea4ea19996, the mips
> +version of reloc.h contained a hack that caused all symbol lookups to
> +be treated like JMP_SLOT, inhibiting undefined symbols from ever being
> +used to resolve symbolic relocations. this hack goes all the way back
> +to commit babf820180368f00742ec65b2050a82380d7c542, when the mips
> +dynamic linker was first made usable.
> +
> +during the recent refactoring to eliminate arch-specific relocation
> +processing (commit adf94c19666e687a728bbf398f9a88ea4ea19996), this
> +hack was overlooked and no equivalent functionality was provided in
> +the new code.
> +
> +fixing the problem is not as simple as adding back an equivalent hack,
> +since there is now also a "non-PIC ABI" that can be used for the main
> +executable, which actually does use a PLT. the closest thing to
> +official documentation I could find for this ABI is nonpic.txt,
> +attached to Message-ID: 20080701202236.GA1534@caradoc.them.org, which
> +can be found in the gcc mailing list archives and elsewhere. per this
> +document, undefined symbols corresponding to PLT thunks have the
> +STO_MIPS_PLT bit set in the symbol's st_other field. thus, I have
> +added an arch-specific rule for mips, applied at the find_sym level
> +rather than the relocation level, to reject undefined symbols with the
> +STO_MIPS_PLT bit clear.
> +
> +the previous hack of treating all mips relocations as JMP_SLOT-like,
> +rather than rejecting the unwanted symbols in find_sym, probably also
> +caused dlsym to wrongly return PLT thunks in place of the correct
> +address of a function under at least some conditions. this should now
> +be fixed, at least for global-scope symbol lookups.
> +---
> +diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
> +index 91fa097..4b81d32 100644
> +--- a/arch/mips/reloc.h
> ++++ b/arch/mips/reloc.h
> +@@ -86,3 +86,4 @@ static void do_arch_relocs(struct dso *this, struct dso *head)
> + 
> + #define NEED_ARCH_RELOCS 1
> + #define DYNAMIC_IS_RO 1
> ++#define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
> +diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
> +index a08300d..55124ff 100644
> +--- a/src/ldso/dynlink.c
> ++++ b/src/ldso/dynlink.c
> +@@ -233,6 +233,10 @@ static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
> + #define OK_TYPES (1<<STT_NOTYPE | 1<<STT_OBJECT | 1<<STT_FUNC | 1<<STT_COMMON | 1<<STT_TLS)
> + #define OK_BINDS (1<<STB_GLOBAL | 1<<STB_WEAK | 1<<STB_GNU_UNIQUE)
> + 
> ++#ifndef ARCH_SYM_REJECT_UND
> ++#define ARCH_SYM_REJECT_UND(s) 0
> ++#endif
> ++
> + static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
> + {
> + 	uint32_t h = 0, gh = 0;
> +@@ -249,7 +253,8 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
> + 		}
> + 		if (!sym) continue;
> + 		if (!sym->st_shndx)
> +-			if (need_def || (sym->st_info&0xf) == STT_TLS)
> ++			if (need_def || (sym->st_info&0xf) == STT_TLS
> ++			    || ARCH_SYM_REJECT_UND(sym))
> + 				continue;
> + 		if (!sym->st_value)
> + 			if ((sym->st_info&0xf) != STT_TLS)
> +--
> +cgit v0.9.0.3-65-g4555
> diff --git a/patches/musl/1.1.3/0001-fix_linker_regression.patch b/patches/musl/1.1.3/0001-fix_linker_regression.patch
> new file mode 100644
> index 0000000..801cb00
> --- /dev/null
> +++ b/patches/musl/1.1.3/0001-fix_linker_regression.patch
> @@ -0,0 +1,64 @@
> +From 9a4ad02214a859e93d2c980e4535378a6a74e3a6 Mon Sep 17 00:00:00 2001
> +From: Rich Felker <dalias@aerifal.cx>
> +Date: Mon, 30 Jun 2014 01:52:54 +0000
> +Subject: fix regression in dynamic linker error reporting
> +
> +due to a mistake when refactoring the error printing for the dynamic
> +linker (commit 7c73cacd09a51a87484db5689864743e4984a84d), all messages
> +were suppressed and replaced by blank lines.
> +---
> +diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
> +index bc4f2f6..a08300d 100644
> +--- a/src/ldso/dynlink.c
> ++++ b/src/ldso/dynlink.c
> +@@ -290,8 +290,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 		if (!astype) continue;
> + 		type = remap_rel(astype);
> + 		if (!type) {
> +-			error(errbuf, sizeof errbuf,
> +-				"Error relocating %s: unsupported relocation type %d",
> ++			error("Error relocating %s: unsupported relocation type %d",
> + 				dso->name, astype);
> + 			continue;
> + 		}
> +@@ -304,8 +303,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 			def = find_sym(ctx, name, type==REL_PLT);
> + 			if (!def.sym && (sym->st_shndx != SHN_UNDEF
> + 			    || sym->st_info>>4 != STB_WEAK)) {
> +-				error(errbuf, sizeof errbuf,
> +-					"Error relocating %s: %s: symbol not found",
> ++				error("Error relocating %s: %s: symbol not found",
> + 					dso->name, name);
> + 				continue;
> + 			}
> +@@ -366,7 +364,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
> + 			if (stride<3) addend = reloc_addr[1];
> + 			if (runtime && def.dso->tls_id >= static_tls_cnt) {
> + 				struct td_index *new = malloc(sizeof *new);
> +-				if (!new) error(errbuf, sizeof errbuf,
> ++				if (!new) error(
> + 					"Error relocating %s: cannot allocate TLSDESC for %s",
> + 					dso->name, sym ? name : "(local)" );
> + 				new->next = dso->td_index;
> +@@ -839,8 +837,7 @@ static void load_deps(struct dso *p)
> + 			if (p->dynv[i] != DT_NEEDED) continue;
> + 			dep = load_library(p->strings + p->dynv[i+1], p);
> + 			if (!dep) {
> +-				error(errbuf, sizeof errbuf,
> +-					"Error loading shared library %s: %m (needed by %s)",
> ++				error("Error loading shared library %s: %m (needed by %s)",
> + 					p->strings + p->dynv[i+1], p->name);
> + 				continue;
> + 			}
> +@@ -890,8 +887,7 @@ static void reloc_all(struct dso *p)
> + 
> + 		if (p->relro_start != p->relro_end &&
> + 		    mprotect(p->base+p->relro_start, p->relro_end-p->relro_start, PROT_READ) < 0) {
> +-			error(errbuf, sizeof errbuf,
> +-				"Error relocating %s: RELRO protection failed: %m",
> ++			error("Error relocating %s: RELRO protection failed: %m",
> + 				p->name);
> + 		}
> + 
> +--
> +cgit v0.9.0.3-65-g4555
> diff --git a/patches/musl/1.1.3/0002-fix_mips_linker_regression.patch b/patches/musl/1.1.3/0002-fix_mips_linker_regression.patch
> new file mode 100644
> index 0000000..4891b4f
> --- /dev/null
> +++ b/patches/musl/1.1.3/0002-fix_mips_linker_regression.patch
> @@ -0,0 +1,88 @@
> +From 2d8cc92a7cb4a3256ed07d86843388ffd8a882b1 Mon Sep 17 00:00:00 2001
> +From: Rich Felker <dalias@aerifal.cx>
> +Date: Mon, 30 Jun 2014 05:18:14 +0000
> +Subject: fix regression in mips dynamic linker
> +
> +this issue caused the address of functions in shared libraries to
> +resolve to their PLT thunks in the main program rather than their
> +correct addresses. it was observed causing crashes, though the
> +mechanism of the crash was not thoroughly investigated. since the
> +issue is very subtle, it calls for some explanation:
> +
> +on all well-behaved archs, GOT entries that belong to the PLT use a
> +special relocation type, typically called JMP_SLOT, so that the
> +dynamic linker can avoid having the jump destinations for the PLT
> +resolve to PLT thunks themselves (they also provide a definition for
> +the symbol, which must be used whenever the address of the function is
> +taken so that all DSOs see the same address).
> +
> +however, the traditional mips PIC ABI lacked such a JMP_SLOT
> +relocation type, presumably because, due to the way PIC works, the
> +address of the PLT thunk was never needed and could always be ignored.
> +
> +prior to commit adf94c19666e687a728bbf398f9a88ea4ea19996, the mips
> +version of reloc.h contained a hack that caused all symbol lookups to
> +be treated like JMP_SLOT, inhibiting undefined symbols from ever being
> +used to resolve symbolic relocations. this hack goes all the way back
> +to commit babf820180368f00742ec65b2050a82380d7c542, when the mips
> +dynamic linker was first made usable.
> +
> +during the recent refactoring to eliminate arch-specific relocation
> +processing (commit adf94c19666e687a728bbf398f9a88ea4ea19996), this
> +hack was overlooked and no equivalent functionality was provided in
> +the new code.
> +
> +fixing the problem is not as simple as adding back an equivalent hack,
> +since there is now also a "non-PIC ABI" that can be used for the main
> +executable, which actually does use a PLT. the closest thing to
> +official documentation I could find for this ABI is nonpic.txt,
> +attached to Message-ID: 20080701202236.GA1534@caradoc.them.org, which
> +can be found in the gcc mailing list archives and elsewhere. per this
> +document, undefined symbols corresponding to PLT thunks have the
> +STO_MIPS_PLT bit set in the symbol's st_other field. thus, I have
> +added an arch-specific rule for mips, applied at the find_sym level
> +rather than the relocation level, to reject undefined symbols with the
> +STO_MIPS_PLT bit clear.
> +
> +the previous hack of treating all mips relocations as JMP_SLOT-like,
> +rather than rejecting the unwanted symbols in find_sym, probably also
> +caused dlsym to wrongly return PLT thunks in place of the correct
> +address of a function under at least some conditions. this should now
> +be fixed, at least for global-scope symbol lookups.
> +---
> +diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
> +index 91fa097..4b81d32 100644
> +--- a/arch/mips/reloc.h
> ++++ b/arch/mips/reloc.h
> +@@ -86,3 +86,4 @@ static void do_arch_relocs(struct dso *this, struct dso *head)
> + 
> + #define NEED_ARCH_RELOCS 1
> + #define DYNAMIC_IS_RO 1
> ++#define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
> +diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
> +index a08300d..55124ff 100644
> +--- a/src/ldso/dynlink.c
> ++++ b/src/ldso/dynlink.c
> +@@ -233,6 +233,10 @@ static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
> + #define OK_TYPES (1<<STT_NOTYPE | 1<<STT_OBJECT | 1<<STT_FUNC | 1<<STT_COMMON | 1<<STT_TLS)
> + #define OK_BINDS (1<<STB_GLOBAL | 1<<STB_WEAK | 1<<STB_GNU_UNIQUE)
> + 
> ++#ifndef ARCH_SYM_REJECT_UND
> ++#define ARCH_SYM_REJECT_UND(s) 0
> ++#endif
> ++
> + static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
> + {
> + 	uint32_t h = 0, gh = 0;
> +@@ -249,7 +253,8 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
> + 		}
> + 		if (!sym) continue;
> + 		if (!sym->st_shndx)
> +-			if (need_def || (sym->st_info&0xf) == STT_TLS)
> ++			if (need_def || (sym->st_info&0xf) == STT_TLS
> ++			    || ARCH_SYM_REJECT_UND(sym))
> + 				continue;
> + 		if (!sym->st_value)
> + 			if ((sym->st_info&0xf) != STT_TLS)
> +--
> +cgit v0.9.0.3-65-g4555
> diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh
> index 430bdde..5f6ce2f 100644
> --- a/scripts/build/arch/arm.sh
> +++ b/scripts/build/arch/arm.sh
> @@ -17,6 +17,7 @@ CT_DoArchTupleValues() {
>      case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in
>          *glibc,y)   CT_TARGET_SYS=gnueabi;;
>          uClibc,y)   CT_TARGET_SYS=uclibcgnueabi;;
> +        musl,y)     CT_TARGET_SYS=musleabi;;
>          *,y)        CT_TARGET_SYS=eabi;;
>      esac
>  
> diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh
> new file mode 100644
> index 0000000..536267c
> --- /dev/null
> +++ b/scripts/build/libc/musl.sh
> @@ -0,0 +1,128 @@
> +# This file adds functions to build the musl C library
> +# Copyright 2013 Timo TerÃÂs
> +# Licensed under the GPL v2. See COPYING in the root of this package
> +
> +do_libc_get() {
> +    local libc_src
> +
> +    libc_src="http://www.musl-libc.org/releases";
> +
> +    if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then
> +        CT_GetCustom "musl" "${CT_LIBC_VERSION}"      \
> +                     "${CT_LIBC_MUSL_CUSTOM_LOCATION}"
> +    else # ! custom location
> +        CT_GetFile "musl-${CT_LIBC_VERSION}" "${libc_src}"
> +    fi # ! custom location
> +}
> +
> +do_libc_extract() {
> +    # If using custom directory location, nothing to do.
> +    if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then
> +        # Abort if the custom directory is not found.
> +        if ! [ -d "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" ]; then
> +            CT_Abort "Directory not found: ${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}"
> +        fi
> +
> +        return 0
> +    fi
> +
> +    CT_Extract "musl-${CT_LIBC_VERSION}"
> +    CT_Patch "musl" "${CT_LIBC_VERSION}"
> +}
> +
> +do_libc_check_config() {
> +    :
> +}
> +
> +do_libc_configure() {
> +    CT_DoLog EXTRA "Configuring C library"
> +    local -a extra_cflags
> +
> +    # From buildroot:
> +    # gcc constant folding bug with weak aliases workaround
> +    # See http://www.openwall.com/lists/musl/2014/05/15/1
> +    if [ "${CT_CC_GCC_4_9_or_later}" = "y" ]; then
> +        extra_cflags+=("-fno-toplevel-reorder")
> +    fi
> +
> +    # NOTE: musl handles the build/host/target a little bit differently
> +    # then one would expect:
> +    #   build   : not used
> +    #   host    : the machine building musl
> +    #   target  : the machine musl runs on
> +    CT_DoExecLog CFG                \
> +    CFLAGS="${extra_cflags[@]}"     \
> +    CROSS_COMPILE="${CT_TARGET}-"   \
> +    ./configure                     \
> +        --host="${CT_TARGET}"       \
> +        --target="${CT_TARGET}"     \
> +        --prefix="/usr"             \
> +        --disable-gcc-wrapper
> +}
> +
> +do_get_arch() {
> +    local ARCH=""
> +
> +    # musl can be installed without gcc if arch is known
> +    case "${CT_TARGET}" in
> +        arm*) ARCH=arm ;;
> +        i?86*) ARCH=i386 ;;
> +        x86_64*) ARCH=x86_64 ;;
> +        mips-*|mipsel-*) ARCH=mips ;;
> +        microblaze-*) ARCH=microblaze ;;
> +        powerpc-*) ARCH=powerpc ;;
> +        sh-*|sh[34]-*) ARCH=sh ;;
> +        x32-*) ARCH=x32 ;;
> +        *) ARCH="" ;;
> +    esac
> +
> +    echo "${ARCH}"
> +}
> +
> +do_libc_start_files() {
> +    #local ARCH="$(do_get_arch)"
> +    CT_DoStep INFO "Installing C library headers"
> +
> +    # Simply copy files until musl has the ability to build out-of-tree
> +    CT_DoLog EXTRA "Copying sources to build directory"
> +    CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" \
> +                            "${CT_BUILD_DIR}/build-libc-headers"
> +    cd "${CT_BUILD_DIR}/build-libc-headers"
> +
> +    do_libc_configure
> +
> +    CT_DoLog EXTRA "Installing headers"
> +    #CT_DoExecLog ALL make ARCH="${ARCH}" DESTDIR="${CT_SYSROOT_DIR}" install-headers
> +    CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install-headers
> +
> +    #CT_DoExecLog ALL make ARCH="${ARCH}" DESTDIR="${CT_SYSROOT_DIR}" \
> +    CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" \
> +        crt/crt1.o crt/crti.o crt/crtn.o
> +    CT_DoExecLog ALL cp -av crt/crt*.o "${CT_SYSROOT_DIR}/usr/lib"
> +    CT_DoExecLog ALL ${CT_TARGET}-gcc -nostdlib \
> +        -nostartfiles -shared -x c /dev/null -o "${CT_SYSROOT_DIR}/usr/lib/libc.so"
> +    CT_EndStep
> +}
> +
> +do_libc() {
> +    #local ARCH="$(do_get_arch)"
> +    CT_DoStep INFO "Installing C library"
> +
> +    # Simply copy files until musl has the ability to build out-of-tree
> +    CT_DoLog EXTRA "Copying sources to build directory"
> +    CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/musl-${CT_LIBC_VERSION}" \
> +                            "${CT_BUILD_DIR}/build-libc"
> +    cd "${CT_BUILD_DIR}/build-libc"
> +
> +    do_libc_configure
> +
> +    CT_DoLog EXTRA "Building C library"
> +    #CT_DoExecLog ALL make ARCH="${ARCH}" ${JOBSFLAGS}
> +    CT_DoExecLog ALL make ${JOBSFLAGS}
> +
> +    CT_DoLog EXTRA "Installing C library"
> +    #CT_DoExecLog ALL make ARCH="${ARCH}" DESTDIR="${CT_SYSROOT_DIR}" install
> +    CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
> +
> +    CT_EndStep
> +}
> diff --git a/scripts/functions b/scripts/functions
> index 2e4d4fa..eae3b95 100644
> --- a/scripts/functions
> +++ b/scripts/functions
> @@ -1182,6 +1182,7 @@ CT_DoBuildTargetTuple() {
>      case "${CT_LIBC}" in
>          *glibc) CT_TARGET_SYS=gnu;;
>          uClibc) CT_TARGET_SYS=uclibc;;
> +        musl)   CT_TARGET_SYS=musl;;
>          *)      CT_TARGET_SYS=elf;;
>      esac
>  
> -- 
> 2.0.1
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]