1
0

gcc.musl 25 KB

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