1
0

gcc.musl 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. diff -Nur gcc-4.8.3.orig/fixincludes/mkfixinc.sh gcc-4.8.3/fixincludes/mkfixinc.sh
  2. --- gcc-4.8.3.orig/fixincludes/mkfixinc.sh 2012-10-28 22:42:48.000000000 +0100
  3. +++ gcc-4.8.3/fixincludes/mkfixinc.sh 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/aarch64/aarch64-linux.h gcc-4.8.3/gcc/config/aarch64/aarch64-linux.h
  15. --- gcc-4.8.3.orig/gcc/config/aarch64/aarch64-linux.h 2013-08-13 15:22:18.000000000 +0200
  16. +++ gcc-4.8.3/gcc/config/aarch64/aarch64-linux.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/arm/linux-eabi.h gcc-4.8.3/gcc/config/arm/linux-eabi.h
  27. --- gcc-4.8.3.orig/gcc/config/arm/linux-eabi.h 2013-01-10 21:38:27.000000000 +0100
  28. +++ gcc-4.8.3/gcc/config/arm/linux-eabi.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/i386/linux64.h gcc-4.8.3/gcc/config/i386/linux64.h
  53. --- gcc-4.8.3.orig/gcc/config/i386/linux64.h 2013-01-10 21:38:27.000000000 +0100
  54. +++ gcc-4.8.3/gcc/config/i386/linux64.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/i386/linux.h gcc-4.8.3/gcc/config/i386/linux.h
  64. --- gcc-4.8.3.orig/gcc/config/i386/linux.h 2013-01-10 21:38:27.000000000 +0100
  65. +++ gcc-4.8.3/gcc/config/i386/linux.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/linux.h gcc-4.8.3/gcc/config/linux.h
  71. --- gcc-4.8.3.orig/gcc/config/linux.h 2013-01-10 21:38:27.000000000 +0100
  72. +++ gcc-4.8.3/gcc/config/linux.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/linux.opt gcc-4.8.3/gcc/config/linux.opt
  213. --- gcc-4.8.3.orig/gcc/config/linux.opt 2013-01-10 21:38:27.000000000 +0100
  214. +++ gcc-4.8.3/gcc/config/linux.opt 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/microblaze/linux.h gcc-4.8.3/gcc/config/microblaze/linux.h
  224. --- gcc-4.8.3.orig/gcc/config/microblaze/linux.h 2013-03-14 16:43:23.000000000 +0100
  225. +++ gcc-4.8.3/gcc/config/microblaze/linux.h 2014-05-23 08:22:46.987415702 +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.3.orig/gcc/config/mips/linux.h gcc-4.8.3/gcc/config/mips/linux.h
  250. --- gcc-4.8.3.orig/gcc/config/mips/linux.h 2013-01-10 21:38:27.000000000 +0100
  251. +++ gcc-4.8.3/gcc/config/mips/linux.h 2014-05-23 08:22:48.643418636 +0200
  252. @@ -18,3 +18,10 @@
  253. <http://www.gnu.org/licenses/>. */
  254. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  255. +
  256. +#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
  257. +#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
  258. +#else
  259. +#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
  260. +#endif
  261. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
  262. diff -Nur gcc-4.8.3.orig/gcc/config/rs6000/linux64.h gcc-4.8.3/gcc/config/rs6000/linux64.h
  263. --- gcc-4.8.3.orig/gcc/config/rs6000/linux64.h 2014-04-04 17:10:24.000000000 +0200
  264. +++ gcc-4.8.3/gcc/config/rs6000/linux64.h 2014-05-23 08:22:48.643418636 +0200
  265. @@ -374,17 +374,21 @@
  266. #endif
  267. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  268. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  269. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
  270. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
  271. #if DEFAULT_LIBC == LIBC_UCLIBC
  272. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  273. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  274. #elif DEFAULT_LIBC == LIBC_GLIBC
  275. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  276. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  277. +#elif DEFAULT_LIBC == LIBC_MUSL
  278. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  279. #else
  280. #error "Unsupported DEFAULT_LIBC"
  281. #endif
  282. #define GNU_USER_DYNAMIC_LINKER32 \
  283. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  284. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  285. #define GNU_USER_DYNAMIC_LINKER64 \
  286. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  287. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  288. #undef DEFAULT_ASM_ENDIAN
  289. #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
  290. diff -Nur gcc-4.8.3.orig/gcc/config/rs6000/secureplt.h gcc-4.8.3/gcc/config/rs6000/secureplt.h
  291. --- gcc-4.8.3.orig/gcc/config/rs6000/secureplt.h 2013-01-10 21:38:27.000000000 +0100
  292. +++ gcc-4.8.3/gcc/config/rs6000/secureplt.h 2014-05-23 08:22:48.643418636 +0200
  293. @@ -18,3 +18,4 @@
  294. <http://www.gnu.org/licenses/>. */
  295. #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
  296. +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
  297. diff -Nur gcc-4.8.3.orig/gcc/config/rs6000/sysv4.h gcc-4.8.3/gcc/config/rs6000/sysv4.h
  298. --- gcc-4.8.3.orig/gcc/config/rs6000/sysv4.h 2014-04-04 16:50:31.000000000 +0200
  299. +++ gcc-4.8.3/gcc/config/rs6000/sysv4.h 2014-05-23 08:22:48.643418636 +0200
  300. @@ -537,6 +537,9 @@
  301. #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
  302. #define CC1_SECURE_PLT_DEFAULT_SPEC ""
  303. #endif
  304. +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
  305. +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
  306. +#endif
  307. /* Pass -G xxx to the compiler. */
  308. #define CC1_SPEC "%{G*} %(cc1_cpu)" \
  309. @@ -585,7 +588,8 @@
  310. /* Override the default target of the linker. */
  311. #define LINK_TARGET_SPEC \
  312. - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
  313. + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
  314. + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
  315. /* Any specific OS flags. */
  316. #define LINK_OS_SPEC "\
  317. @@ -763,15 +767,18 @@
  318. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  319. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  320. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
  321. #if DEFAULT_LIBC == LIBC_UCLIBC
  322. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  323. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  324. +#elif DEFAULT_LIBC == LIBC_MUSL
  325. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  326. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  327. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  328. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  329. #else
  330. #error "Unsupported DEFAULT_LIBC"
  331. #endif
  332. #define GNU_USER_DYNAMIC_LINKER \
  333. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  334. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  335. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  336. %{rdynamic:-export-dynamic} \
  337. @@ -894,6 +901,7 @@
  338. { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
  339. { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
  340. { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
  341. + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
  342. { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
  343. { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
  344. { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
  345. diff -Nur gcc-4.8.3.orig/gcc/config/sh/linux.h gcc-4.8.3/gcc/config/sh/linux.h
  346. --- gcc-4.8.3.orig/gcc/config/sh/linux.h 2013-03-14 04:01:53.000000000 +0100
  347. +++ gcc-4.8.3/gcc/config/sh/linux.h 2014-05-23 08:22:48.643418636 +0200
  348. @@ -43,7 +43,14 @@
  349. #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
  350. +#if TARGET_ENDIAN_DEFAULT == 0 /* BE */
  351. +#define MUSL_DYNAMIC_LINKER_E "eb"
  352. +#else
  353. +#define MUSL_DYNAMIC_LINKER_E
  354. +#endif
  355. +
  356. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  357. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
  358. #undef SUBTARGET_LINK_EMUL_SUFFIX
  359. #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
  360. diff -Nur gcc-4.8.3.orig/gcc/config.gcc gcc-4.8.3/gcc/config.gcc
  361. --- gcc-4.8.3.orig/gcc/config.gcc 2014-05-06 17:29:04.000000000 +0200
  362. +++ gcc-4.8.3/gcc/config.gcc 2014-05-23 08:22:49.895420854 +0200
  363. @@ -550,7 +550,7 @@
  364. esac
  365. # Common C libraries.
  366. -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
  367. +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
  368. # Common parts for widely ported systems.
  369. case ${target} in
  370. @@ -653,6 +653,9 @@
  371. *-*-*uclibc*)
  372. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
  373. ;;
  374. + *-*-*musl*)
  375. + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
  376. + ;;
  377. *)
  378. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
  379. ;;
  380. @@ -2135,6 +2138,10 @@
  381. powerpc*-*-linux*paired*)
  382. tm_file="${tm_file} rs6000/750cl.h" ;;
  383. esac
  384. + case ${target} in
  385. + *-linux*-musl*)
  386. + enable_secureplt=yes ;;
  387. + esac
  388. if test x${enable_secureplt} = xyes; then
  389. tm_file="rs6000/secureplt.h ${tm_file}"
  390. fi
  391. diff -Nur gcc-4.8.3.orig/gcc/configure gcc-4.8.3/gcc/configure
  392. --- gcc-4.8.3.orig/gcc/configure 2014-04-28 12:05:29.000000000 +0200
  393. +++ gcc-4.8.3/gcc/configure 2014-05-23 08:22:49.903420868 +0200
  394. @@ -26821,6 +26821,9 @@
  395. else
  396. gcc_cv_libc_provides_ssp=no
  397. case "$target" in
  398. + *-*-musl*)
  399. + # All versions of musl provide stack protector
  400. + gcc_cv_libc_provides_ssp=yes;;
  401. *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
  402. # glibc 2.4 and later provides __stack_chk_fail and
  403. # either __stack_chk_guard, or TLS access to stack guard canary.
  404. @@ -26854,6 +26857,7 @@
  405. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  406. # simply assert that glibc does provide this, which is true for all
  407. # realistically usable GNU/Hurd configurations.
  408. + # All supported versions of musl provide it as well
  409. gcc_cv_libc_provides_ssp=yes;;
  410. *-*-darwin* | *-*-freebsd*)
  411. ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
  412. @@ -26936,6 +26940,9 @@
  413. gcc_cv_target_dl_iterate_phdr=no
  414. fi
  415. ;;
  416. + *-linux-musl*)
  417. + gcc_cv_target_dl_iterate_phdr=yes
  418. + ;;
  419. esac
  420. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  421. diff -Nur gcc-4.8.3.orig/gcc/configure.ac gcc-4.8.3/gcc/configure.ac
  422. --- gcc-4.8.3.orig/gcc/configure.ac 2014-04-28 12:05:29.000000000 +0200
  423. +++ gcc-4.8.3/gcc/configure.ac 2014-05-23 08:22:49.903420868 +0200
  424. @@ -4750,6 +4750,9 @@
  425. gcc_cv_libc_provides_ssp,
  426. [gcc_cv_libc_provides_ssp=no
  427. case "$target" in
  428. + *-*-musl*)
  429. + # All versions of musl provide stack protector
  430. + gcc_cv_libc_provides_ssp=yes;;
  431. *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
  432. [# glibc 2.4 and later provides __stack_chk_fail and
  433. # either __stack_chk_guard, or TLS access to stack guard canary.
  434. @@ -4783,6 +4786,7 @@
  435. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  436. # simply assert that glibc does provide this, which is true for all
  437. # realistically usable GNU/Hurd configurations.
  438. + # All supported versions of musl provide it as well
  439. gcc_cv_libc_provides_ssp=yes;;
  440. *-*-darwin* | *-*-freebsd*)
  441. AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
  442. @@ -4848,6 +4852,9 @@
  443. gcc_cv_target_dl_iterate_phdr=no
  444. fi
  445. ;;
  446. + *-linux-musl*)
  447. + gcc_cv_target_dl_iterate_phdr=yes
  448. + ;;
  449. esac
  450. GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
  451. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  452. diff -Nur gcc-4.8.3.orig/gcc/ginclude/stddef.h gcc-4.8.3/gcc/ginclude/stddef.h
  453. --- gcc-4.8.3.orig/gcc/ginclude/stddef.h 2013-01-10 21:38:27.000000000 +0100
  454. +++ gcc-4.8.3/gcc/ginclude/stddef.h 2014-05-23 08:22:49.903420868 +0200
  455. @@ -181,6 +181,7 @@
  456. #ifndef _GCC_SIZE_T
  457. #ifndef _SIZET_
  458. #ifndef __size_t
  459. +#ifndef __DEFINED_size_t /* musl */
  460. #define __size_t__ /* BeOS */
  461. #define __SIZE_T__ /* Cray Unicos/Mk */
  462. #define _SIZE_T
  463. @@ -197,6 +198,7 @@
  464. #define ___int_size_t_h
  465. #define _GCC_SIZE_T
  466. #define _SIZET_
  467. +#define __DEFINED_size_t /* musl */
  468. #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
  469. || defined(__FreeBSD_kernel__)
  470. /* __size_t is a typedef on FreeBSD 5, must not trash it. */
  471. @@ -214,6 +216,7 @@
  472. typedef long ssize_t;
  473. #endif /* __BEOS__ */
  474. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  475. +#endif /* __DEFINED_size_t */
  476. #endif /* __size_t */
  477. #endif /* _SIZET_ */
  478. #endif /* _GCC_SIZE_T */
  479. diff -Nur gcc-4.8.3.orig/libgcc/unwind-dw2-fde-dip.c gcc-4.8.3/libgcc/unwind-dw2-fde-dip.c
  480. --- gcc-4.8.3.orig/libgcc/unwind-dw2-fde-dip.c 2013-02-04 20:06:20.000000000 +0100
  481. +++ gcc-4.8.3/libgcc/unwind-dw2-fde-dip.c 2014-05-23 08:22:49.955420959 +0200
  482. @@ -46,33 +46,13 @@
  483. #include "unwind-compat.h"
  484. #include "gthr.h"
  485. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  486. - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
  487. - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
  488. -# define USE_PT_GNU_EH_FRAME
  489. -#endif
  490. -
  491. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  492. - && defined(__BIONIC__)
  493. -# define USE_PT_GNU_EH_FRAME
  494. -#endif
  495. -
  496. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  497. - && defined(__FreeBSD__) && __FreeBSD__ >= 7
  498. -# define ElfW __ElfN
  499. -# define USE_PT_GNU_EH_FRAME
  500. -#endif
  501. -
  502. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  503. - && defined(__OpenBSD__)
  504. -# define ElfW(type) Elf_##type
  505. -# define USE_PT_GNU_EH_FRAME
  506. -#endif
  507. -
  508. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  509. - && defined(TARGET_DL_ITERATE_PHDR) \
  510. - && defined(__sun__) && defined(__svr4__)
  511. +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
  512. # define USE_PT_GNU_EH_FRAME
  513. +# ifdef __OpenBSD__
  514. +# define ElfW(type) Elf_##typ
  515. +# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
  516. +# define ElfW __ElfN
  517. +# endif
  518. #endif
  519. #if defined(USE_PT_GNU_EH_FRAME)
  520. diff -Nur gcc-4.8.3.orig/libgomp/config/posix/time.c gcc-4.8.3/libgomp/config/posix/time.c
  521. --- gcc-4.8.3.orig/libgomp/config/posix/time.c 2013-01-14 19:18:49.000000000 +0100
  522. +++ gcc-4.8.3/libgomp/config/posix/time.c 2014-05-23 08:22:49.975420996 +0200
  523. @@ -28,6 +28,8 @@
  524. The following implementation uses the most simple POSIX routines.
  525. If present, POSIX 4 clocks should be used instead. */
  526. +#define _POSIX_C_SOURCE 199309L /* for clocks */
  527. +
  528. #include "libgomp.h"
  529. #include <unistd.h>
  530. #if TIME_WITH_SYS_TIME
  531. diff -Nur gcc-4.8.3.orig/libitm/config/arm/hwcap.cc gcc-4.8.3/libitm/config/arm/hwcap.cc
  532. --- gcc-4.8.3.orig/libitm/config/arm/hwcap.cc 2013-02-03 18:46:11.000000000 +0100
  533. +++ gcc-4.8.3/libitm/config/arm/hwcap.cc 2014-05-23 08:22:49.979421003 +0200
  534. @@ -40,7 +40,11 @@
  535. #ifdef __linux__
  536. #include <unistd.h>
  537. +#ifdef __GLIBC__
  538. #include <sys/fcntl.h>
  539. +#else
  540. +#include <fcntl.h>
  541. +#endif
  542. #include <elf.h>
  543. static void __attribute__((constructor))
  544. diff -Nur gcc-4.8.3.orig/libitm/config/linux/x86/tls.h gcc-4.8.3/libitm/config/linux/x86/tls.h
  545. --- gcc-4.8.3.orig/libitm/config/linux/x86/tls.h 2013-02-03 18:46:11.000000000 +0100
  546. +++ gcc-4.8.3/libitm/config/linux/x86/tls.h 2014-05-23 08:22:49.999421038 +0200
  547. @@ -25,16 +25,19 @@
  548. #ifndef LIBITM_X86_TLS_H
  549. #define LIBITM_X86_TLS_H 1
  550. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  551. +#if defined(__GLIBC_PREREQ)
  552. +#if __GLIBC_PREREQ(2, 10)
  553. /* Use slots in the TCB head rather than __thread lookups.
  554. GLIBC has reserved words 10 through 13 for TM. */
  555. #define HAVE_ARCH_GTM_THREAD 1
  556. #define HAVE_ARCH_GTM_THREAD_DISP 1
  557. #endif
  558. +#endif
  559. #include "config/generic/tls.h"
  560. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  561. +#if defined(__GLIBC_PREREQ)
  562. +#if __GLIBC_PREREQ(2, 10)
  563. namespace GTM HIDDEN {
  564. #ifdef __x86_64__
  565. @@ -101,5 +104,6 @@
  566. } // namespace GTM
  567. #endif /* >= GLIBC 2.10 */
  568. +#endif
  569. #endif // LIBITM_X86_TLS_H
  570. diff -Nur gcc-4.8.3.orig/libstdc++-v3/configure.host gcc-4.8.3/libstdc++-v3/configure.host
  571. --- gcc-4.8.3.orig/libstdc++-v3/configure.host 2013-06-19 03:18:38.000000000 +0200
  572. +++ gcc-4.8.3/libstdc++-v3/configure.host 2014-05-23 08:22:50.015421065 +0200
  573. @@ -264,6 +264,13 @@
  574. os_include_dir="os/bsd/freebsd"
  575. ;;
  576. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  577. + # check for musl by target
  578. + case "${host_os}" in
  579. + *-musl*)
  580. + os_include_dir="os/generic"
  581. + ;;
  582. + *)
  583. +
  584. if [ "$uclibc" = "yes" ]; then
  585. os_include_dir="os/uclibc"
  586. elif [ "$bionic" = "yes" ]; then
  587. @@ -272,6 +279,9 @@
  588. os_include_dir="os/gnu-linux"
  589. fi
  590. ;;
  591. +
  592. + esac
  593. + ;;
  594. hpux*)
  595. os_include_dir="os/hpux"
  596. ;;