PKGBUILD 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. # Contributor: Márcio Silva <coadde@hyperbola.info>
  2. # Maintainer: David P. <megver83@parabola.nu>
  3. # toolchain build order: {kernel}-api-headers->glibc->binutils->gcc->binutils->glibc
  4. # toolchain (for cross-compiler) build order:
  5. # {kernel}-api-headers(host system)->glibc(host system)
  6. # ->binutils(host system)->gcc(host system)->binutils(host system)->glibc(host system)
  7. # ->binutils(cross)->gcc(cross)
  8. # ->kernel-api-headers(target system)->glibc(target system)
  9. # ->binutils(target system)->gcc(target system)->binutils(target system)
  10. # ->glibc(target system)
  11. # NOTE: libtool requires rebuilt with each new gcc version
  12. #--------------------------------------------------------------------------------
  13. # cross-compile table
  14. #--------------------------------------------------------------------------------
  15. # +-------------+-------------+-----------------------------------------------------------------------------------------------------+-----------+---------+
  16. # | -march | CARCH | CTARGET (_CTARGET) | Multilib | QEMU |
  17. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  18. # | _march | CARCH | _arch | <machine> | _os_target (GNU/*) | _multilib | - |
  19. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  20. # | x86_64 | x86_64 | x86_64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kdragonflybsd,kopensolaris}-gnu|elf | yes | bin/sys |
  21. # | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | gnu|{linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnu|elf | no | bin/sys |
  22. # | armv8-a | aarch64 | aarch64 | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
  23. # | armv8-a | aarch64_be | aarch64_be | unknown | {linux,kfreebsd,knetbsd}-gnu|elf | no | bin/sys |
  24. # | armv7-a | armv7h | armv7l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
  25. # | armv6 | armv6h | armv6l | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabihf|elf | no | bin/sys |
  26. # | armv5te | arm | armv5tel | unknown | {linux,kfreebsd,kopenbsd,knetbsd,kopensolaris}-gnueabi | no | bin/sys |
  27. # | * | arm | arm | unknown | eabi | no | bin/sys |
  28. # | arm | armeb | armeb | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnueabi|eabi | no | bin |
  29. # | mips64el | mips64el | mips64el | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  30. # | mips64 | mips64 | mips64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  31. # | * | mipsel | mipsel | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  32. # | * | mips | mips | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  33. #v| powerpc64 | powerpc64 | powerpc64 | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |x|eabi
  34. #x| powerpc64le | powerpc64le | powerpc64le | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin |
  35. # | powerpc | powerpc | powerpc | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | bin/sys |
  36. # | powerpcle | powerpcle | powerpcle | unknown | {linux,kfreebsd,kopenbsd,knetbsd}-gnu{,eabi}|{elf,eabi} | no | - |
  37. # | - | spu | spu | unknown | elf | no | - |
  38. # | - | sh64 | sh64 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
  39. # | - | sh64le | sh64le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - |
  40. # | - | sh4 | sh4 | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  41. # | - | sh4le | sh4le | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | bin/sys |
  42. # | - | sh | sh | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
  43. # | - | shle | shle | unknown | {linux,kopenbsd,knetbsd}-gnu|elf | no | - @ |
  44. # | - | m68k | m68k | unknown | gnu|{linux,knetbsd}-gnu|elf | no | bin/sys |
  45. # | - | avr | avr | unknown | linux-gnu|elf | no | - |
  46. # | - | xtensa | xtensa | unknown | linux-gnu|elf | no | sys |
  47. # | - | lm32 | lm32 | unknown | linux-gnu|elf | no | sys |
  48. # | - | or32 | or32 | unknown | linux-gnu|elf | no | bin/sys |x|linux-gnu
  49. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  50. # For "Wine, Darling and DOSBox"
  51. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  52. # | x86_64 | x86_64 | x86_64 | unknown | mingw64(Wine)|darwin | yes | bin/sys |
  53. # | i[3-7]86 | i[3-7]86 | i[3-7]86 | pc | mingw32(Wine)|msdosdjgpp(DOSBox)|darwin | no | bin/sys |
  54. # | armv7-a | armv7h | armv7l | unknown | mingw-arm(Wine)|darwin | no | bin/sys |
  55. # | powerpc | powerpc | powerpc | unknown | darwin | no | bin/sys |
  56. # +-------------+-------------+-------------+-----------+---------------------------------------------------------------------------+-----------+---------+
  57. # opt : Multilib is optional
  58. # * : Any supported by architecture.
  59. # - : None.
  60. # @ : bin/sys (Only sh4 and sh4l support)
  61. # < : experimental support. (future)
  62. #--------------------------------------------------------------------------------
  63. # Tips for build()
  64. #--------------------------------------------------------------------------------
  65. # * If builing without "--disable-multilib" make sure to have "--with-python-dir=share/gcc-$_target"
  66. #
  67. # * When building using `make' instead of `make all-gcc' append "--with-sysroot=/usr/$_target" and
  68. # "--with-native-system-header-dir=/include". You'll also have to build and add a libc implementation
  69. # in makedepends as $_target-<libc> (e.g. $_target-newlib or $_target-glibc)
  70. #--------------------------------------------------------------------------------
  71. # Choosing the correct pkgdesc
  72. #--------------------------------------------------------------------------------
  73. # You must know wether your toolchain is a bare-metal one, if it's specifically for big-endian or
  74. # little-endian order and know its full name, if possible. Here are some useful tips:
  75. #
  76. # * If the toolchain has no operating system (see the toolchain triplet, <_os_target>), then it's a
  77. # bare-metal toolchain, in which case you have to specify it in the pkgdesc
  78. #
  79. # * Do a bit of research in forums, wikis and documents about the target you plan to build, a good
  80. # idea is to see the description that other distros put (e.g. Debian) if they have the same toolchain
  81. #
  82. # Example: arm-linux-gnueabi-{gcc,binutils,$etc}
  83. # This toolchain has GNU/Linux as OS, so it's not a bare-metal one. It's for armel, which
  84. # stands for "ARM EABI little-endian", but the gnueabi part means it uses the GNU EABI. You can find
  85. # that info in Debian's gcc-arm-linux-gnueabi and a couple of FLOSS and programmers community forums.
  86. # Toolchain triplet: <_arch>-<machine>-<_os_target>
  87. # <machine> is generally optional and uneeded
  88. _target=x86_64-pc-linux-gnu
  89. # This are some common options for names. Change $_target_name in pkgdesc according to the target architecture.
  90. case ${_target%%-*} in
  91. arm*) _target_name=ARM
  92. ;;
  93. aarch64*) _target_name=ARM64
  94. ;;
  95. xtensa) _target_name=Xtensa
  96. ;;
  97. sh*) _target_name=SuperH
  98. ;;
  99. powerpc*) _target_name=PowerPC
  100. ;;
  101. riscv*) _target_name=RISC-V
  102. ;;
  103. mips*) _target_name=MIPS
  104. ;;
  105. i686) _target_name=x86
  106. ;;
  107. *) _target_name=${_target%%-*}
  108. ;;
  109. esac
  110. # Learn more about the correct package naming here:
  111. # https://wiki.archlinux.org/index.php/Cross-compiling_tools_package_guidelines#Package_naming
  112. pkgname=$_target-gcc
  113. _pkgver=10.1.0
  114. #_snapshot=9-20190601
  115. pkgver=$_pkgver${_snapshot/*-/+}
  116. _islver=0.22
  117. pkgrel=1
  118. pkgdesc="The GNU Compiler Collection - cross compiler for $_target_name target"
  119. arch=('i686' 'x86_64' 'armv7h' 'aarch64' 'mips64el' 'ppc64le')
  120. url='http://gcc.gnu.org/'
  121. license=(GPL LGPL FDL)
  122. depends=($_target-binutils libmpc zlib)
  123. makedepends=(gmp mpfr)
  124. # Uncomment the following if building --with-newlib support
  125. #optdepends=("$_target-newlib: Standard C library ($_target target)")
  126. options=(!emptydirs !strip)
  127. source=(https://gcc.gnu.org/pub/gcc/releases/gcc-$_pkgver/gcc-$_pkgver.tar.xz
  128. #https://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
  129. http://isl.gforge.inria.fr/isl-$_islver.tar.bz2)
  130. sha512sums=('0cb2a74c793face751f42bc580960b00e2bfea785872a0a2155f1f1dbfaa248f9591b67f4322db0f096f8844aca9243bc02732bda106c3b6e43b02bb67eb3096'
  131. 'fc2c9796979610dd51143dcefe4f5c989c4354571cc5a1fcc6b932fd41f42a54f6b43adfd289af61be7bd06f3a523fa6a7d7ee56680e32d8036beb4c188fa668')
  132. if [ -n "$_snapshot" ]; then
  133. _basedir=gcc-$_snapshot
  134. else
  135. _basedir=gcc-$_pkgver
  136. fi
  137. prepare() {
  138. cd $_basedir
  139. # link isl for in-tree builds
  140. ln -sf ../isl-$_islver isl
  141. echo $_pkgver > gcc/BASE-VER
  142. # Do not run fixincludes
  143. sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
  144. # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
  145. sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" "$srcdir"/$_basedir/{libiberty,gcc}/configure
  146. mkdir $srcdir/gcc-build
  147. }
  148. build() {
  149. cd gcc-build
  150. # using -pipe causes spurious test-suite failures
  151. # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
  152. CFLAGS=${CFLAGS/-pipe/}
  153. CXXFLAGS=${CXXFLAGS/-pipe/}
  154. $srcdir/$_basedir/configure \
  155. --target=$_target \
  156. --prefix=/usr \
  157. --libexecdir=/usr/lib \
  158. --enable-languages=c,c++ \
  159. --enable-plugins \
  160. --enable-shared \
  161. --disable-decimal-float \
  162. --disable-libffi \
  163. --disable-libgomp \
  164. --disable-libmudflap \
  165. --disable-libquadmath \
  166. --disable-libssp \
  167. --disable-libstdcxx-pch \
  168. --disable-nls \
  169. --disable-threads \
  170. --disable-tls \
  171. --disable-multilib \
  172. --with-gnu-as \
  173. --with-gnu-ld \
  174. --with-system-zlib \
  175. --with-gmp \
  176. --with-mpfr \
  177. --with-mpc \
  178. --with-isl \
  179. --with-libelf \
  180. --enable-gnu-indirect-function
  181. make all-gcc
  182. }
  183. package() {
  184. # Uncomment the last part if libgcc was also built
  185. cd gcc-build -C make DESTDIR="$pkgdir" install-gcc # install-target-{libgcc,libstdc++-v3}
  186. # strip target binaries
  187. # add "$pkgdir"/usr/$_target/lib next to "$pkgdir"/usr/lib/gcc/$_target/ if libgcc was built
  188. find "$pkgdir"/usr/lib/gcc/$_target/ \
  189. -type f -and \( -name \*.a -or -name \*.o \) \
  190. -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges \
  191. -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line \
  192. -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
  193. # strip host binaries
  194. find "$pkgdir/usr/bin/" "$pkgdir/usr/lib/gcc/$_target/" -type f \
  195. -and \( -executable \) -exec strip '{}' \;
  196. # Remove files that conflict with host gcc package
  197. rm -r "$pkgdir/usr/share/"{man/man7,info}
  198. }