recipe 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # Build recipe for GCC.
  2. #
  3. # Copyright (c) 2015-2018 Matias Fonzo, <selk@dragora.org>.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. program=gcc
  17. version=8-20181123
  18. release=1
  19. # Set 'outdir' for a nice and well-organized output directory
  20. outdir="${outdir}/${arch}/devel"
  21. tarname=${program}-${version}.tar.xz
  22. # Remote source(s)
  23. #fetch=http://gnu.c3sl.ufpr.br/ftp/gcc/gcc-${version}/$tarname
  24. fetch=ftp://gcc.gnu.org/pub/gcc/snapshots/${version}/$tarname
  25. homepage=http://www.gnu.org/software/gcc
  26. license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"
  27. description="
  28. The GNU C Compiler Collection.
  29. The GNU Compiler Collection (GCC) is a compiler system produced by the
  30. GNU Project supporting various programming languages. GCC is a key
  31. component of the GNU toolchain. The Free Software Foundation (FSF)
  32. distributes GCC under the GNU General Public License (GNU GPL).
  33. For more information about GCC, visit: $homepage
  34. "
  35. # Source documentation
  36. docs="COPYING* README"
  37. docsdir="${docdir}/${program}-${version}"
  38. # System-dependent
  39. MACHTYPE="$(cc -dumpmachine)"
  40. build()
  41. {
  42. set -e
  43. unpack "${tardir}/$tarname"
  44. cd "$srcdir"
  45. # Set sane permissions
  46. chmod -R u+w,go-w,a+rX-s .
  47. # Apply specific patches for the support in musl.
  48. # http://port70.net/~nsz/musl/gcc-8.2.0
  49. #patch -Np1 -i "${worktree}/patches/gcc/0001-ssp_nonshared.patch"
  50. patch -Np1 -i "${worktree}/patches/gcc/musl-libssp.diff"
  51. patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
  52. patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
  53. patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
  54. patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
  55. patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
  56. patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
  57. patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
  58. patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
  59. patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
  60. patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
  61. patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
  62. # Create a separate build directory
  63. rm -rf ../gcc-build
  64. mkdir ../gcc-build
  65. cd ../gcc-build
  66. ../${program}-${version}/configure SED=sed \
  67. $configure_args \
  68. $multilib_options \
  69. $gcc_options \
  70. --libdir=/usr/lib${libSuffix} \
  71. --mandir=$mandir \
  72. --infodir=$infodir \
  73. --enable-bootstrap \
  74. --enable-languages=c,c++,objc,obj-c++,fortran \
  75. --enable-clocale=generic \
  76. --enable-threads=posix \
  77. --enable-tls \
  78. --enable-nls \
  79. --enable-lto \
  80. --enable-libstdcxx-time \
  81. --enable-checking=release \
  82. --enable-fully-dynamic-string \
  83. --enable-default-ssp \
  84. --enable-default-pie \
  85. --disable-libssp \
  86. --disable-symvers \
  87. --disable-libitm \
  88. --disable-gnu-indirect-function \
  89. --disable-libstdcxx-pch \
  90. --disable-libmudflap \
  91. --disable-libsanitizer \
  92. --disable-libmpx \
  93. --disable-libcilkrts \
  94. --with-system-zlib \
  95. --build=$MACHTYPE \
  96. --host=$MACHTYPE \
  97. --target=$MACHTYPE
  98. make -j${jobs} V=1
  99. make -j${jobs} V=1 DESTDIR="$destdir" install-strip
  100. # Back to source dir
  101. cd .. && cd "$srcdir"
  102. # Provide minimal libssp_nonshared.a so we don't need libssp from GCC
  103. cc $QICFLAGS -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
  104. -o __stack_chk_fail_local.o
  105. ar r libssp_nonshared.a __stack_chk_fail_local.o
  106. cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
  107. strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
  108. # Move misplaced file(s) for GDB
  109. mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
  110. mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
  111. "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
  112. # Provide compatibility and make soft links for package size
  113. (
  114. cd "${destdir}/usr/bin" || exit 1
  115. mv gcc gcc-${version}
  116. ln -sf gcc-${version} gcc
  117. ln -sf gcc cc
  118. ln -sf gcc-${version} ${MACHTYPE}-gcc
  119. ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
  120. mv g++ g++-gcc-${version}
  121. ln -sf g++-gcc-${version} g++
  122. ln -sf g++ c++
  123. ln -sf g++-gcc-${version} ${MACHTYPE}-g++
  124. ln -sf g++-gcc-${version} ${MACHTYPE}-c++
  125. mv gfortran gfortran-${version}
  126. ln -sf gfortran-${version} gfortran
  127. ln -sf gfortran-${version} ${MACHTYPE}-gfortran
  128. # Extra symlinks for fortran
  129. ln -sf gfortran g77
  130. ln -sf g77 f77
  131. ln -sf gfortran g95
  132. ln -sf g95 f95
  133. mv gcc-ar gcc-ar-${version}
  134. ln -sf gcc-ar-${version} gcc-ar
  135. ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
  136. mv gcc-nm gcc-nm-${version}
  137. ln -sf gcc-nm-${version} gcc-nm
  138. ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
  139. mv gcc-ranlib gcc-ranlib-${version}
  140. ln -sf gcc-ranlib-${version} gcc-ranlib
  141. ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
  142. )
  143. (
  144. mkdir -p "${destdir}/lib" && \
  145. cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
  146. )
  147. # Compress info documents deleting index file for the package
  148. if test -d "${destdir}/$infodir"
  149. then
  150. rm -f "${destdir}/${infodir}/dir"
  151. lzip -9 "${destdir}/${infodir}"/* || true
  152. fi
  153. # Compress and link man pages (if needed)
  154. if test -d "${destdir}/$mandir"
  155. then
  156. (
  157. cd "${destdir}/$mandir"
  158. find . -type f -exec lzip -9 '{}' +
  159. find . -type l | while read -r file
  160. do
  161. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  162. rm -- "$file"
  163. done
  164. )
  165. fi
  166. # Copy documentation
  167. mkdir -p "${destdir}${docsdir}"
  168. cp -p $docs "${destdir}${docsdir}/"
  169. # Delete temporary build directory
  170. cd -- "$TMPDIR"
  171. if test -d ./gcc-build
  172. then
  173. rm -rf ./gcc-build
  174. fi
  175. }