200-musl.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. --- a/config.sub
  2. +++ b/config.sub
  3. @@ -125,6 +125,7 @@ esac
  4. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
  5. case $maybe_os in
  6. nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
  7. + linux-musl* | \
  8. linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
  9. knetbsd*-gnu* | netbsd*-gnu* | \
  10. kopensolaris*-gnu* | \
  11. --- a/gcc/config/arm/linux-eabi.h
  12. +++ b/gcc/config/arm/linux-eabi.h
  13. @@ -63,6 +63,10 @@
  14. #undef GLIBC_DYNAMIC_LINKER
  15. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
  16. +/* musl has no "classic" (i.e. broken) mode */
  17. +#undef MUSL_DYNAMIC_LINKER
  18. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
  19. +
  20. /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
  21. use the GNU/Linux version, not the generic BPABI version. */
  22. #undef LINK_SPEC
  23. --- a/gcc/config/i386/linux.h
  24. +++ b/gcc/config/i386/linux.h
  25. @@ -101,6 +101,7 @@ along with GCC; see the file COPYING3.
  26. /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
  27. #define LINK_EMULATION "elf_i386"
  28. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  29. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
  30. #undef ASM_SPEC
  31. #define ASM_SPEC \
  32. --- a/gcc/config/i386/linux64.h
  33. +++ b/gcc/config/i386/linux64.h
  34. @@ -61,6 +61,9 @@ see the files COPYING3 and COPYING.RUNTI
  35. #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
  36. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
  37. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
  38. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
  39. +
  40. #if TARGET_64BIT_DEFAULT
  41. #define SPEC_32 "m32"
  42. #define SPEC_64 "!m32"
  43. --- a/gcc/config/linux.h
  44. +++ b/gcc/config/linux.h
  45. @@ -86,6 +86,7 @@ see the files COPYING3 and COPYING.RUNTI
  46. #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
  47. #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
  48. #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
  49. +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
  50. #define LINUX_TARGET_OS_CPP_BUILTINS() \
  51. do { \
  52. @@ -120,18 +121,21 @@ see the files COPYING3 and COPYING.RUNTI
  53. uClibc or Bionic is the default C library and whether
  54. -muclibc or -mglibc or -mbionic has been passed to change the default. */
  55. -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
  56. - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
  57. +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
  58. + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
  59. #if DEFAULT_LIBC == LIBC_GLIBC
  60. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  61. - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
  62. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  63. + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
  64. #elif DEFAULT_LIBC == LIBC_UCLIBC
  65. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  66. - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
  67. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  68. + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
  69. #elif DEFAULT_LIBC == LIBC_BIONIC
  70. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  71. - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
  72. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  73. + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
  74. +#elif DEFAULT_LIBC == LIBC_MUSL
  75. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  76. + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
  77. #else
  78. #error "Unsupported DEFAULT_LIBC"
  79. #endif /* DEFAULT_LIBC */
  80. @@ -149,13 +153,13 @@ see the files COPYING3 and COPYING.RUNTI
  81. #define LINUX_DYNAMIC_LINKER \
  82. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
  83. - BIONIC_DYNAMIC_LINKER)
  84. + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  85. #define LINUX_DYNAMIC_LINKER32 \
  86. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
  87. - BIONIC_DYNAMIC_LINKER32)
  88. + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  89. #define LINUX_DYNAMIC_LINKER64 \
  90. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
  91. - BIONIC_DYNAMIC_LINKER64)
  92. + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  93. /* Determine whether the entire c99 runtime
  94. is present in the runtime library. */
  95. --- a/gcc/config/linux.opt
  96. +++ b/gcc/config/linux.opt
  97. @@ -30,3 +30,7 @@ Use GNU C library
  98. muclibc
  99. Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) VarExists Negative(mbionic)
  100. Use uClibc C library
  101. +
  102. +mmusl
  103. +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
  104. +Use musl C library
  105. --- a/gcc/config/mips/linux.h
  106. +++ b/gcc/config/mips/linux.h
  107. @@ -66,6 +66,8 @@ along with GCC; see the file COPYING3.
  108. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  109. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
  110. +
  111. /* Borrowed from sparc/linux.h */
  112. #undef LINK_SPEC
  113. #define LINK_SPEC \
  114. --- a/gcc/config/mips/linux64.h
  115. +++ b/gcc/config/mips/linux64.h
  116. @@ -39,8 +39,11 @@ along with GCC; see the file COPYING3.
  117. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld.so.1"
  118. #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
  119. #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
  120. +#define MUSL_DYNAMIC_LINKERN32 "/lib32/ld-musl-mips.so.1"
  121. +#define MUSL_DYNAMIC_LINKER32 "/lib32/ld-musl-mips.so.1"
  122. +#define MUSL_DYNAMIC_LINKER64 "/lib64/ld-musl-mips.so.1"
  123. #define LINUX_DYNAMIC_LINKERN32 \
  124. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32)
  125. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
  126. #undef LINK_SPEC
  127. #define LINK_SPEC "\
  128. --- a/gcc/config.gcc
  129. +++ b/gcc/config.gcc
  130. @@ -514,7 +514,7 @@ case ${target} in
  131. tmake_file="$tmake_file t-gnu";;
  132. esac
  133. # Common C libraries.
  134. - tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
  135. + tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
  136. # glibc / uclibc / bionic switch.
  137. # uclibc and bionic aren't usable for GNU/Hurd and neither for GNU/k*BSD.
  138. case $target in
  139. @@ -530,6 +530,9 @@ case ${target} in
  140. *-*-*uclibc*)
  141. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
  142. ;;
  143. + *-*-*musl*)
  144. + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
  145. + ;;
  146. *)
  147. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
  148. ;;
  149. --- a/gcc/ginclude/stddef.h
  150. +++ b/gcc/ginclude/stddef.h
  151. @@ -183,6 +183,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  152. #ifndef _GCC_SIZE_T
  153. #ifndef _SIZET_
  154. #ifndef __size_t
  155. +#ifndef __DEFINED_size_t /* musl */
  156. #define __size_t__ /* BeOS */
  157. #define __SIZE_T__ /* Cray Unicos/Mk */
  158. #define _SIZE_T
  159. @@ -199,6 +200,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  160. #define ___int_size_t_h
  161. #define _GCC_SIZE_T
  162. #define _SIZET_
  163. +#define __DEFINED_size_t /* musl */
  164. #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
  165. /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
  166. #else
  167. @@ -213,6 +215,7 @@ typedef __SIZE_TYPE__ size_t;
  168. typedef long ssize_t;
  169. #endif /* __BEOS__ */
  170. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  171. +#endif /* __DEFINED_size_t */
  172. #endif /* __size_t */
  173. #endif /* _SIZET_ */
  174. #endif /* _GCC_SIZE_T */
  175. --- a/libgomp/config/posix/time.c
  176. +++ b/libgomp/config/posix/time.c
  177. @@ -28,6 +28,8 @@
  178. The following implementation uses the most simple POSIX routines.
  179. If present, POSIX 4 clocks should be used instead. */
  180. +#define _POSIX_C_SOURCE 199309L /* for clocks */
  181. +
  182. #include "libgomp.h"
  183. #include <unistd.h>
  184. #if TIME_WITH_SYS_TIME
  185. --- a/libstdc++-v3/configure.host
  186. +++ b/libstdc++-v3/configure.host
  187. @@ -236,6 +236,13 @@ case "${host_os}" in
  188. os_include_dir="os/bsd/freebsd"
  189. ;;
  190. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  191. + # check for musl by target
  192. + case "${host_os}" in
  193. + *-musl*)
  194. + os_include_dir="os/generic"
  195. + ;;
  196. + *)
  197. +
  198. if [ "$uclibc" = "yes" ]; then
  199. os_include_dir="os/uclibc"
  200. elif [ "$bionic" = "yes" ]; then
  201. @@ -244,6 +251,9 @@ case "${host_os}" in
  202. os_include_dir="os/gnu-linux"
  203. fi
  204. ;;
  205. +
  206. + esac
  207. + ;;
  208. hpux*)
  209. os_include_dir="os/hpux"
  210. ;;