05-gcc-final 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Build script for gcc.
  2. #
  3. # Copyright (c) 2016-2020 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. version=9.3.0
  17. # Prerequisites
  18. gmp_version=6.2.0
  19. mpfr_version=4.0.2
  20. mpc_version=1.1.0
  21. isl_version=0.22.1
  22. cd -- "$TMPDIR"
  23. rm -rf gcc-${version} gmp-${gmp_version} \
  24. mpfr-${mpfr_version} mpc-${mpc_version} isl-${isl_version}
  25. unpack "${worktree}/sources/gcc-${version}.tar.xz" \
  26. "${worktree}/sources/gmp-${gmp_version}.tar.lz" \
  27. "${worktree}/sources/mpfr-${mpfr_version}.tar.bz2" \
  28. "${worktree}/sources/mpc-${mpc_version}.tar.gz" \
  29. "${worktree}/sources/isl-${isl_version}.tar.bz2"
  30. # Build instructions
  31. cd gcc-${version}
  32. # Make symlinks for requisites
  33. ln -s ../gmp-${gmp_version} gmp
  34. ln -s ../mpfr-${mpfr_version} mpfr
  35. ln -s ../mpc-${mpc_version} mpc
  36. ln -s ../isl-${isl_version} isl
  37. # Apply patches for MPFR
  38. (
  39. cd mpfr || exit 1
  40. for file in "${worktree}"/patches/mpfr/*
  41. do
  42. if test -f "$file"
  43. then
  44. rm -f PATCHES
  45. patch -p1 < "$file"
  46. fi
  47. done
  48. )
  49. # Update detection for hosts based on musl
  50. cp -f "${worktree}/archive/common/config.guess" gmp/configfsf.guess
  51. cp -f "${worktree}/archive/common/config.sub" gmp/config.sub
  52. for directory in mpfr mpc isl
  53. do
  54. cp -f "${worktree}/archive/common/config.guess" ${directory}/config.guess
  55. cp -f "${worktree}/archive/common/config.sub" ${directory}/config.sub
  56. done
  57. unset directory
  58. # Apply specific patches for the support in musl.
  59. # http://port70.net/~nsz/musl/gcc-9.1.0/
  60. patch -Np1 -i "${worktree}/patches/gcc/230-musl_libssp.patch"
  61. patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
  62. patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
  63. patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
  64. patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
  65. patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
  66. patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
  67. patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
  68. patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
  69. patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
  70. patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
  71. patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
  72. patch -Np1 -i "${worktree}/patches/gcc/0013-invalid-tls-model.patch"
  73. # Build in a separate directory
  74. rm -rf ../gcc-build
  75. mkdir ../gcc-build
  76. cd ../gcc-build
  77. option_list="
  78. --prefix="$crossdir" \
  79. --libdir="${crossdir}/lib${libSuffix}" \
  80. --build=$host \
  81. --host=$host \
  82. --target=$target \
  83. --enable-languages=c,c++ \
  84. --enable-clocale=generic \
  85. --enable-tls \
  86. --enable-libstdcxx-time \
  87. --enable-checking=release \
  88. --enable-fully-dynamic-string \
  89. --enable-libssp \
  90. --disable-symvers \
  91. --disable-gnu-indirect-function \
  92. --disable-libmudflap \
  93. --disable-libsanitizer \
  94. --disable-libmpx \
  95. --disable-nls \
  96. --disable-lto-plugin \
  97. --with-sysroot="${crossdir}/$target" \
  98. $multilib_options \
  99. $gcc_options
  100. "
  101. if test -n "$IS_DARKCRUSADE"
  102. then
  103. ../gcc-${version}/configure CC="$BTCC" CXX="$BTCXX" AR="ar" \
  104. CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
  105. $option_list
  106. else
  107. ../gcc-${version}/configure AR="ar" \
  108. CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
  109. $option_list
  110. fi
  111. unset option_list IS_DARKCRUSADE
  112. make -j${jobs} all \
  113. AS_FOR_TARGET="${target}-as" \
  114. LD_FOR_TARGET="${target}-ld"
  115. make -j${jobs} install
  116. # Inset again libssp_nonshared.a overwritten the recent library
  117. ${target}-gcc \
  118. -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
  119. -o __stack_chk_fail_local.o
  120. ${target}-ar rc libssp_nonshared.a __stack_chk_fail_local.o
  121. ${target}-ranlib libssp_nonshared.a
  122. cp -f libssp_nonshared.a "${crossdir}/${target}/lib/"
  123. cd -- "$TMPDIR"
  124. cleanup()
  125. {
  126. rm -rf gcc-${version} gcc-build \
  127. gmp-${gmp_version} mpfr-${mpfr_version} \
  128. mpc-${mpc_version} isl-${isl_version}
  129. }