More updates...
[dragora.git] / stages / 0 / 05-gcc-final
bloba9c9e41bc390e1b75207f999d1be8a379c043029
1 # Build script for gcc.
3 # Copyright (c) 2016-2020 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.
17 version=9.3.0
19 # Prerequisites
20 gmp_version=6.2.0
21 mpfr_version=4.0.2
22 mpc_version=1.1.0
23 isl_version=0.22.1
25 cd -- "$TMPDIR"
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.gz" \
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" 
35 # Build instructions
36 cd gcc-${version}
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
46     cd mpfr || exit 1
48     for file in "${worktree}"/patches/mpfr/*
49     do
50         if test -f "$file"
51         then
52             rm -f PATCHES
53             patch -p1 < "$file"
54         fi
55     done
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 for directory in mpfr mpc isl
65     cp -f "${worktree}/archive/common/config.guess" ${directory}/config.guess
66     cp -f "${worktree}/archive/common/config.sub" ${directory}/config.sub
67 done
68 unset directory
70 # Apply specific patches for the support in musl.
71 # http://port70.net/~nsz/musl/gcc-9.1.0/
73 patch -Np1 -i "${worktree}/patches/gcc/230-musl_libssp.patch"
74 patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
75 patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
76 patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
77 patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
78 patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
79 patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
80 patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
81 patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
82 patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
83 patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
84 patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
85 patch -Np1 -i "${worktree}/patches/gcc/0013-invalid-tls-model.patch"
87 # Build in a separate directory
88 rm -rf ../gcc-build
89 mkdir ../gcc-build
90 cd ../gcc-build
92 option_list="
93  --prefix="$crossdir" \
94  --libdir="${crossdir}/lib${libSuffix}" \
95  --build=$host \
96  --host=$host \
97  --target=$target \
98  --enable-languages=c,c++ \
99  --enable-clocale=generic \
100  --enable-tls \
101  --enable-libstdcxx-time \
102  --enable-checking=release \
103  --enable-fully-dynamic-string \
104  --enable-libssp \
105  --disable-symvers \
106  --disable-gnu-indirect-function \
107  --disable-libmudflap \
108  --disable-libsanitizer \
109  --disable-libmpx \
110  --disable-nls \
111  --disable-lto-plugin \
112  --with-sysroot="${crossdir}/$target" \
113  $multilib_options \
114  $gcc_options
117 if test -n "$IS_DARKCRUSADE"
118 then
119     ../gcc-${version}/configure CC="$BTCC" CXX="$BTCXX" AR="ar" \
120     CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
121     $option_list
122 else
123     ../gcc-${version}/configure AR="ar" \
124     CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
125     $option_list
128 unset option_list IS_DARKCRUSADE
130 make -j${jobs} all \
131  AS_FOR_TARGET="${target}-as" \
132  LD_FOR_TARGET="${target}-ld"
134 make -j${jobs} install
136 # Insert again libssp_nonshared.a overwritten the recent library
137 ${target}-gcc \
138  -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
139  -o __stack_chk_fail_local.o
141 ${target}-ar rc libssp_nonshared.a __stack_chk_fail_local.o
142 ${target}-ranlib libssp_nonshared.a
143 cp -f libssp_nonshared.a "${crossdir}/${target}/lib/"
145 cd -- "$TMPDIR"
147 cleanup()
149     rm -rf gcc-${version} gcc-build \
150      gmp-${gmp_version} mpfr-${mpfr_version} \
151      mpc-${mpc_version} isl-${isl_version}