200-musl.patch 8.4 KB

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