musl-cross.patch 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. diff -Nur gcc-4.7.3.orig/config.sub gcc-4.7.3/config.sub
  2. --- gcc-4.7.3.orig/config.sub 2012-08-06 16:34:27.000000000 +0200
  3. +++ gcc-4.7.3/config.sub 2013-09-16 15:39:42.000000000 +0200
  4. @@ -4,7 +4,7 @@
  5. # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
  6. # 2011 Free Software Foundation, Inc.
  7. -timestamp='2011-10-29'
  8. +timestamp='2011-03-23'
  9. # This file is (in principle) common to ALL GNU software.
  10. # The presence of a machine in this file suggests that SOME GNU software
  11. @@ -125,6 +125,7 @@
  12. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
  13. case $maybe_os in
  14. nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
  15. + linux-musl* | \
  16. linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
  17. knetbsd*-gnu* | netbsd*-gnu* | \
  18. kopensolaris*-gnu* | \
  19. @@ -251,17 +252,13 @@
  20. | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
  21. | am33_2.0 \
  22. | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
  23. - | be32 | be64 \
  24. | bfin \
  25. | c4x | clipper \
  26. | d10v | d30v | dlx | dsp16xx \
  27. - | epiphany \
  28. | fido | fr30 | frv \
  29. | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
  30. - | hexagon \
  31. | i370 | i860 | i960 | ia64 \
  32. | ip2k | iq2000 \
  33. - | le32 | le64 \
  34. | lm32 \
  35. | m32c | m32r | m32rle | m68000 | m68k | m88k \
  36. | maxq | mb | microblaze | mcore | mep | metag \
  37. @@ -295,7 +292,7 @@
  38. | pdp10 | pdp11 | pj | pjl \
  39. | powerpc | powerpc64 | powerpc64le | powerpcle \
  40. | pyramid \
  41. - | rl78 | rx \
  42. + | rx \
  43. | score \
  44. | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
  45. | sh64 | sh64le \
  46. @@ -304,7 +301,7 @@
  47. | spu \
  48. | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
  49. | ubicom32 \
  50. - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
  51. + | v850 | v850e \
  52. | we32k \
  53. | x86 | xc16x | xstormy16 | xtensa \
  54. | z8k | z80)
  55. @@ -361,7 +358,6 @@
  56. | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
  57. | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
  58. | avr-* | avr32-* \
  59. - | be32-* | be64-* \
  60. | bfin-* | bs2000-* \
  61. | c[123]* | c30-* | [cjt]90-* | c4x-* \
  62. | clipper-* | craynv-* | cydra-* \
  63. @@ -370,10 +366,8 @@
  64. | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
  65. | h8300-* | h8500-* \
  66. | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
  67. - | hexagon-* \
  68. | i*86-* | i860-* | i960-* | ia64-* \
  69. | ip2k-* | iq2000-* \
  70. - | le32-* | le64-* \
  71. | lm32-* \
  72. | m32c-* | m32r-* | m32rle-* \
  73. | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
  74. @@ -407,7 +401,7 @@
  75. | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
  76. | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
  77. | pyramid-* \
  78. - | rl78-* | romp-* | rs6000-* | rx-* \
  79. + | romp-* | rs6000-* | rx-* \
  80. | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
  81. | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
  82. | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
  83. @@ -415,11 +409,10 @@
  84. | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
  85. | tahoe-* \
  86. | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
  87. - | tile*-* \
  88. + | tile-* | tilegx-* \
  89. | tron-* \
  90. | ubicom32-* \
  91. - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
  92. - | vax-* \
  93. + | v850-* | v850e-* | vax-* \
  94. | we32k-* \
  95. | x86-* | x86_64-* | xc16x-* | xps100-* \
  96. | xstormy16-* | xtensa*-* \
  97. @@ -820,10 +813,6 @@
  98. basic_machine=i370-ibm
  99. os=-mvs
  100. ;;
  101. - nacl)
  102. - basic_machine=le32-unknown
  103. - os=-nacl
  104. - ;;
  105. ncr3000)
  106. basic_machine=i486-ncr
  107. os=-sysv4
  108. @@ -1132,8 +1121,13 @@
  109. basic_machine=t90-cray
  110. os=-unicos
  111. ;;
  112. + # This must be matched before tile*.
  113. + tilegx*)
  114. + basic_machine=tilegx-unknown
  115. + os=-linux-gnu
  116. + ;;
  117. tile*)
  118. - basic_machine=$basic_machine-unknown
  119. + basic_machine=tile-unknown
  120. os=-linux-gnu
  121. ;;
  122. tx39)
  123. @@ -1346,6 +1340,7 @@
  124. | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
  125. | -mingw32* | -linux-gnu* | -linux-android* \
  126. | -linux-newlib* | -linux-uclibc* \
  127. + | -linux-musl* \
  128. | -uxpv* | -beos* | -mpeix* | -udk* \
  129. | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
  130. | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
  131. diff -Nur gcc-4.7.3.orig/fixincludes/mkfixinc.sh gcc-4.7.3/fixincludes/mkfixinc.sh
  132. --- gcc-4.7.3.orig/fixincludes/mkfixinc.sh 2011-09-22 16:00:17.000000000 +0200
  133. +++ gcc-4.7.3/fixincludes/mkfixinc.sh 2013-09-16 15:39:42.000000000 +0200
  134. @@ -20,7 +20,8 @@
  135. powerpc-*-eabi* | \
  136. powerpc-*-rtems* | \
  137. powerpcle-*-eabisim* | \
  138. - powerpcle-*-eabi* )
  139. + powerpcle-*-eabi* | \
  140. + *-musl* )
  141. # IF there is no include fixing,
  142. # THEN create a no-op fixer and exit
  143. (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
  144. diff -Nur gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h gcc-4.7.3/gcc/config/arm/linux-eabi.h
  145. --- gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h 2011-11-02 16:03:19.000000000 +0100
  146. +++ gcc-4.7.3/gcc/config/arm/linux-eabi.h 2013-09-16 15:39:42.000000000 +0200
  147. @@ -64,6 +64,23 @@
  148. #undef GLIBC_DYNAMIC_LINKER
  149. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
  150. +/* For ARM musl currently supports two dynamic linkers:
  151. + - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
  152. + - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI.
  153. + musl does not support the legacy OABI (i.e. broken) mode.
  154. + All the dynamic linkers live in /lib.
  155. + We default to soft-float, but this can be overridden by changing both
  156. + MUSL_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
  157. +#undef MUSL_DYNAMIC_LINKER
  158. +#define MUSL_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-musl-arm.so.1"
  159. +#define MUSL_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-musl-armhf.so.1"
  160. +#define MUSL_DYNAMIC_LINKER_DEFAULT MUSL_DYNAMIC_LINKER_SOFT_FLOAT
  161. +
  162. +#define MUSL_DYNAMIC_LINKER \
  163. + "%{mfloat-abi=hard:" MUSL_DYNAMIC_LINKER_HARD_FLOAT "} \
  164. + %{mfloat-abi=soft*:" MUSL_DYNAMIC_LINKER_SOFT_FLOAT "} \
  165. + %{!mfloat-abi=*:" MUSL_DYNAMIC_LINKER_DEFAULT "}"
  166. +
  167. /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
  168. use the GNU/Linux version, not the generic BPABI version. */
  169. #undef LINK_SPEC
  170. diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux64.h gcc-4.7.3/gcc/config/i386/linux64.h
  171. --- gcc-4.7.3.orig/gcc/config/i386/linux64.h 2011-07-07 17:38:34.000000000 +0200
  172. +++ gcc-4.7.3/gcc/config/i386/linux64.h 2013-09-16 15:39:42.000000000 +0200
  173. @@ -31,3 +31,7 @@
  174. #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
  175. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
  176. #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
  177. +
  178. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
  179. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
  180. +#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
  181. diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux.h gcc-4.7.3/gcc/config/i386/linux.h
  182. --- gcc-4.7.3.orig/gcc/config/i386/linux.h 2011-06-03 20:30:39.000000000 +0200
  183. +++ gcc-4.7.3/gcc/config/i386/linux.h 2013-09-16 15:39:42.000000000 +0200
  184. @@ -22,3 +22,4 @@
  185. #define GNU_USER_LINK_EMULATION "elf_i386"
  186. #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
  187. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
  188. diff -Nur gcc-4.7.3.orig/gcc/config/linux.h gcc-4.7.3/gcc/config/linux.h
  189. --- gcc-4.7.3.orig/gcc/config/linux.h 2012-08-14 15:59:04.000000000 +0200
  190. +++ gcc-4.7.3/gcc/config/linux.h 2013-09-16 15:39:42.000000000 +0200
  191. @@ -33,10 +33,12 @@
  192. #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
  193. #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
  194. #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
  195. +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
  196. #else
  197. #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
  198. #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
  199. #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
  200. +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
  201. #endif
  202. #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
  203. @@ -54,18 +56,21 @@
  204. uClibc or Bionic is the default C library and whether
  205. -muclibc or -mglibc or -mbionic has been passed to change the default. */
  206. -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
  207. - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
  208. +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
  209. + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
  210. #if DEFAULT_LIBC == LIBC_GLIBC
  211. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  212. - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
  213. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  214. + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
  215. #elif DEFAULT_LIBC == LIBC_UCLIBC
  216. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  217. - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
  218. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  219. + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
  220. #elif DEFAULT_LIBC == LIBC_BIONIC
  221. -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
  222. - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
  223. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  224. + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
  225. +#elif DEFAULT_LIBC == LIBC_MUSL
  226. +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
  227. + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
  228. #else
  229. #error "Unsupported DEFAULT_LIBC"
  230. #endif /* DEFAULT_LIBC */
  231. @@ -85,21 +90,21 @@
  232. #define GNU_USER_DYNAMIC_LINKER \
  233. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
  234. - BIONIC_DYNAMIC_LINKER)
  235. + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  236. #define GNU_USER_DYNAMIC_LINKER32 \
  237. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
  238. - BIONIC_DYNAMIC_LINKER32)
  239. + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  240. #define GNU_USER_DYNAMIC_LINKER64 \
  241. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
  242. - BIONIC_DYNAMIC_LINKER64)
  243. + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  244. #define GNU_USER_DYNAMIC_LINKERX32 \
  245. CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
  246. - BIONIC_DYNAMIC_LINKERX32)
  247. + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
  248. /* Determine whether the entire c99 runtime
  249. is present in the runtime library. */
  250. #undef TARGET_C99_FUNCTIONS
  251. -#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  252. +#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL)
  253. /* Whether we have sincos that follows the GNU extension. */
  254. #undef TARGET_HAS_SINCOS
  255. @@ -108,3 +113,74 @@
  256. /* Whether we have Bionic libc runtime */
  257. #undef TARGET_HAS_BIONIC
  258. #define TARGET_HAS_BIONIC (OPTION_BIONIC)
  259. +
  260. +/* musl avoids problematic includes by rearranging the include directories.
  261. + * Unfortunately, this is mostly duplicated from cppdefault.c */
  262. +#if DEFAULT_LIBC == LIBC_MUSL
  263. +#define INCLUDE_DEFAULTS_MUSL_GPP \
  264. + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
  265. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
  266. + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
  267. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
  268. + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
  269. + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
  270. +
  271. +#ifdef LOCAL_INCLUDE_DIR
  272. +#define INCLUDE_DEFAULTS_MUSL_LOCAL \
  273. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
  274. + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
  275. +#else
  276. +#define INCLUDE_DEFAULTS_MUSL_LOCAL
  277. +#endif
  278. +
  279. +#ifdef PREFIX_INCLUDE_DIR
  280. +#define INCLUDE_DEFAULTS_MUSL_PREFIX \
  281. + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
  282. +#else
  283. +#define INCLUDE_DEFAULTS_MUSL_PREFIX
  284. +#endif
  285. +
  286. +#ifdef CROSS_INCLUDE_DIR
  287. +#define INCLUDE_DEFAULTS_MUSL_CROSS \
  288. + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
  289. +#else
  290. +#define INCLUDE_DEFAULTS_MUSL_CROSS
  291. +#endif
  292. +
  293. +#ifdef TOOL_INCLUDE_DIR
  294. +#define INCLUDE_DEFAULTS_MUSL_TOOL \
  295. + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
  296. +#else
  297. +#define INCLUDE_DEFAULTS_MUSL_TOOL
  298. +#endif
  299. +
  300. +#ifdef NATIVE_SYSTEM_HEADER_DIR
  301. +#define INCLUDE_DEFAULTS_MUSL_NATIVE \
  302. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
  303. + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
  304. +#else
  305. +#define INCLUDE_DEFAULTS_MUSL_NATIVE
  306. +#endif
  307. +
  308. +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
  309. +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
  310. +# define INCLUDE_DEFAULTS_MUSL_LOCAL
  311. +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
  312. +# define INCLUDE_DEFAULTS_MUSL_NATIVE
  313. +#else
  314. +# undef INCLUDE_DEFAULTS_MUSL_CROSS
  315. +# define INCLUDE_DEFAULTS_MUSL_CROSS
  316. +#endif
  317. +
  318. +#undef INCLUDE_DEFAULTS
  319. +#define INCLUDE_DEFAULTS \
  320. + { \
  321. + INCLUDE_DEFAULTS_MUSL_GPP \
  322. + INCLUDE_DEFAULTS_MUSL_PREFIX \
  323. + INCLUDE_DEFAULTS_MUSL_CROSS \
  324. + INCLUDE_DEFAULTS_MUSL_TOOL \
  325. + INCLUDE_DEFAULTS_MUSL_NATIVE \
  326. + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
  327. + { 0, 0, 0, 0, 0, 0 } \
  328. + }
  329. +#endif
  330. diff -Nur gcc-4.7.3.orig/gcc/config/linux.opt gcc-4.7.3/gcc/config/linux.opt
  331. --- gcc-4.7.3.orig/gcc/config/linux.opt 2010-09-29 16:51:52.000000000 +0200
  332. +++ gcc-4.7.3/gcc/config/linux.opt 2013-09-16 15:39:42.000000000 +0200
  333. @@ -30,3 +30,7 @@
  334. muclibc
  335. Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
  336. Use uClibc C library
  337. +
  338. +mmusl
  339. +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
  340. +Use musl C library
  341. diff -Nur gcc-4.7.3.orig/gcc/config/mips/linux.h gcc-4.7.3/gcc/config/mips/linux.h
  342. --- gcc-4.7.3.orig/gcc/config/mips/linux.h 2011-07-19 20:00:27.000000000 +0200
  343. +++ gcc-4.7.3/gcc/config/mips/linux.h 2013-09-16 15:39:43.000000000 +0200
  344. @@ -19,3 +19,5 @@
  345. <http://www.gnu.org/licenses/>. */
  346. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  347. +
  348. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
  349. diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/linux64.h gcc-4.7.3/gcc/config/rs6000/linux64.h
  350. --- gcc-4.7.3.orig/gcc/config/rs6000/linux64.h 2012-03-12 17:16:51.000000000 +0100
  351. +++ gcc-4.7.3/gcc/config/rs6000/linux64.h 2013-09-16 15:39:43.000000000 +0200
  352. @@ -362,17 +362,21 @@
  353. #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
  354. #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
  355. #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
  356. +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
  357. +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
  358. #if DEFAULT_LIBC == LIBC_UCLIBC
  359. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  360. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  361. #elif DEFAULT_LIBC == LIBC_GLIBC
  362. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  363. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  364. +#elif DEFAULT_LIBC == LIBC_MUSL
  365. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  366. #else
  367. #error "Unsupported DEFAULT_LIBC"
  368. #endif
  369. #define GNU_USER_DYNAMIC_LINKER32 \
  370. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
  371. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
  372. #define GNU_USER_DYNAMIC_LINKER64 \
  373. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
  374. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
  375. #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
  376. diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/secureplt.h gcc-4.7.3/gcc/config/rs6000/secureplt.h
  377. --- gcc-4.7.3.orig/gcc/config/rs6000/secureplt.h 2007-08-02 12:49:31.000000000 +0200
  378. +++ gcc-4.7.3/gcc/config/rs6000/secureplt.h 2013-09-16 15:39:43.000000000 +0200
  379. @@ -18,3 +18,4 @@
  380. <http://www.gnu.org/licenses/>. */
  381. #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
  382. +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
  383. diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h gcc-4.7.3/gcc/config/rs6000/sysv4.h
  384. --- gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h 2012-04-30 19:39:01.000000000 +0200
  385. +++ gcc-4.7.3/gcc/config/rs6000/sysv4.h 2013-09-16 15:39:43.000000000 +0200
  386. @@ -566,6 +566,9 @@
  387. #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
  388. #define CC1_SECURE_PLT_DEFAULT_SPEC ""
  389. #endif
  390. +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
  391. +#define LINK_SECURE_PLT_DEFAULT_SPEC ""
  392. +#endif
  393. /* Pass -G xxx to the compiler and set correct endian mode. */
  394. #define CC1_SPEC "%{G*} %(cc1_cpu) \
  395. @@ -626,7 +629,8 @@
  396. %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \
  397. %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
  398. %{mcall-i960-old: --oformat elf32-powerpcle} \
  399. - }}}}"
  400. + }}}} \
  401. +%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
  402. /* Any specific OS flags. */
  403. #define LINK_OS_SPEC "\
  404. @@ -804,15 +808,18 @@
  405. #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
  406. #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
  407. +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
  408. #if DEFAULT_LIBC == LIBC_UCLIBC
  409. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
  410. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
  411. +#elif DEFAULT_LIBC == LIBC_MUSL
  412. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
  413. #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
  414. -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
  415. +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
  416. #else
  417. #error "Unsupported DEFAULT_LIBC"
  418. #endif
  419. #define GNU_USER_DYNAMIC_LINKER \
  420. - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
  421. + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
  422. #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
  423. %{rdynamic:-export-dynamic} \
  424. @@ -938,6 +945,7 @@
  425. { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
  426. { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
  427. { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
  428. + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
  429. { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
  430. { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
  431. { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
  432. diff -Nur gcc-4.7.3.orig/gcc/config.gcc gcc-4.7.3/gcc/config.gcc
  433. --- gcc-4.7.3.orig/gcc/config.gcc 2013-03-06 23:54:11.000000000 +0100
  434. +++ gcc-4.7.3/gcc/config.gcc 2013-09-16 15:39:43.000000000 +0200
  435. @@ -522,7 +522,7 @@
  436. esac
  437. # Common C libraries.
  438. -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
  439. +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
  440. # Common parts for widely ported systems.
  441. case ${target} in
  442. @@ -625,6 +625,9 @@
  443. *-*-*uclibc*)
  444. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
  445. ;;
  446. + *-*-*musl*)
  447. + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
  448. + ;;
  449. *)
  450. tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
  451. ;;
  452. @@ -2092,6 +2095,10 @@
  453. powerpc*-*-linux*paired*)
  454. tm_file="${tm_file} rs6000/750cl.h" ;;
  455. esac
  456. + case ${target} in
  457. + *-linux*-musl*)
  458. + enable_secureplt=yes ;;
  459. + esac
  460. if test x${enable_secureplt} = xyes; then
  461. tm_file="rs6000/secureplt.h ${tm_file}"
  462. fi
  463. diff -Nur gcc-4.7.3.orig/gcc/configure gcc-4.7.3/gcc/configure
  464. --- gcc-4.7.3.orig/gcc/configure 2013-02-06 16:23:55.000000000 +0100
  465. +++ gcc-4.7.3/gcc/configure 2013-09-16 15:39:43.000000000 +0200
  466. @@ -26815,7 +26815,8 @@
  467. gcc_cv_libc_provides_ssp=yes
  468. fi
  469. ;;
  470. - *-*-gnu*)
  471. + *-*-gnu* | \
  472. + *-linux-musl*)
  473. # Avoid complicated tests (see
  474. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  475. # simply assert that glibc does provide this, which is true for all
  476. @@ -26902,6 +26903,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. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  485. diff -Nur gcc-4.7.3.orig/gcc/configure.ac gcc-4.7.3/gcc/configure.ac
  486. --- gcc-4.7.3.orig/gcc/configure.ac 2013-02-06 16:23:55.000000000 +0100
  487. +++ gcc-4.7.3/gcc/configure.ac 2013-09-16 15:39:43.000000000 +0200
  488. @@ -4692,7 +4692,8 @@
  489. gcc_cv_libc_provides_ssp=yes
  490. fi]
  491. ;;
  492. - *-*-gnu*)
  493. + *-*-gnu* | \
  494. + *-linux-musl*)
  495. # Avoid complicated tests (see
  496. # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
  497. # simply assert that glibc does provide this, which is true for all
  498. @@ -4762,6 +4763,9 @@
  499. gcc_cv_target_dl_iterate_phdr=no
  500. fi
  501. ;;
  502. + *-linux-musl*)
  503. + gcc_cv_target_dl_iterate_phdr=yes
  504. + ;;
  505. esac
  506. GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
  507. if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
  508. diff -Nur gcc-4.7.3.orig/gcc/ginclude/stddef.h gcc-4.7.3/gcc/ginclude/stddef.h
  509. --- gcc-4.7.3.orig/gcc/ginclude/stddef.h 2012-02-12 02:06:04.000000000 +0100
  510. +++ gcc-4.7.3/gcc/ginclude/stddef.h 2013-09-16 15:39:43.000000000 +0200
  511. @@ -184,6 +184,7 @@
  512. #ifndef _GCC_SIZE_T
  513. #ifndef _SIZET_
  514. #ifndef __size_t
  515. +#ifndef __DEFINED_size_t /* musl */
  516. #define __size_t__ /* BeOS */
  517. #define __SIZE_T__ /* Cray Unicos/Mk */
  518. #define _SIZE_T
  519. @@ -200,6 +201,7 @@
  520. #define ___int_size_t_h
  521. #define _GCC_SIZE_T
  522. #define _SIZET_
  523. +#define __DEFINED_size_t /* musl */
  524. #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
  525. || defined(__FreeBSD_kernel__)
  526. /* __size_t is a typedef on FreeBSD 5, must not trash it. */
  527. @@ -215,6 +217,7 @@
  528. typedef long ssize_t;
  529. #endif /* __BEOS__ */
  530. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  531. +#endif /* __DEFINED_size_t */
  532. #endif /* __size_t */
  533. #endif /* _SIZET_ */
  534. #endif /* _GCC_SIZE_T */
  535. diff -Nur gcc-4.7.3.orig/libgcc/unwind-dw2-fde-dip.c gcc-4.7.3/libgcc/unwind-dw2-fde-dip.c
  536. --- gcc-4.7.3.orig/libgcc/unwind-dw2-fde-dip.c 2012-10-06 23:55:06.000000000 +0200
  537. +++ gcc-4.7.3/libgcc/unwind-dw2-fde-dip.c 2013-09-16 15:39:43.000000000 +0200
  538. @@ -47,28 +47,13 @@
  539. #include "unwind-compat.h"
  540. #include "gthr.h"
  541. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  542. - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
  543. - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
  544. -# define USE_PT_GNU_EH_FRAME
  545. -#endif
  546. -
  547. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  548. - && defined(__FreeBSD__) && __FreeBSD__ >= 7
  549. -# define ElfW __ElfN
  550. -# define USE_PT_GNU_EH_FRAME
  551. -#endif
  552. -
  553. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  554. - && defined(__OpenBSD__)
  555. -# define ElfW(type) Elf_##type
  556. -# define USE_PT_GNU_EH_FRAME
  557. -#endif
  558. -
  559. -#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
  560. - && defined(TARGET_DL_ITERATE_PHDR) \
  561. - && defined(__sun__) && defined(__svr4__)
  562. +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
  563. # define USE_PT_GNU_EH_FRAME
  564. +# ifdef __OpenBSD__
  565. +# define ElfW(type) Elf_##typ
  566. +# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
  567. +# define ElfW __ElfN
  568. +# endif
  569. #endif
  570. #if defined(USE_PT_GNU_EH_FRAME)
  571. diff -Nur gcc-4.7.3.orig/libgomp/config/posix/time.c gcc-4.7.3/libgomp/config/posix/time.c
  572. --- gcc-4.7.3.orig/libgomp/config/posix/time.c 2009-04-09 17:00:19.000000000 +0200
  573. +++ gcc-4.7.3/libgomp/config/posix/time.c 2013-09-16 15:39:43.000000000 +0200
  574. @@ -28,6 +28,8 @@
  575. The following implementation uses the most simple POSIX routines.
  576. If present, POSIX 4 clocks should be used instead. */
  577. +#define _POSIX_C_SOURCE 199309L /* for clocks */
  578. +
  579. #include "libgomp.h"
  580. #include <unistd.h>
  581. #if TIME_WITH_SYS_TIME
  582. diff -Nur gcc-4.7.3.orig/libitm/config/arm/hwcap.cc gcc-4.7.3/libitm/config/arm/hwcap.cc
  583. --- gcc-4.7.3.orig/libitm/config/arm/hwcap.cc 2011-12-15 04:24:05.000000000 +0100
  584. +++ gcc-4.7.3/libitm/config/arm/hwcap.cc 2013-09-16 15:39:43.000000000 +0200
  585. @@ -40,7 +40,11 @@
  586. #ifdef __linux__
  587. #include <unistd.h>
  588. +#ifdef __GLIBC__
  589. #include <sys/fcntl.h>
  590. +#else
  591. +#include <fcntl.h>
  592. +#endif
  593. #include <elf.h>
  594. static void __attribute__((constructor))
  595. diff -Nur gcc-4.7.3.orig/libitm/config/linux/x86/tls.h gcc-4.7.3/libitm/config/linux/x86/tls.h
  596. --- gcc-4.7.3.orig/libitm/config/linux/x86/tls.h 2011-11-08 12:13:41.000000000 +0100
  597. +++ gcc-4.7.3/libitm/config/linux/x86/tls.h 2013-09-16 15:39:43.000000000 +0200
  598. @@ -25,16 +25,19 @@
  599. #ifndef LIBITM_X86_TLS_H
  600. #define LIBITM_X86_TLS_H 1
  601. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  602. +#if defined(__GLIBC_PREREQ)
  603. +#if __GLIBC_PREREQ(2, 10)
  604. /* Use slots in the TCB head rather than __thread lookups.
  605. GLIBC has reserved words 10 through 13 for TM. */
  606. #define HAVE_ARCH_GTM_THREAD 1
  607. #define HAVE_ARCH_GTM_THREAD_DISP 1
  608. #endif
  609. +#endif
  610. #include "config/generic/tls.h"
  611. -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
  612. +#if defined(__GLIBC_PREREQ)
  613. +#if __GLIBC_PREREQ(2, 10)
  614. namespace GTM HIDDEN {
  615. #ifdef __x86_64__
  616. @@ -101,5 +104,6 @@
  617. } // namespace GTM
  618. #endif /* >= GLIBC 2.10 */
  619. +#endif
  620. #endif // LIBITM_X86_TLS_H
  621. diff -Nur gcc-4.7.3.orig/libssp/configure gcc-4.7.3/libssp/configure
  622. --- gcc-4.7.3.orig/libssp/configure 2012-08-06 16:34:27.000000000 +0200
  623. +++ gcc-4.7.3/libssp/configure 2013-09-16 15:39:43.000000000 +0200
  624. @@ -626,6 +626,8 @@
  625. ssp_have_usable_vsnprintf
  626. EGREP
  627. GREP
  628. +LIBSSP_IN_LIBC_FALSE
  629. +LIBSSP_IN_LIBC_TRUE
  630. LIBSSP_USE_SYMVER_SUN_FALSE
  631. LIBSSP_USE_SYMVER_SUN_TRUE
  632. LIBSSP_USE_SYMVER_GNU_FALSE
  633. @@ -735,6 +737,7 @@
  634. enable_multilib
  635. enable_dependency_tracking
  636. enable_symvers
  637. +enable_ssp_in_libc
  638. enable_shared
  639. enable_static
  640. with_pic
  641. @@ -1374,6 +1377,7 @@
  642. --disable-dependency-tracking speeds up one-time build
  643. --enable-dependency-tracking do not reject slow dependency extractors
  644. --disable-symvers disable symbol versioning for libssp
  645. + --enable-ssp-in-libc do not build SSP, as it is in libc
  646. --enable-shared[=PKGS] build shared libraries [default=yes]
  647. --enable-static[=PKGS] build static libraries [default=yes]
  648. --enable-fast-install[=PKGS]
  649. @@ -4206,6 +4210,36 @@
  650. fi
  651. +# musl provides libssp in libc
  652. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libssp is provided in libc" >&5
  653. +$as_echo_n "checking whether libssp is provided in libc... " >&6; }
  654. +# Check whether --enable-ssp_in_libc was given.
  655. +if test "${enable_ssp_in_libc+set}" = set; then :
  656. + enableval=$enable_ssp_in_libc; ssp_in_libc=$enableval
  657. +else
  658. + ssp_in_libc=check
  659. +fi
  660. +
  661. +if test "x$ssp_in_libc" = "xcheck"; then
  662. + case "$host" in
  663. + *-musl*)
  664. + ssp_in_libc=yes
  665. + ;;
  666. +
  667. + *)
  668. + ssp_in_libc=no
  669. + ;;
  670. + esac
  671. +fi
  672. + if test "x$ssp_in_libc" = xyes; then
  673. + LIBSSP_IN_LIBC_TRUE=
  674. + LIBSSP_IN_LIBC_FALSE='#'
  675. +else
  676. + LIBSSP_IN_LIBC_TRUE='#'
  677. + LIBSSP_IN_LIBC_FALSE=
  678. +fi
  679. +
  680. +
  681. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
  682. $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
  683. @@ -10650,7 +10684,7 @@
  684. lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
  685. lt_status=$lt_dlunknown
  686. cat > conftest.$ac_ext <<_LT_EOF
  687. -#line 10653 "configure"
  688. +#line 10687 "configure"
  689. #include "confdefs.h"
  690. #if HAVE_DLFCN_H
  691. @@ -10756,7 +10790,7 @@
  692. lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
  693. lt_status=$lt_dlunknown
  694. cat > conftest.$ac_ext <<_LT_EOF
  695. -#line 10759 "configure"
  696. +#line 10793 "configure"
  697. #include "confdefs.h"
  698. #if HAVE_DLFCN_H
  699. @@ -11185,6 +11219,10 @@
  700. as_fn_error "conditional \"LIBSSP_USE_SYMVER_SUN\" was never defined.
  701. Usually this means the macro was only invoked conditionally." "$LINENO" 5
  702. fi
  703. +if test -z "${LIBSSP_IN_LIBC_TRUE}" && test -z "${LIBSSP_IN_LIBC_FALSE}"; then
  704. + as_fn_error "conditional \"LIBSSP_IN_LIBC\" was never defined.
  705. +Usually this means the macro was only invoked conditionally." "$LINENO" 5
  706. +fi
  707. : ${CONFIG_STATUS=./config.status}
  708. ac_write_fail=0
  709. diff -Nur gcc-4.7.3.orig/libssp/configure.ac gcc-4.7.3/libssp/configure.ac
  710. --- gcc-4.7.3.orig/libssp/configure.ac 2012-05-31 20:59:34.000000000 +0200
  711. +++ gcc-4.7.3/libssp/configure.ac 2013-09-16 15:39:43.000000000 +0200
  712. @@ -114,6 +114,26 @@
  713. AM_CONDITIONAL(LIBSSP_USE_SYMVER_GNU, [test "x$ssp_use_symver" = xgnu])
  714. AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test "x$ssp_use_symver" = xsun])
  715. +# musl provides libssp in libc
  716. +AC_MSG_CHECKING([whether libssp is provided in libc])
  717. +AC_ARG_ENABLE(ssp_in_libc,
  718. +AC_HELP_STRING([--enable-ssp-in-libc],
  719. + [do not build SSP, as it is in libc]),
  720. +ssp_in_libc=$enableval,
  721. +ssp_in_libc=check)
  722. +if test "x$ssp_in_libc" = "xcheck"; then
  723. + case "$host" in
  724. + *-musl*)
  725. + ssp_in_libc=yes
  726. + ;;
  727. +
  728. + *)
  729. + ssp_in_libc=no
  730. + ;;
  731. + esac
  732. +fi
  733. +AM_CONDITIONAL(LIBSSP_IN_LIBC, [test "x$ssp_in_libc" = xyes])
  734. +
  735. AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h)
  736. if test x$gcc_no_link = xyes; then
  737. diff -Nur gcc-4.7.3.orig/libssp/Makefile.am gcc-4.7.3/libssp/Makefile.am
  738. --- gcc-4.7.3.orig/libssp/Makefile.am 2010-12-06 01:50:04.000000000 +0100
  739. +++ gcc-4.7.3/libssp/Makefile.am 2013-09-16 15:39:43.000000000 +0200
  740. @@ -36,7 +36,11 @@
  741. AM_CFLAGS = -Wall
  742. +if LIBSSP_IN_LIBC
  743. +toolexeclib_LTLIBRARIES = libssp_nonshared.la
  744. +else
  745. toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
  746. +endif
  747. target_noncanonical = @target_noncanonical@
  748. libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
  749. diff -Nur gcc-4.7.3.orig/libssp/Makefile.in gcc-4.7.3/libssp/Makefile.in
  750. --- gcc-4.7.3.orig/libssp/Makefile.in 2011-02-13 12:45:53.000000000 +0100
  751. +++ gcc-4.7.3/libssp/Makefile.in 2013-09-16 15:39:43.000000000 +0200
  752. @@ -93,12 +93,17 @@
  753. libssp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
  754. $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
  755. $(libssp_la_LDFLAGS) $(LDFLAGS) -o $@
  756. +@LIBSSP_IN_LIBC_FALSE@am_libssp_la_rpath = -rpath $(toolexeclibdir)
  757. am_libssp_nonshared_la_OBJECTS = libssp_nonshared_la-ssp-local.lo
  758. libssp_nonshared_la_OBJECTS = $(am_libssp_nonshared_la_OBJECTS)
  759. libssp_nonshared_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
  760. $(LIBTOOLFLAGS) --mode=link $(CCLD) \
  761. $(libssp_nonshared_la_CFLAGS) $(CFLAGS) \
  762. $(libssp_nonshared_la_LDFLAGS) $(LDFLAGS) -o $@
  763. +@LIBSSP_IN_LIBC_FALSE@am_libssp_nonshared_la_rpath = -rpath \
  764. +@LIBSSP_IN_LIBC_FALSE@ $(toolexeclibdir)
  765. +@LIBSSP_IN_LIBC_TRUE@am_libssp_nonshared_la_rpath = -rpath \
  766. +@LIBSSP_IN_LIBC_TRUE@ $(toolexeclibdir)
  767. DEFAULT_INCLUDES = -I.@am__isrc@
  768. depcomp = $(SHELL) $(top_srcdir)/../depcomp
  769. am__depfiles_maybe = depfiles
  770. @@ -258,7 +263,8 @@
  771. @LIBSSP_USE_SYMVER_GNU_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = $(srcdir)/ssp.map
  772. @LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = ssp.map-sun
  773. AM_CFLAGS = -Wall
  774. -toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
  775. +@LIBSSP_IN_LIBC_FALSE@toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
  776. +@LIBSSP_IN_LIBC_TRUE@toolexeclib_LTLIBRARIES = libssp_nonshared.la
  777. libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
  778. nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
  779. libssp_la_SOURCES = \
  780. @@ -414,9 +420,9 @@
  781. rm -f "$${dir}/so_locations"; \
  782. done
  783. libssp.la: $(libssp_la_OBJECTS) $(libssp_la_DEPENDENCIES)
  784. - $(libssp_la_LINK) -rpath $(toolexeclibdir) $(libssp_la_OBJECTS) $(libssp_la_LIBADD) $(LIBS)
  785. + $(libssp_la_LINK) $(am_libssp_la_rpath) $(libssp_la_OBJECTS) $(libssp_la_LIBADD) $(LIBS)
  786. libssp_nonshared.la: $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_DEPENDENCIES)
  787. - $(libssp_nonshared_la_LINK) -rpath $(toolexeclibdir) $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_LIBADD) $(LIBS)
  788. + $(libssp_nonshared_la_LINK) $(am_libssp_nonshared_la_rpath) $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_LIBADD) $(LIBS)
  789. mostlyclean-compile:
  790. -rm -f *.$(OBJEXT)
  791. diff -Nur gcc-4.7.3.orig/libstdc++-v3/configure.host gcc-4.7.3/libstdc++-v3/configure.host
  792. --- gcc-4.7.3.orig/libstdc++-v3/configure.host 2012-12-18 15:27:14.000000000 +0100
  793. +++ gcc-4.7.3/libstdc++-v3/configure.host 2013-09-16 15:39:43.000000000 +0200
  794. @@ -243,6 +243,13 @@
  795. os_include_dir="os/bsd/freebsd"
  796. ;;
  797. gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
  798. + # check for musl by target
  799. + case "${host_os}" in
  800. + *-musl*)
  801. + os_include_dir="os/generic"
  802. + ;;
  803. + *)
  804. +
  805. if [ "$uclibc" = "yes" ]; then
  806. os_include_dir="os/uclibc"
  807. elif [ "$bionic" = "yes" ]; then
  808. @@ -251,6 +258,9 @@
  809. os_include_dir="os/gnu-linux"
  810. fi
  811. ;;
  812. +
  813. + esac
  814. + ;;
  815. hpux*)
  816. os_include_dir="os/hpux"
  817. ;;