You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
12 KiB

  1. --- a/gcc/config.gcc
  2. +++ b/gcc/config.gcc
  3. @@ -549,7 +549,7 @@ case ${target} in
  4. esac
  5. # Common C libraries.
  6. -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
  7. +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
  8. # Common parts for widely ported systems.
  9. case ${target} in
  10. @@ -652,6 +652,9 @@ case ${target} in
  11. *-*-*uclibc*)
  12. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
  13. ;;
  14. + *-*-*musl*)
  15. + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
  16. + ;;
  17. *)
  18. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
  19. ;;
  20. --- a/gcc/config/arm/linux-eabi.h
  21. +++ b/gcc/config/arm/linux-eabi.h
  22. @@ -77,6 +77,10 @@
  23. %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
  24. %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
  25. +/* musl has no "classic" (i.e. broken) mode */
  26. +#undef MUSL_DYNAMIC_LINKER
  27. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
  28. +
  29. /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
  30. use the GNU/Linux version, not the generic BPABI version. */
  31. #undef LINK_SPEC
  32. --- a/gcc/config/i386/linux.h
  33. +++ b/gcc/config/i386/linux.h
  34. @@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
  35. #define GNU_USER_LINK_EMULATION "elf_i386"
  36. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  37. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
  38. --- a/gcc/config/i386/linux64.h
  39. +++ b/gcc/config/i386/linux64.h
  40. @@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI
  41. #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
  42. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
  43. #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
  44. +
  45. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
  46. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
  47. +#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
  48. --- a/gcc/config/linux.h
  49. +++ b/gcc/config/linux.h
  50. @@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
  51. #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
  52. #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
  53. #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
  54. +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
  55. #else
  56. #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
  57. #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
  58. #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
  59. +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
  60. #endif
  61. #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
  62. @@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTI
  63. uClibc or Bionic is the default C library and whether
  64. -muclibc or -mglibc or -mbionic has been passed to change the default. */
  65. -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
  66. - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
  67. +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
  68. + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
  69. #if DEFAULT_LIBC == LIBC_GLIBC
  70. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  71. - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
  72. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  73. + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
  74. #elif DEFAULT_LIBC == LIBC_UCLIBC
  75. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  76. - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
  77. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  78. + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
  79. #elif DEFAULT_LIBC == LIBC_BIONIC
  80. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  81. - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
  82. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  83. + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
  84. +#elif DEFAULT_LIBC == LIBC_MUSL
  85. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  86. + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
  87. #else
  88. #error "Unsupported DEFAULT_LIBC"
  89. #endif /* DEFAULT_LIBC */
  90. @@ -84,16 +89,16 @@ see the files COPYING3 and COPYING.RUNTI
  91. #define GNU_USER_DYNAMIC_LINKER \
  92. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
  93. - BIONIC_DYNAMIC_LINKER)
  94. + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  95. #define GNU_USER_DYNAMIC_LINKER32 \
  96. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
  97. - BIONIC_DYNAMIC_LINKER32)
  98. + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  99. #define GNU_USER_DYNAMIC_LINKER64 \
  100. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
  101. - BIONIC_DYNAMIC_LINKER64)
  102. + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  103. #define GNU_USER_DYNAMIC_LINKERX32 \
  104. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
  105. - BIONIC_DYNAMIC_LINKERX32)
  106. + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
  107. /* Determine whether the entire c99 runtime
  108. is present in the runtime library. */
  109. --- a/gcc/config/linux.opt
  110. +++ b/gcc/config/linux.opt
  111. @@ -30,3 +30,7 @@ Use GNU C library
  112. muclibc
  113. Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
  114. Use uClibc C library
  115. +
  116. +mmusl
  117. +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
  118. +Use musl C library
  119. --- a/gcc/config/mips/linux.h
  120. +++ b/gcc/config/mips/linux.h
  121. @@ -18,3 +18,5 @@ along with GCC; see the file COPYING3.
  122. <http://www.gnu.org/licenses/>. */
  123. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  124. +
  125. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
  126. --- a/gcc/config/rs6000/linux64.h
  127. +++ b/gcc/config/rs6000/linux64.h
  128. @@ -364,17 +364,21 @@ extern int dot_symbols;
  129. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
  130. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  131. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  132. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
  133. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
  134. #if DEFAULT_LIBC == LIBC_UCLIBC
  135. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  136. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  137. #elif DEFAULT_LIBC == LIBC_GLIBC
  138. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  139. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  140. +#elif DEFAULT_LIBC == LIBC_MUSL
  141. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  142. #else
  143. #error "Unsupported DEFAULT_LIBC"
  144. #endif
  145. #define GNU_USER_DYNAMIC_LINKER32 \
  146. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  147. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  148. #define GNU_USER_DYNAMIC_LINKER64 \
  149. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  150. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  151. #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
  152. --- a/gcc/config/rs6000/sysv4.h
  153. +++ b/gcc/config/rs6000/sysv4.h
  154. @@ -789,15 +789,18 @@ extern int fixuplabelno;
  155. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  156. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  157. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
  158. #if DEFAULT_LIBC == LIBC_UCLIBC
  159. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  160. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  161. +#elif DEFAULT_LIBC == LIBC_MUSL
  162. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  163. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  164. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  165. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  166. #else
  167. #error "Unsupported DEFAULT_LIBC"
  168. #endif
  169. #define GNU_USER_DYNAMIC_LINKER \
  170. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  171. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  172. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  173. %{rdynamic:-export-dynamic} \
  174. --- a/gcc/ginclude/stddef.h
  175. +++ b/gcc/ginclude/stddef.h
  176. @@ -181,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  177. #ifndef _GCC_SIZE_T
  178. #ifndef _SIZET_
  179. #ifndef __size_t
  180. +#ifndef __DEFINED_size_t /* musl */
  181. #define __size_t__ /* BeOS */
  182. #define __SIZE_T__ /* Cray Unicos/Mk */
  183. #define _SIZE_T
  184. @@ -197,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  185. #define ___int_size_t_h
  186. #define _GCC_SIZE_T
  187. #define _SIZET_
  188. +#define __DEFINED_size_t /* musl */
  189. #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
  190. || defined(__FreeBSD_kernel__)
  191. /* __size_t is a typedef on FreeBSD 5, must not trash it. */
  192. @@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
  193. typedef long ssize_t;
  194. #endif /* __BEOS__ */
  195. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  196. +#endif /* __DEFINED_size_t */
  197. #endif /* __size_t */
  198. #endif /* _SIZET_ */
  199. #endif /* _GCC_SIZE_T */
  200. --- a/libgomp/config/posix/time.c
  201. +++ b/libgomp/config/posix/time.c
  202. @@ -28,6 +28,8 @@
  203. The following implementation uses the most simple POSIX routines.
  204. If present, POSIX 4 clocks should be used instead. */
  205. +#define _POSIX_C_SOURCE 199309L /* for clocks */
  206. +
  207. #include "libgomp.h"
  208. #include <unistd.h>
  209. #if TIME_WITH_SYS_TIME
  210. --- a/libitm/config/arm/hwcap.cc
  211. +++ b/libitm/config/arm/hwcap.cc
  212. @@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
  213. #ifdef __linux__
  214. #include <unistd.h>
  215. +#ifdef __GLIBC__
  216. #include <sys/fcntl.h>
  217. +#else
  218. +#include <fcntl.h>
  219. +#endif
  220. #include <elf.h>
  221. static void __attribute__((constructor))
  222. --- a/libitm/config/linux/x86/tls.h
  223. +++ b/libitm/config/linux/x86/tls.h
  224. @@ -25,16 +25,19 @@
  225. #ifndef LIBITM_X86_TLS_H
  226. #define LIBITM_X86_TLS_H 1
  227. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  228. +#if defined(__GLIBC_PREREQ)
  229. +#if __GLIBC_PREREQ(2, 10)
  230. /* Use slots in the TCB head rather than __thread lookups.
  231. GLIBC has reserved words 10 through 13 for TM. */
  232. #define HAVE_ARCH_GTM_THREAD 1
  233. #define HAVE_ARCH_GTM_THREAD_DISP 1
  234. #endif
  235. +#endif
  236. #include "config/generic/tls.h"
  237. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  238. +#if defined(__GLIBC_PREREQ)
  239. +#if __GLIBC_PREREQ(2, 10)
  240. namespace GTM HIDDEN {
  241. #ifdef __x86_64__
  242. @@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
  243. } // namespace GTM
  244. #endif /* >= GLIBC 2.10 */
  245. +#endif
  246. #endif // LIBITM_X86_TLS_H
  247. --- a/libstdc++-v3/configure.host
  248. +++ b/libstdc++-v3/configure.host
  249. @@ -264,6 +264,13 @@ case "${host_os}" in
  250. os_include_dir="os/bsd/freebsd"
  251. ;;
  252. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  253. + # check for musl by target
  254. + case "${host_os}" in
  255. + *-musl*)
  256. + os_include_dir="os/generic"
  257. + ;;
  258. + *)
  259. +
  260. if [ "$uclibc" = "yes" ]; then
  261. os_include_dir="os/uclibc"
  262. elif [ "$bionic" = "yes" ]; then
  263. @@ -272,6 +279,9 @@ case "${host_os}" in
  264. os_include_dir="os/gnu-linux"
  265. fi
  266. ;;
  267. +
  268. + esac
  269. + ;;
  270. hpux*)
  271. os_include_dir="os/hpux"
  272. ;;
  273. --- a/gcc/config/mips/linux64.h
  274. +++ b/gcc/config/mips/linux64.h
  275. @@ -27,6 +27,9 @@ along with GCC; see the file COPYING3.
  276. #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
  277. #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
  278. #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
  279. +#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
  280. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
  281. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
  282. #define GNU_USER_DYNAMIC_LINKERN32 \
  283. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
  284. - BIONIC_DYNAMIC_LINKERN32)
  285. + BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
  286. --- a/gcc/config/sparc/linux64.h 2013-09-10 10:02:45.663973856 +0100
  287. +++ b/gcc/config/sparc/linux64.h 2013-09-10 10:03:17.871972435 +0100
  288. @@ -104,6 +104,9 @@
  289. #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
  290. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
  291. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-sparc.so.1"
  292. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-sparc.so.1"
  293. +
  294. #ifdef SPARC_BI_ARCH
  295. #undef SUBTARGET_EXTRA_SPECS