03-gcc-static 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Build script for gcc.
  2. #
  3. # Copyright (c) 2016-2022 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=11-20220429
  17. # Prerequisites
  18. gmp_version=6.2.1
  19. mpfr_version=4.1.0
  20. mpc_version=1.2.1
  21. isl_version=0.24
  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. cp -f "${worktree}/archive/common/config.guess" isl/config.guess
  53. cp -f "${worktree}/archive/common/config.sub" isl/config.sub
  54. # Apply specific patches for the support in musl.
  55. # https://port70.net/~nsz/musl/gcc-11.1.0/
  56. patch -Np1 -i "${worktree}/patches/gcc/11/0002-posix_memalign.patch"
  57. patch -Np1 -i "${worktree}/patches/gcc/11/0003-j2.patch"
  58. patch -Np1 -i "${worktree}/patches/gcc/11/0004-static-pie.patch"
  59. patch -Np1 -i "${worktree}/patches/gcc/11/0005-m68k-sqrt.patch"
  60. patch -Np1 -i "${worktree}/patches/gcc/11/extra-musl_libssp.patch"
  61. patch -Np1 -i "${worktree}/patches/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch"
  62. # Build in a separate directory
  63. rm -rf ../gcc-build
  64. mkdir ../gcc-build
  65. cd ../gcc-build
  66. ../gcc-${version}/configure \
  67. AR="ar" CC="$BTCC" CXX="$BTCXX" \
  68. CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
  69. --prefix="$crossdir" \
  70. --libdir="${crossdir}/lib${libSuffix}" \
  71. --build=$host \
  72. --host=$host \
  73. --target=$target \
  74. --enable-languages=c \
  75. --enable-clocale=generic \
  76. --enable-initfini-array \
  77. --disable-shared \
  78. --disable-threads \
  79. --disable-decimal-float \
  80. --disable-libgomp \
  81. --disable-libssp \
  82. --disable-libatomic \
  83. --disable-libitm \
  84. --disable-libquadmath \
  85. --disable-libvtv \
  86. --disable-libcilkrts \
  87. --disable-libstdcxx \
  88. --disable-gnu-indirect-function \
  89. --disable-libsanitizer \
  90. --disable-libmpx \
  91. --disable-nls \
  92. --with-sysroot="${crossdir}/$target" \
  93. --with-newlib \
  94. --without-headers \
  95. --without-ppl \
  96. --without-cloog \
  97. $multilib_options \
  98. $gcc_options
  99. make -j${jobs} all-gcc all-target-libgcc
  100. make -j${jobs} install-gcc install-target-libgcc
  101. cd ..
  102. cleanup()
  103. {
  104. cd -- "$TMPDIR" && rm -rf gcc-${version} gcc-build \
  105. gmp-${gmp_version} mpfr-${mpfr_version} \
  106. mpc-${mpc_version} isl-${isl_version}
  107. }