summaryrefslogtreecommitdiff
path: root/toolchain
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2013-08-11 18:07:39 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2013-08-11 18:07:39 +0200
commit36a26b341d49d90e5b936278478134aa178a0238 (patch)
tree2c5bd0adacb775f849c82e5942a3bfb9061c8a5a /toolchain
parent16de5fcccc6de9d6df017078fb02f775514c1b9b (diff)
preliminary musl support
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/Makefile4
-rw-r--r--toolchain/binutils/patches/2.22/musl.patch20
-rw-r--r--toolchain/gcc/patches/4.7.3/musl.patch360
-rw-r--r--toolchain/musl/Makefile29
-rw-r--r--toolchain/musl/Makefile.inc9
5 files changed, 422 insertions, 0 deletions
diff --git a/toolchain/Makefile b/toolchain/Makefile
index ed5f2652c..5c27e1aa1 100644
--- a/toolchain/Makefile
+++ b/toolchain/Makefile
@@ -26,6 +26,10 @@ ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
TARGETS+=uClibc
LIBC:=uClibc
endif
+ifeq ($(ADK_TARGET_LIB_MUSL),y)
+TARGETS+=musl
+LIBC:=musl
+endif
ifeq ($(ADK_TOOLCHAIN_GDB),y)
TARGETS+=gdb
endif
diff --git a/toolchain/binutils/patches/2.22/musl.patch b/toolchain/binutils/patches/2.22/musl.patch
new file mode 100644
index 000000000..4ea53c18f
--- /dev/null
+++ b/toolchain/binutils/patches/2.22/musl.patch
@@ -0,0 +1,20 @@
+diff -Nur binutils-2.22.orig/config.sub binutils-2.22/config.sub
+--- binutils-2.22.orig/config.sub 2011-06-06 12:36:06.000000000 +0200
++++ binutils-2.22/config.sub 2013-08-11 14:40:22.308115171 +0200
+@@ -126,6 +126,7 @@
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
++ linux-musl* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+@@ -1334,7 +1335,7 @@
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+- | -linux-newlib* | -linux-uclibc* \
++ | -linux-newlib* | -linux-uclibc* | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/toolchain/gcc/patches/4.7.3/musl.patch b/toolchain/gcc/patches/4.7.3/musl.patch
new file mode 100644
index 000000000..4da8ce564
--- /dev/null
+++ b/toolchain/gcc/patches/4.7.3/musl.patch
@@ -0,0 +1,360 @@
+diff -Nur gcc-4.7.3.orig/config.sub gcc-4.7.3/config.sub
+--- gcc-4.7.3.orig/config.sub 2012-08-06 16:34:27.000000000 +0200
++++ gcc-4.7.3/config.sub 2013-08-11 14:20:23.979180205 +0200
+@@ -125,6 +125,7 @@
+ 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* | \
+diff -Nur gcc-4.7.3.orig/fixincludes/mkfixinc.sh gcc-4.7.3/fixincludes/mkfixinc.sh
+--- gcc-4.7.3.orig/fixincludes/mkfixinc.sh 2011-09-22 16:00:17.000000000 +0200
++++ gcc-4.7.3/fixincludes/mkfixinc.sh 2013-08-11 14:17:48.905129751 +0200
+@@ -20,7 +20,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}
+diff -Nur gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h gcc-4.7.3/gcc/config/arm/linux-eabi.h
+--- gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h 2011-11-02 16:03:19.000000000 +0100
++++ gcc-4.7.3/gcc/config/arm/linux-eabi.h 2013-08-11 14:17:15.153554066 +0200
+@@ -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 -Nur gcc-4.7.3.orig/gcc/config/i386/linux64.h gcc-4.7.3/gcc/config/i386/linux64.h
+--- gcc-4.7.3.orig/gcc/config/i386/linux64.h 2011-07-07 17:38:34.000000000 +0200
++++ gcc-4.7.3/gcc/config/i386/linux64.h 2013-08-11 14:17:15.157554016 +0200
+@@ -31,3 +31,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 -Nur gcc-4.7.3.orig/gcc/config/i386/linux.h gcc-4.7.3/gcc/config/i386/linux.h
+--- gcc-4.7.3.orig/gcc/config/i386/linux.h 2011-06-03 20:30:39.000000000 +0200
++++ gcc-4.7.3/gcc/config/i386/linux.h 2013-08-11 14:17:15.153554066 +0200
+@@ -22,3 +22,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 -Nur gcc-4.7.3.orig/gcc/config/linux.h gcc-4.7.3/gcc/config/linux.h
+--- gcc-4.7.3.orig/gcc/config/linux.h 2012-08-14 15:59:04.000000000 +0200
++++ gcc-4.7.3/gcc/config/linux.h 2013-08-11 14:17:15.169553864 +0200
+@@ -33,10 +33,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() \
+@@ -54,18 +56,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 */
+@@ -85,16 +90,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 -Nur gcc-4.7.3.orig/gcc/config/linux.opt gcc-4.7.3/gcc/config/linux.opt
+--- gcc-4.7.3.orig/gcc/config/linux.opt 2010-09-29 16:51:52.000000000 +0200
++++ gcc-4.7.3/gcc/config/linux.opt 2013-08-11 14:17:15.169553864 +0200
+@@ -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 -Nur gcc-4.7.3.orig/gcc/config/mips/linux64.h gcc-4.7.3/gcc/config/mips/linux64.h
+--- gcc-4.7.3.orig/gcc/config/mips/linux64.h 2011-07-19 20:00:27.000000000 +0200
++++ gcc-4.7.3/gcc/config/mips/linux64.h 2013-08-11 14:17:15.357551501 +0200
+@@ -28,6 +28,9 @@
+ #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
+diff -Nur gcc-4.7.3.orig/gcc/config/mips/linux.h gcc-4.7.3/gcc/config/mips/linux.h
+--- gcc-4.7.3.orig/gcc/config/mips/linux.h 2011-07-19 20:00:27.000000000 +0200
++++ gcc-4.7.3/gcc/config/mips/linux.h 2013-08-11 14:17:15.169553864 +0200
+@@ -19,3 +19,5 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
+diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/linux64.h gcc-4.7.3/gcc/config/rs6000/linux64.h
+--- gcc-4.7.3.orig/gcc/config/rs6000/linux64.h 2012-03-12 17:16:51.000000000 +0100
++++ gcc-4.7.3/gcc/config/rs6000/linux64.h 2013-08-11 14:17:15.169553864 +0200
+@@ -362,17 +362,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 -Nur gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h gcc-4.7.3/gcc/config/rs6000/sysv4.h
+--- gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h 2012-04-30 19:39:01.000000000 +0200
++++ gcc-4.7.3/gcc/config/rs6000/sysv4.h 2013-08-11 14:17:15.173553814 +0200
+@@ -804,15 +804,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} \
+diff -Nur gcc-4.7.3.orig/gcc/config.gcc gcc-4.7.3/gcc/config.gcc
+--- gcc-4.7.3.orig/gcc/config.gcc 2013-03-06 23:54:11.000000000 +0100
++++ gcc-4.7.3/gcc/config.gcc 2013-08-11 14:17:15.141554216 +0200
+@@ -522,7 +522,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
+@@ -625,6 +625,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 -Nur gcc-4.7.3.orig/gcc/configure gcc-4.7.3/gcc/configure
+--- gcc-4.7.3.orig/gcc/configure 2013-02-06 16:23:55.000000000 +0100
++++ gcc-4.7.3/gcc/configure 2013-08-11 14:17:42.205213980 +0200
+@@ -26902,6 +26902,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 -Nur gcc-4.7.3.orig/gcc/ginclude/stddef.h gcc-4.7.3/gcc/ginclude/stddef.h
+--- gcc-4.7.3.orig/gcc/ginclude/stddef.h 2012-02-12 02:06:04.000000000 +0100
++++ gcc-4.7.3/gcc/ginclude/stddef.h 2013-08-11 14:17:15.349551601 +0200
+@@ -184,6 +184,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
+@@ -200,6 +201,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. */
+@@ -215,6 +217,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 */
+diff -Nur gcc-4.7.3.orig/libgomp/config/posix/time.c gcc-4.7.3/libgomp/config/posix/time.c
+--- gcc-4.7.3.orig/libgomp/config/posix/time.c 2009-04-09 17:00:19.000000000 +0200
++++ gcc-4.7.3/libgomp/config/posix/time.c 2013-08-11 14:17:15.349551601 +0200
+@@ -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 -Nur gcc-4.7.3.orig/libitm/config/arm/hwcap.cc gcc-4.7.3/libitm/config/arm/hwcap.cc
+--- gcc-4.7.3.orig/libitm/config/arm/hwcap.cc 2011-12-15 04:24:05.000000000 +0100
++++ gcc-4.7.3/libitm/config/arm/hwcap.cc 2013-08-11 14:17:15.353551551 +0200
+@@ -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))
+diff -Nur gcc-4.7.3.orig/libitm/config/linux/x86/tls.h gcc-4.7.3/libitm/config/linux/x86/tls.h
+--- gcc-4.7.3.orig/libitm/config/linux/x86/tls.h 2011-11-08 12:13:41.000000000 +0100
++++ gcc-4.7.3/libitm/config/linux/x86/tls.h 2013-08-11 14:17:15.353551551 +0200
+@@ -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 -Nur gcc-4.7.3.orig/libstdc++-v3/configure.host gcc-4.7.3/libstdc++-v3/configure.host
+--- gcc-4.7.3.orig/libstdc++-v3/configure.host 2012-12-18 15:27:14.000000000 +0100
++++ gcc-4.7.3/libstdc++-v3/configure.host 2013-08-11 14:17:15.357551501 +0200
+@@ -243,6 +243,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
+@@ -251,6 +258,9 @@
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
diff --git a/toolchain/musl/Makefile b/toolchain/musl/Makefile
new file mode 100644
index 000000000..3955e3eda
--- /dev/null
+++ b/toolchain/musl/Makefile
@@ -0,0 +1,29 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(TOPDIR)/rules.mk
+include ../rules.mk
+include Makefile.inc
+include ${TOPDIR}/mk/buildhlp.mk
+
+$(WRKBUILD)/.headers:
+ (cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' ./configure --prefix=/usr \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-gcc-wrapper \
+ )
+ $(MAKE) -C $(WRKBUILD) DESTDIR=$(STAGING_TARGET_DIR) install-headers
+ touch $(WRKBUILD)/.configured
+ touch $@
+
+$(WRKBUILD)/.compiled:
+ $(MAKE) -C $(WRKBUILD) all
+ touch $@
+
+$(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
+ $(MAKE) -C $(WRKBUILD) DESTDIR=$(STAGING_TARGET_DIR) install
+ touch $@
+
+$(WRKBUILD)/.fixup:
+ touch $@
+
+include ${TOPDIR}/mk/toolchain.mk
diff --git a/toolchain/musl/Makefile.inc b/toolchain/musl/Makefile.inc
new file mode 100644
index 000000000..068c07ef8
--- /dev/null
+++ b/toolchain/musl/Makefile.inc
@@ -0,0 +1,9 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+PKG_NAME:= musl
+PKG_VERSION:= 0.9.12
+PKG_RELEASE:= 1
+PKG_MD5SUM:= 100c8e932d0785c35b92539f025aa76f
+PKG_SITES:= http://www.musl-libc.org/releases/
+DISTFILES:= $(PKG_NAME)-$(PKG_VERSION).tar.gz