stages: 2/04-iso: Do not include kernel build/source tree in the LiveCD
[dragora.git] / stages / 0 / 03-gcc-static
blob4c2081c0a8d7e43143f23d2649d9fe709112fae7
1 # Build script for gcc.
3 # Copyright (c) 2016-2023 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=11-20230310
19 # Prerequisites
20 gmp_version=6.2.1
21 mpfr_version=4.2.0
22 mpc_version=1.3.1
23 isl_version=0.24
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.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"
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 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
78 rm -rf ../gcc-build
79 mkdir ../gcc-build
80 cd ../gcc-build
82 ../gcc-${version}/configure \
83 AR="ar" CC="$BTCC" CXX="$BTCXX" \
84 CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
85  --prefix="$crossdir" \
86  --libdir="${crossdir}/lib${libSuffix}" \
87  --build=$host \
88  --host=$host \
89  --target=$target \
90  --enable-languages=c \
91  --enable-clocale=generic \
92  --enable-initfini-array \
93  --disable-shared \
94  --disable-threads \
95  --disable-decimal-float \
96  --disable-libgomp \
97  --disable-libssp \
98  --disable-libatomic \
99  --disable-libitm \
100  --disable-libquadmath \
101  --disable-libvtv \
102  --disable-libcilkrts \
103  --disable-libstdcxx \
104  --disable-gnu-indirect-function \
105  --disable-libsanitizer \
106  --disable-libmpx \
107  --disable-nls \
108  --with-sysroot="${crossdir}/$target" \
109  --with-newlib \
110  --without-headers \
111  --without-ppl \
112  --without-cloog \
113  $multilib_options \
114  $gcc_options
116 make -j${jobs} MAKEINFO="true" all-gcc all-target-libgcc
117 make -j${jobs} MAKEINFO="true" install-gcc install-target-libgcc
119 cd ..
121 cleanup()
123     cd -- "$TMPDIR" && rm -rf gcc-${version} gcc-build \
124      gmp-${gmp_version} mpfr-${mpfr_version} \
125      mpc-${mpc_version} isl-${isl_version}