1 diff --git a/config.sub b/config.sub
5 # Here we must recognize all the valid KERNEL-OS combinations.
6 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
8 - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
9 + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | linux-musl* | \
10 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
11 storm-chaos* | os2-emx* | rtmk-nova*)
14 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
15 | -chorusos* | -chorusrdb* \
16 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
17 - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
18 + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* | -linux-musl* \
19 | -uxpv* | -beos* | -mpeix* | -udk* \
20 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
21 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
22 diff --git a/gcc/config.gcc b/gcc/config.gcc
26 tmake_file="t-slibgcc-elf-ver t-linux"
29 - tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
30 + tm_defines="${tm_defines} UCLIBC_DEFAULT=1 MUSL_DEFAULT=0"
33 + tm_defines="$tm_defines UCLIBC_DEFAULT=0 MUSL_DEFAULT=1"
36 - tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
37 + tm_defines="${tm_defines} UCLIBC_DEFAULT=0 MUSL_DEFAULT=1"
40 # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
41 diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
42 --- a/gcc/config/arm/linux-eabi.h
43 +++ b/gcc/config/arm/linux-eabi.h
45 #undef GLIBC_DYNAMIC_LINKER
46 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
48 +/* musl has no "classic" (i.e. broken) mode */
49 +#undef MUSL_DYNAMIC_LINKER
50 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
52 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
53 use the GNU/Linux version, not the generic BPABI version. */
55 diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
56 --- a/gcc/config/i386/linux.h
57 +++ b/gcc/config/i386/linux.h
59 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
60 #define LINK_EMULATION "elf_i386"
61 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
62 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
64 #undef SUBTARGET_EXTRA_SPECS
65 #define SUBTARGET_EXTRA_SPECS \
66 diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
67 --- a/gcc/config/i386/linux64.h
68 +++ b/gcc/config/i386/linux64.h
70 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
71 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
73 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
74 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
77 #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
79 diff --git a/gcc/config/linux.h b/gcc/config/linux.h
80 --- a/gcc/config/linux.h
81 +++ b/gcc/config/linux.h
83 uClibc is the default C library and whether -muclibc or -mglibc has
84 been passed to change the default. */
86 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
87 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mmusl:" M ";:%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}}"
88 +#elif defined(MUSL_DEFAULT)
89 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
91 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
92 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mmusl:" M ";:%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}}"
95 /* For most targets the following definitions suffice;
97 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
98 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
99 #define LINUX_DYNAMIC_LINKER \
100 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
101 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
102 #define LINUX_DYNAMIC_LINKER32 \
103 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
104 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
105 #define LINUX_DYNAMIC_LINKER64 \
106 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
107 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
109 /* Determine whether the entire c99 runtime
110 is present in the runtime library. */
111 diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
112 --- a/gcc/config/linux.opt
113 +++ b/gcc/config/linux.opt
115 Use uClibc instead of GNU libc
118 -Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists
119 +Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists InverseMask(MUSL, GLIBC) Var(linux_musl) VarExists
120 Use GNU libc instead of uClibc
123 +Target RejectNegative Report Mask(MUSL) Var(linux_musl) Init(MUSL_DEFAULT ? OPTION_MASK_MUSL : 0)
125 diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
126 --- a/gcc/config/mips/linux.h
127 +++ b/gcc/config/mips/linux.h
130 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
132 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
134 /* Borrowed from sparc/linux.h */
137 diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
138 --- a/gcc/ginclude/stddef.h
139 +++ b/gcc/ginclude/stddef.h
144 +#ifndef __DEFINED_size_t /* musl */
145 #define __size_t__ /* BeOS */
146 #define __SIZE_T__ /* Cray Unicos/Mk */
149 #define ___int_size_t_h
152 +#define __DEFINED_size_t /* musl */
153 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
154 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
157 typedef long ssize_t;
158 #endif /* __BEOS__ */
159 #endif /* !(defined (__GNUG__) && defined (size_t)) */
160 +#endif /* __DEFINED_size_t */
161 #endif /* __size_t */
163 #endif /* _GCC_SIZE_T */
164 diff --git a/libgomp/config/posix/time.c b/libgomp/config/posix/time.c
165 --- a/libgomp/config/posix/time.c
166 +++ b/libgomp/config/posix/time.c
168 The following implementation uses the most simple POSIX routines.
169 If present, POSIX 4 clocks should be used instead. */
171 +#define _POSIX_C_SOURCE 199309L /* for clocks */
175 #if TIME_WITH_SYS_TIME
176 diff --git a/libgomp/env.c b/libgomp/env.c
180 /* This file defines the OpenMP internal control variables, and arranges
181 for them to be initialized from environment variables at startup. */
186 #include "libgomp_f.h"
188 diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
189 --- a/libstdc++-v3/configure.host
190 +++ b/libstdc++-v3/configure.host
191 @@ -211,12 +211,22 @@
192 os_include_dir="os/bsd/freebsd"
194 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
195 + # check for musl by target
196 + case "${host_os}" in
198 + os_include_dir="os/generic"
202 if [ "$uclibc" = "yes" ]; then
203 os_include_dir="os/uclibc"
205 os_include_dir="os/gnu-linux"
212 os_include_dir="os/hpux"