200-musl.patch 8.4 KB

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