musl-cross.patch 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. diff -Nur gcc-4.8.2.orig/fixincludes/mkfixinc.sh gcc-4.8.2/fixincludes/mkfixinc.sh
  2. --- gcc-4.8.2.orig/fixincludes/mkfixinc.sh 2012-10-28 22:42:48.000000000 +0100
  3. +++ gcc-4.8.2/fixincludes/mkfixinc.sh 2014-04-15 15:34:20.289308442 +0200
  4. @@ -19,7 +19,8 @@
  5. powerpc-*-eabi* | \
  6. powerpc-*-rtems* | \
  7. powerpcle-*-eabisim* | \
  8. - powerpcle-*-eabi* )
  9. + powerpcle-*-eabi* | \
  10. + *-musl* )
  11. # IF there is no include fixing,
  12. # THEN create a no-op fixer and exit
  13. (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
  14. diff -Nur gcc-4.8.2.orig/gcc/config/aarch64/aarch64-linux.h gcc-4.8.2/gcc/config/aarch64/aarch64-linux.h
  15. --- gcc-4.8.2.orig/gcc/config/aarch64/aarch64-linux.h 2013-08-13 15:22:18.000000000 +0200
  16. +++ gcc-4.8.2/gcc/config/aarch64/aarch64-linux.h 2014-04-15 15:34:20.289308442 +0200
  17. @@ -21,7 +21,11 @@
  18. #ifndef GCC_AARCH64_LINUX_H
  19. #define GCC_AARCH64_LINUX_H
  20. +/* The AArch64 port currently supports two dynamic linkers:
  21. + - ld-linux-aarch64.so.1 - GLIBC dynamic linker
  22. + - ld-musl-aarch64.so.1 - musl libc dynamic linker */
  23. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64.so.1"
  24. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
  25. #define CPP_SPEC "%{pthread:-D_REENTRANT}"
  26. diff -Nur gcc-4.8.2.orig/gcc/config/arm/linux-eabi.h gcc-4.8.2/gcc/config/arm/linux-eabi.h
  27. --- gcc-4.8.2.orig/gcc/config/arm/linux-eabi.h 2013-01-10 21:38:27.000000000 +0100
  28. +++ gcc-4.8.2/gcc/config/arm/linux-eabi.h 2014-04-15 15:34:20.289308442 +0200
  29. @@ -77,6 +77,23 @@
  30. %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
  31. %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
  32. +/* For ARM musl currently supports four dynamic linkers:
  33. + - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
  34. + - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
  35. + - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
  36. + - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
  37. + musl does not support the legacy OABI mode.
  38. + All the dynamic linkers live in /lib.
  39. + We default to soft-float, EL. */
  40. +#undef MUSL_DYNAMIC_LINKER
  41. +#if TARGET_BIG_ENDIAN_DEFAULT
  42. +#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
  43. +#else
  44. +#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
  45. +#endif
  46. +#define MUSL_DYNAMIC_LINKER \
  47. + "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
  48. +
  49. /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
  50. use the GNU/Linux version, not the generic BPABI version. */
  51. #undef LINK_SPEC
  52. diff -Nur gcc-4.8.2.orig/gcc/config/i386/linux64.h gcc-4.8.2/gcc/config/i386/linux64.h
  53. --- gcc-4.8.2.orig/gcc/config/i386/linux64.h 2013-01-10 21:38:27.000000000 +0100
  54. +++ gcc-4.8.2/gcc/config/i386/linux64.h 2014-04-15 15:34:20.289308442 +0200
  55. @@ -30,3 +30,7 @@
  56. #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
  57. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
  58. #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
  59. +
  60. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
  61. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
  62. +#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
  63. diff -Nur gcc-4.8.2.orig/gcc/config/i386/linux.h gcc-4.8.2/gcc/config/i386/linux.h
  64. --- gcc-4.8.2.orig/gcc/config/i386/linux.h 2013-01-10 21:38:27.000000000 +0100
  65. +++ gcc-4.8.2/gcc/config/i386/linux.h 2014-04-15 15:34:20.289308442 +0200
  66. @@ -21,3 +21,4 @@
  67. #define GNU_USER_LINK_EMULATION "elf_i386"
  68. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  69. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
  70. diff -Nur gcc-4.8.2.orig/gcc/config/linux.h gcc-4.8.2/gcc/config/linux.h
  71. --- gcc-4.8.2.orig/gcc/config/linux.h 2013-01-10 21:38:27.000000000 +0100
  72. +++ gcc-4.8.2/gcc/config/linux.h 2014-04-15 15:34:20.293308455 +0200
  73. @@ -32,10 +32,12 @@
  74. #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
  75. #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
  76. #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
  77. +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
  78. #else
  79. #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
  80. #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
  81. #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
  82. +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
  83. #endif
  84. #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
  85. @@ -53,18 +55,21 @@
  86. uClibc or Bionic is the default C library and whether
  87. -muclibc or -mglibc or -mbionic has been passed to change the default. */
  88. -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
  89. - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
  90. +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
  91. + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
  92. #if DEFAULT_LIBC == LIBC_GLIBC
  93. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  94. - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
  95. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  96. + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
  97. #elif DEFAULT_LIBC == LIBC_UCLIBC
  98. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  99. - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
  100. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  101. + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
  102. #elif DEFAULT_LIBC == LIBC_BIONIC
  103. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  104. - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
  105. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  106. + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
  107. +#elif DEFAULT_LIBC == LIBC_MUSL
  108. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  109. + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
  110. #else
  111. #error "Unsupported DEFAULT_LIBC"
  112. #endif /* DEFAULT_LIBC */
  113. @@ -84,21 +89,21 @@
  114. #define GNU_USER_DYNAMIC_LINKER \
  115. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
  116. - BIONIC_DYNAMIC_LINKER)
  117. + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  118. #define GNU_USER_DYNAMIC_LINKER32 \
  119. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
  120. - BIONIC_DYNAMIC_LINKER32)
  121. + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  122. #define GNU_USER_DYNAMIC_LINKER64 \
  123. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
  124. - BIONIC_DYNAMIC_LINKER64)
  125. + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  126. #define GNU_USER_DYNAMIC_LINKERX32 \
  127. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
  128. - BIONIC_DYNAMIC_LINKERX32)
  129. + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
  130. /* Determine whether the entire c99 runtime
  131. is present in the runtime library. */
  132. #undef TARGET_C99_FUNCTIONS
  133. -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  134. +#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL)
  135. /* Whether we have sincos that follows the GNU extension. */
  136. #undef TARGET_HAS_SINCOS
  137. @@ -107,3 +112,74 @@
  138. /* Whether we have Bionic libc runtime */
  139. #undef TARGET_HAS_BIONIC
  140. #define TARGET_HAS_BIONIC (OPTION_BIONIC)
  141. +
  142. +/* musl avoids problematic includes by rearranging the include directories.
  143. + * Unfortunately, this is mostly duplicated from cppdefault.c */
  144. +#if DEFAULT_LIBC == LIBC_MUSL
  145. +#define INCLUDE_DEFAULTS_MUSL_GPP \
  146. + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
  147. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
  148. + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
  149. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
  150. + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
  151. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
  152. +
  153. +#ifdef LOCAL_INCLUDE_DIR
  154. +#define INCLUDE_DEFAULTS_MUSL_LOCAL \
  155. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
  156. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
  157. +#else
  158. +#define INCLUDE_DEFAULTS_MUSL_LOCAL
  159. +#endif
  160. +
  161. +#ifdef PREFIX_INCLUDE_DIR
  162. +#define INCLUDE_DEFAULTS_MUSL_PREFIX \
  163. + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
  164. +#else
  165. +#define INCLUDE_DEFAULTS_MUSL_PREFIX
  166. +#endif
  167. +
  168. +#ifdef CROSS_INCLUDE_DIR
  169. +#define INCLUDE_DEFAULTS_MUSL_CROSS \
  170. + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
  171. +#else
  172. +#define INCLUDE_DEFAULTS_MUSL_CROSS
  173. +#endif
  174. +
  175. +#ifdef TOOL_INCLUDE_DIR
  176. +#define INCLUDE_DEFAULTS_MUSL_TOOL \
  177. + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
  178. +#else
  179. +#define INCLUDE_DEFAULTS_MUSL_TOOL
  180. +#endif
  181. +
  182. +#ifdef NATIVE_SYSTEM_HEADER_DIR
  183. +#define INCLUDE_DEFAULTS_MUSL_NATIVE \
  184. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
  185. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
  186. +#else
  187. +#define INCLUDE_DEFAULTS_MUSL_NATIVE
  188. +#endif
  189. +
  190. +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
  191. +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
  192. +# define INCLUDE_DEFAULTS_MUSL_LOCAL
  193. +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
  194. +# define INCLUDE_DEFAULTS_MUSL_NATIVE
  195. +#else
  196. +# undef INCLUDE_DEFAULTS_MUSL_CROSS
  197. +# define INCLUDE_DEFAULTS_MUSL_CROSS
  198. +#endif
  199. +
  200. +#undef INCLUDE_DEFAULTS
  201. +#define INCLUDE_DEFAULTS \
  202. + { \
  203. + INCLUDE_DEFAULTS_MUSL_GPP \
  204. + INCLUDE_DEFAULTS_MUSL_PREFIX \
  205. + INCLUDE_DEFAULTS_MUSL_CROSS \
  206. + INCLUDE_DEFAULTS_MUSL_TOOL \
  207. + INCLUDE_DEFAULTS_MUSL_NATIVE \
  208. + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
  209. + { 0, 0, 0, 0, 0, 0 } \
  210. + }
  211. +#endif
  212. diff -Nur gcc-4.8.2.orig/gcc/config/linux.opt gcc-4.8.2/gcc/config/linux.opt
  213. --- gcc-4.8.2.orig/gcc/config/linux.opt 2013-01-10 21:38:27.000000000 +0100
  214. +++ gcc-4.8.2/gcc/config/linux.opt 2014-04-15 15:34:20.293308455 +0200
  215. @@ -30,3 +30,7 @@
  216. muclibc
  217. Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
  218. Use uClibc C library
  219. +
  220. +mmusl
  221. +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
  222. +Use musl C library
  223. diff -Nur gcc-4.8.2.orig/gcc/config/microblaze/linux.h gcc-4.8.2/gcc/config/microblaze/linux.h
  224. --- gcc-4.8.2.orig/gcc/config/microblaze/linux.h 2013-03-14 16:43:23.000000000 +0100
  225. +++ gcc-4.8.2/gcc/config/microblaze/linux.h 2014-04-15 15:34:20.293308455 +0200
  226. @@ -25,7 +25,22 @@
  227. #undef TLS_NEEDS_GOT
  228. #define TLS_NEEDS_GOT 1
  229. -#define DYNAMIC_LINKER "/lib/ld.so.1"
  230. +#if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
  231. +#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
  232. +#else
  233. +#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
  234. +#endif
  235. +
  236. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
  237. +#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  238. +
  239. +#if DEFAULT_LIBC == LIBC_MUSL
  240. +#define DYNAMIC_LINKER MUSL_DYNAMIC_LINKER
  241. +#else
  242. +#define DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
  243. +#endif
  244. +
  245. +
  246. #undef SUBTARGET_EXTRA_SPECS
  247. #define SUBTARGET_EXTRA_SPECS \
  248. { "dynamic_linker", DYNAMIC_LINKER }
  249. diff -Nur gcc-4.8.2.orig/gcc/config/microblaze/microblaze.h gcc-4.8.2/gcc/config/microblaze/microblaze.h
  250. --- gcc-4.8.2.orig/gcc/config/microblaze/microblaze.h 2013-03-14 16:43:23.000000000 +0100
  251. +++ gcc-4.8.2/gcc/config/microblaze/microblaze.h 2014-04-15 15:34:20.293308455 +0200
  252. @@ -213,6 +213,12 @@
  253. #define STRICT_ALIGNMENT 1
  254. #define PCC_BITFIELD_TYPE_MATTERS 1
  255. +#undef SIZE_TYPE
  256. +#define SIZE_TYPE "unsigned int"
  257. +
  258. +#undef PTRDIFF_TYPE
  259. +#define PTRDIFF_TYPE "int"
  260. +
  261. #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
  262. ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
  263. && (ALIGN) < BITS_PER_WORD \
  264. diff -Nur gcc-4.8.2.orig/gcc/config/mips/linux.h gcc-4.8.2/gcc/config/mips/linux.h
  265. --- gcc-4.8.2.orig/gcc/config/mips/linux.h 2013-01-10 21:38:27.000000000 +0100
  266. +++ gcc-4.8.2/gcc/config/mips/linux.h 2014-04-15 15:34:20.293308455 +0200
  267. @@ -18,3 +18,10 @@
  268. <http://www.gnu.org/licenses/>. */
  269. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  270. +
  271. +#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
  272. +#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
  273. +#else
  274. +#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
  275. +#endif
  276. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
  277. diff -Nur gcc-4.8.2.orig/gcc/config/rs6000/linux64.h gcc-4.8.2/gcc/config/rs6000/linux64.h
  278. --- gcc-4.8.2.orig/gcc/config/rs6000/linux64.h 2013-06-19 03:18:38.000000000 +0200
  279. +++ gcc-4.8.2/gcc/config/rs6000/linux64.h 2014-04-15 15:34:20.293308455 +0200
  280. @@ -354,17 +354,21 @@
  281. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
  282. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  283. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  284. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
  285. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
  286. #if DEFAULT_LIBC == LIBC_UCLIBC
  287. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  288. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  289. #elif DEFAULT_LIBC == LIBC_GLIBC
  290. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  291. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  292. +#elif DEFAULT_LIBC == LIBC_MUSL
  293. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  294. #else
  295. #error "Unsupported DEFAULT_LIBC"
  296. #endif
  297. #define GNU_USER_DYNAMIC_LINKER32 \
  298. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  299. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  300. #define GNU_USER_DYNAMIC_LINKER64 \
  301. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  302. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  303. #undef DEFAULT_ASM_ENDIAN
  304. #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
  305. diff -Nur gcc-4.8.2.orig/gcc/config/rs6000/secureplt.h gcc-4.8.2/gcc/config/rs6000/secureplt.h
  306. --- gcc-4.8.2.orig/gcc/config/rs6000/secureplt.h 2013-01-10 21:38:27.000000000 +0100
  307. +++ gcc-4.8.2/gcc/config/rs6000/secureplt.h 2014-04-15 15:34:20.293308455 +0200
  308. @@ -18,3 +18,4 @@
  309. <http://www.gnu.org/licenses/>. */
  310. #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
  311. +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
  312. diff -Nur gcc-4.8.2.orig/gcc/config/rs6000/sysv4.h gcc-4.8.2/gcc/config/rs6000/sysv4.h
  313. --- gcc-4.8.2.orig/gcc/config/rs6000/sysv4.h 2013-06-19 03:18:38.000000000 +0200
  314. +++ gcc-4.8.2/gcc/config/rs6000/sysv4.h 2014-04-15 15:34:20.293308455 +0200
  315. @@ -550,6 +550,9 @@
  316. #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
  317. #define CC1_SECURE_PLT_DEFAULT_SPEC ""
  318. #endif
  319. +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
  320. +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
  321. +#endif
  322. /* Pass -G xxx to the compiler and set correct endian mode. */
  323. #define CC1_SPEC "%{G*} %(cc1_cpu)" \
  324. @@ -600,7 +603,8 @@
  325. /* Override the default target of the linker. */
  326. #define LINK_TARGET_SPEC \
  327. - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
  328. + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
  329. + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
  330. /* Any specific OS flags. */
  331. #define LINK_OS_SPEC "\
  332. @@ -778,15 +782,18 @@
  333. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  334. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  335. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
  336. #if DEFAULT_LIBC == LIBC_UCLIBC
  337. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  338. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  339. +#elif DEFAULT_LIBC == LIBC_MUSL
  340. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  341. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  342. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  343. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  344. #else
  345. #error "Unsupported DEFAULT_LIBC"
  346. #endif
  347. #define GNU_USER_DYNAMIC_LINKER \
  348. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  349. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  350. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  351. %{rdynamic:-export-dynamic} \
  352. @@ -912,6 +919,7 @@
  353. { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
  354. { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
  355. { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
  356. + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
  357. { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
  358. { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
  359. { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
  360. diff -Nur gcc-4.8.2.orig/gcc/config/sh/linux.h gcc-4.8.2/gcc/config/sh/linux.h
  361. --- gcc-4.8.2.orig/gcc/config/sh/linux.h 2013-03-14 04:01:53.000000000 +0100
  362. +++ gcc-4.8.2/gcc/config/sh/linux.h 2014-04-15 17:15:20.493877154 +0200
  363. @@ -43,7 +43,14 @@
  364. #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
  365. +#if TARGET_ENDIAN_DEFAULT == 0 /* BE */
  366. +#define MUSL_DYNAMIC_LINKER_E "eb"
  367. +#else
  368. +#define MUSL_DYNAMIC_LINKER_E
  369. +#endif
  370. +
  371. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  372. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
  373. #undef SUBTARGET_LINK_EMUL_SUFFIX
  374. #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
  375. diff -Nur gcc-4.8.2.orig/gcc/config/sh/sh.c gcc-4.8.2/gcc/config/sh/sh.c
  376. --- gcc-4.8.2.orig/gcc/config/sh/sh.c 2013-03-13 19:09:10.000000000 +0100
  377. +++ gcc-4.8.2/gcc/config/sh/sh.c 2014-04-15 15:34:20.297308468 +0200
  378. @@ -24,6 +24,9 @@
  379. malloc & co, which are poisoned by "system.h". The proper solution is
  380. to include <cstdlib> in "system.h" instead of <stdlib.h>. */
  381. #include <cstdlib>
  382. +#include <sstream>
  383. +#include <vector>
  384. +#include <algorithm>
  385. #include "config.h"
  386. #include "system.h"
  387. @@ -60,9 +63,6 @@
  388. #include "tm-constrs.h"
  389. #include "opts.h"
  390. -#include <sstream>
  391. -#include <vector>
  392. -#include <algorithm>
  393. int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch;
  394. diff -Nur gcc-4.8.2.orig/gcc/config.gcc gcc-4.8.2/gcc/config.gcc
  395. --- gcc-4.8.2.orig/gcc/config.gcc 2013-10-03 02:47:24.000000000 +0200
  396. +++ gcc-4.8.2/gcc/config.gcc 2014-04-15 15:34:20.297308468 +0200
  397. @@ -550,7 +550,7 @@
  398. esac
  399. # Common C libraries.
  400. -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
  401. +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
  402. # Common parts for widely ported systems.
  403. case ${target} in
  404. @@ -653,6 +653,9 @@
  405. *-*-*uclibc*)
  406. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
  407. ;;
  408. + *-*-*musl*)
  409. + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
  410. + ;;
  411. *)
  412. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
  413. ;;
  414. @@ -2114,6 +2117,10 @@
  415. powerpc*-*-linux*paired*)
  416. tm_file="${tm_file} rs6000/750cl.h" ;;
  417. esac
  418. + case ${target} in
  419. + *-linux*-musl*)
  420. + enable_secureplt=yes ;;
  421. + esac
  422. if test x${enable_secureplt} = xyes; then
  423. tm_file="rs6000/secureplt.h ${tm_file}"
  424. fi
  425. diff -Nur gcc-4.8.2.orig/gcc/configure gcc-4.8.2/gcc/configure
  426. --- gcc-4.8.2.orig/gcc/configure 2013-06-19 03:18:38.000000000 +0200
  427. +++ gcc-4.8.2/gcc/configure 2014-04-15 15:34:20.301308482 +0200
  428. @@ -26739,6 +26739,9 @@
  429. else
  430. gcc_cv_libc_provides_ssp=no
  431. case "$target" in
  432. + *-*-musl*)
  433. + # All versions of musl provide stack protector
  434. + gcc_cv_libc_provides_ssp=yes;;
  435. *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
  436. # glibc 2.4 and later provides __stack_chk_fail and
  437. # either __stack_chk_guard, or TLS access to stack guard canary.
  438. @@ -26772,6 +26775,7 @@
  439. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  440. # simply assert that glibc does provide this, which is true for all
  441. # realistically usable GNU/Hurd configurations.
  442. + # All supported versions of musl provide it as well
  443. gcc_cv_libc_provides_ssp=yes;;
  444. *-*-darwin* | *-*-freebsd*)
  445. ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
  446. @@ -26854,6 +26858,9 @@
  447. gcc_cv_target_dl_iterate_phdr=no
  448. fi
  449. ;;
  450. + *-linux-musl*)
  451. + gcc_cv_target_dl_iterate_phdr=yes
  452. + ;;
  453. esac
  454. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  455. diff -Nur gcc-4.8.2.orig/gcc/configure.ac gcc-4.8.2/gcc/configure.ac
  456. --- gcc-4.8.2.orig/gcc/configure.ac 2013-06-19 03:18:38.000000000 +0200
  457. +++ gcc-4.8.2/gcc/configure.ac 2014-04-15 15:34:20.309308509 +0200
  458. @@ -4722,6 +4722,9 @@
  459. gcc_cv_libc_provides_ssp,
  460. [gcc_cv_libc_provides_ssp=no
  461. case "$target" in
  462. + *-*-musl*)
  463. + # All versions of musl provide stack protector
  464. + gcc_cv_libc_provides_ssp=yes;;
  465. *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
  466. [# glibc 2.4 and later provides __stack_chk_fail and
  467. # either __stack_chk_guard, or TLS access to stack guard canary.
  468. @@ -4755,6 +4758,7 @@
  469. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  470. # simply assert that glibc does provide this, which is true for all
  471. # realistically usable GNU/Hurd configurations.
  472. + # All supported versions of musl provide it as well
  473. gcc_cv_libc_provides_ssp=yes;;
  474. *-*-darwin* | *-*-freebsd*)
  475. AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
  476. @@ -4820,6 +4824,9 @@
  477. gcc_cv_target_dl_iterate_phdr=no
  478. fi
  479. ;;
  480. + *-linux-musl*)
  481. + gcc_cv_target_dl_iterate_phdr=yes
  482. + ;;
  483. esac
  484. GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
  485. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  486. diff -Nur gcc-4.8.2.orig/gcc/ginclude/stddef.h gcc-4.8.2/gcc/ginclude/stddef.h
  487. --- gcc-4.8.2.orig/gcc/ginclude/stddef.h 2013-01-10 21:38:27.000000000 +0100
  488. +++ gcc-4.8.2/gcc/ginclude/stddef.h 2014-04-15 15:34:20.313308522 +0200
  489. @@ -181,6 +181,7 @@
  490. #ifndef _GCC_SIZE_T
  491. #ifndef _SIZET_
  492. #ifndef __size_t
  493. +#ifndef __DEFINED_size_t /* musl */
  494. #define __size_t__ /* BeOS */
  495. #define __SIZE_T__ /* Cray Unicos/Mk */
  496. #define _SIZE_T
  497. @@ -197,6 +198,7 @@
  498. #define ___int_size_t_h
  499. #define _GCC_SIZE_T
  500. #define _SIZET_
  501. +#define __DEFINED_size_t /* musl */
  502. #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
  503. || defined(__FreeBSD_kernel__)
  504. /* __size_t is a typedef on FreeBSD 5, must not trash it. */
  505. @@ -214,6 +216,7 @@
  506. typedef long ssize_t;
  507. #endif /* __BEOS__ */
  508. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  509. +#endif /* __DEFINED_size_t */
  510. #endif /* __size_t */
  511. #endif /* _SIZET_ */
  512. #endif /* _GCC_SIZE_T */
  513. diff -Nur gcc-4.8.2.orig/libgcc/unwind-dw2-fde-dip.c gcc-4.8.2/libgcc/unwind-dw2-fde-dip.c
  514. --- gcc-4.8.2.orig/libgcc/unwind-dw2-fde-dip.c 2013-02-04 20:06:20.000000000 +0100
  515. +++ gcc-4.8.2/libgcc/unwind-dw2-fde-dip.c 2014-04-15 15:34:20.313308522 +0200
  516. @@ -46,33 +46,13 @@
  517. #include "unwind-compat.h"
  518. #include "gthr.h"
  519. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  520. - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
  521. - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
  522. -# define USE_PT_GNU_EH_FRAME
  523. -#endif
  524. -
  525. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  526. - && defined(__BIONIC__)
  527. -# define USE_PT_GNU_EH_FRAME
  528. -#endif
  529. -
  530. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  531. - && defined(__FreeBSD__) && __FreeBSD__ >= 7
  532. -# define ElfW __ElfN
  533. -# define USE_PT_GNU_EH_FRAME
  534. -#endif
  535. -
  536. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  537. - && defined(__OpenBSD__)
  538. -# define ElfW(type) Elf_##type
  539. -# define USE_PT_GNU_EH_FRAME
  540. -#endif
  541. -
  542. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  543. - && defined(TARGET_DL_ITERATE_PHDR) \
  544. - && defined(__sun__) && defined(__svr4__)
  545. +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
  546. # define USE_PT_GNU_EH_FRAME
  547. +# ifdef __OpenBSD__
  548. +# define ElfW(type) Elf_##typ
  549. +# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
  550. +# define ElfW __ElfN
  551. +# endif
  552. #endif
  553. #if defined(USE_PT_GNU_EH_FRAME)
  554. diff -Nur gcc-4.8.2.orig/libgomp/config/posix/time.c gcc-4.8.2/libgomp/config/posix/time.c
  555. --- gcc-4.8.2.orig/libgomp/config/posix/time.c 2013-01-14 19:18:49.000000000 +0100
  556. +++ gcc-4.8.2/libgomp/config/posix/time.c 2014-04-15 15:34:20.313308522 +0200
  557. @@ -28,6 +28,8 @@
  558. The following implementation uses the most simple POSIX routines.
  559. If present, POSIX 4 clocks should be used instead. */
  560. +#define _POSIX_C_SOURCE 199309L /* for clocks */
  561. +
  562. #include "libgomp.h"
  563. #include <unistd.h>
  564. #if TIME_WITH_SYS_TIME
  565. diff -Nur gcc-4.8.2.orig/libitm/config/arm/hwcap.cc gcc-4.8.2/libitm/config/arm/hwcap.cc
  566. --- gcc-4.8.2.orig/libitm/config/arm/hwcap.cc 2013-02-03 18:46:11.000000000 +0100
  567. +++ gcc-4.8.2/libitm/config/arm/hwcap.cc 2014-04-15 15:34:20.313308522 +0200
  568. @@ -40,7 +40,11 @@
  569. #ifdef __linux__
  570. #include <unistd.h>
  571. +#ifdef __GLIBC__
  572. #include <sys/fcntl.h>
  573. +#else
  574. +#include <fcntl.h>
  575. +#endif
  576. #include <elf.h>
  577. static void __attribute__((constructor))
  578. diff -Nur gcc-4.8.2.orig/libitm/config/linux/x86/tls.h gcc-4.8.2/libitm/config/linux/x86/tls.h
  579. --- gcc-4.8.2.orig/libitm/config/linux/x86/tls.h 2013-02-03 18:46:11.000000000 +0100
  580. +++ gcc-4.8.2/libitm/config/linux/x86/tls.h 2014-04-15 15:34:20.313308522 +0200
  581. @@ -25,16 +25,19 @@
  582. #ifndef LIBITM_X86_TLS_H
  583. #define LIBITM_X86_TLS_H 1
  584. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  585. +#if defined(__GLIBC_PREREQ)
  586. +#if __GLIBC_PREREQ(2, 10)
  587. /* Use slots in the TCB head rather than __thread lookups.
  588. GLIBC has reserved words 10 through 13 for TM. */
  589. #define HAVE_ARCH_GTM_THREAD 1
  590. #define HAVE_ARCH_GTM_THREAD_DISP 1
  591. #endif
  592. +#endif
  593. #include "config/generic/tls.h"
  594. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  595. +#if defined(__GLIBC_PREREQ)
  596. +#if __GLIBC_PREREQ(2, 10)
  597. namespace GTM HIDDEN {
  598. #ifdef __x86_64__
  599. @@ -101,5 +104,6 @@
  600. } // namespace GTM
  601. #endif /* >= GLIBC 2.10 */
  602. +#endif
  603. #endif // LIBITM_X86_TLS_H
  604. diff -Nur gcc-4.8.2.orig/libstdc++-v3/configure.host gcc-4.8.2/libstdc++-v3/configure.host
  605. --- gcc-4.8.2.orig/libstdc++-v3/configure.host 2013-06-19 03:18:38.000000000 +0200
  606. +++ gcc-4.8.2/libstdc++-v3/configure.host 2014-04-15 15:34:20.313308522 +0200
  607. @@ -264,6 +264,13 @@
  608. os_include_dir="os/bsd/freebsd"
  609. ;;
  610. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  611. + # check for musl by target
  612. + case "${host_os}" in
  613. + *-musl*)
  614. + os_include_dir="os/generic"
  615. + ;;
  616. + *)
  617. +
  618. if [ "$uclibc" = "yes" ]; then
  619. os_include_dir="os/uclibc"
  620. elif [ "$bionic" = "yes" ]; then
  621. @@ -272,6 +279,9 @@
  622. os_include_dir="os/gnu-linux"
  623. fi
  624. ;;
  625. +
  626. + esac
  627. + ;;
  628. hpux*)
  629. os_include_dir="os/hpux"
  630. ;;