1 # Build script for gcc.
3 # Copyright (c) 2016-2022 Matias Fonzo, <selk@dragora.org>.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
27 rm -rf gcc-${version} gmp-${gmp_version} \
28 mpfr-${mpfr_version} mpc-${mpc_version} isl-${isl_version}
29 unpack "${worktree}/sources/gcc-${version}.tar.xz" \
30 "${worktree}/sources/gmp-${gmp_version}.tar.lz" \
31 "${worktree}/sources/mpfr-${mpfr_version}.tar.bz2" \
32 "${worktree}/sources/mpc-${mpc_version}.tar.gz" \
33 "${worktree}/sources/isl-${isl_version}.tar.bz2"
38 # Make symlinks for requisites
39 ln -s ../gmp-${gmp_version} gmp
40 ln -s ../mpfr-${mpfr_version} mpfr
41 ln -s ../mpc-${mpc_version} mpc
42 ln -s ../isl-${isl_version} isl
44 # Apply patches for MPFR
48 for file in "${worktree}"/patches/mpfr/*
58 # Update detection for hosts based on musl
60 cp -f "${worktree}/archive/common/config.guess" gmp/configfsf.guess
61 cp -f "${worktree}/archive/common/config.sub" gmp/config.sub
63 cp -f "${worktree}/archive/common/config.guess" isl/config.guess
64 cp -f "${worktree}/archive/common/config.sub" isl/config.sub
66 # Apply specific patches for the support in musl.
67 # https://port70.net/~nsz/musl/gcc-11.1.0/
69 patch -Np1 -i "${worktree}/patches/gcc/11/0002-posix_memalign.patch"
70 patch -Np1 -i "${worktree}/patches/gcc/11/0003-j2.patch"
71 patch -Np1 -i "${worktree}/patches/gcc/11/0004-static-pie.patch"
72 patch -Np1 -i "${worktree}/patches/gcc/11/0005-m68k-sqrt.patch"
73 patch -Np1 -i "${worktree}/patches/gcc/11/extra-musl_libssp.patch"
75 patch -Np1 -i "${worktree}/patches/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch"
77 # Build in a separate directory
83 --prefix="$crossdir" \
84 --libdir="${crossdir}/lib${libSuffix}" \
88 --enable-languages=c,c++ \
89 --enable-clocale=generic \
90 --enable-initfini-array \
92 --enable-libstdcxx-time \
93 --enable-checking=release \
94 --enable-fully-dynamic-string \
97 --disable-gnu-indirect-function \
98 --disable-libsanitizer \
101 --with-sysroot="${crossdir}/$target" \
106 if test -n "$IS_DARKCRUSADE"
108 ../gcc-${version}/configure CC="$BTCC" CXX="$BTCXX" AR="ar" \
109 CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
112 ../gcc-${version}/configure AR="ar" \
113 CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
117 unset option_list IS_DARKCRUSADE
120 AS_FOR_TARGET="${target}-as" \
121 LD_FOR_TARGET="${target}-ld"
123 make -j${jobs} install
125 # Insert again libssp_nonshared.a overwritten the recent library
127 -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
128 -o __stack_chk_fail_local.o
130 ${target}-ar rc libssp_nonshared.a __stack_chk_fail_local.o
131 ${target}-ranlib libssp_nonshared.a
132 cp -f libssp_nonshared.a "${crossdir}/${target}/lib/"
138 rm -rf gcc-${version} gcc-build \
139 gmp-${gmp_version} mpfr-${mpfr_version} \
140 mpc-${mpc_version} isl-${isl_version}