1 # Build recipe for GCC.
3 # Copyright (c) 2015-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.
21 # Define hash tag to categorize the package name output
24 tarname=${program}-${version}.tar.gz
27 fetch=http://www.netgull.com/gcc/releases/gcc-${version}/$tarname
29 # http://www.netgull.com/gcc/snapshots/${version}/$tarname
30 # http://gnu.c3sl.ufpr.br/ftp/gcc/gcc-${version}/$tarname
31 # ftp://gcc.gnu.org/pub/gcc/snapshots/${version}/$tarname
34 homepage=http://www.gnu.org/software/gcc
35 license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"
38 The GNU C Compiler Collection.
40 The GNU Compiler Collection (GCC) is a compiler system produced by the
41 GNU Project supporting various programming languages. GCC is a key
42 component of the GNU toolchain. The Free Software Foundation (FSF)
43 distributes GCC under the GNU General Public License (GNU GPL).
45 For more information about GCC, visit: $homepage
48 # Source documentation
49 docs="COPYING* README"
50 docsdir="${docdir}/${program}-${version}"
53 MACHTYPE="$(cc -dumpmachine)"
59 unpack "${tardir}/$tarname"
63 # Set sane permissions
64 chmod -R u+w,go-w,a+rX-s .
66 # Apply specific patches for the support in musl.
67 # http://port70.net/~nsz/musl/gcc-9.1.0/
69 patch -Np1 -i "${worktree}/patches/gcc/230-musl_libssp.patch"
70 patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
71 patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
72 patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
73 patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
74 patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
75 patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
76 patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
77 patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
78 patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
79 patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
80 patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
81 patch -Np1 -i "${worktree}/patches/gcc/0013-invalid-tls-model.patch"
82 patch -Np1 -i "${worktree}/patches/gcc/turn-on-relro-bydefault.patch"
84 # Create a separate build directory
89 ../${program}-${version}/configure SED=sed \
90 CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
92 --libdir=/usr/lib${libSuffix} \
96 --enable-languages=c,c++,fortran,objc,obj-c++ \
97 --enable-clocale=generic \
98 --enable-threads=posix \
104 --enable-libstdcxx-time \
105 --enable-checking=release \
106 --enable-fully-dynamic-string \
107 --enable-default-ssp \
108 --enable-default-pie \
112 --disable-gnu-indirect-function \
113 --disable-libstdcxx-pch \
114 --disable-libmudflap \
115 --disable-libsanitizer \
116 --disable-libcilkrts \
125 BOOT_LDFLAGS="$QILDFLAGS" \
126 BOOT_CFLAGS="$QICFLAGS" \
127 BOOT_CXXFLAGS="$QICXXFLAGS"
129 make -j${jobs} V=1 DESTDIR="$destdir" install
131 # Strip ELF executables only excluding shared objects
132 find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
133 cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
135 # Strip static libraries in order to reduce the package size
136 find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
137 cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true
140 cd .. && cd "$srcdir"
142 # Move misplaced file(s) for GDB
143 mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
144 mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
145 "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
147 # Provide compatibility and make soft links for package size
149 cd "${destdir}/usr/bin" || exit 1
150 mv gcc gcc-${version}
151 ln -sf gcc-${version} gcc
153 ln -sf gcc-${version} ${MACHTYPE}-gcc
154 ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
156 mv g++ g++-gcc-${version}
157 ln -sf g++-gcc-${version} g++
159 ln -sf g++-gcc-${version} ${MACHTYPE}-g++
160 ln -sf g++-gcc-${version} ${MACHTYPE}-c++
162 mv gfortran gfortran-${version}
163 ln -sf gfortran-${version} gfortran
164 ln -sf gfortran-${version} ${MACHTYPE}-gfortran
165 # Extra symlinks for fortran
171 mv gcc-ar gcc-ar-${version}
172 ln -sf gcc-ar-${version} gcc-ar
173 ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
175 mv gcc-nm gcc-nm-${version}
176 ln -sf gcc-nm-${version} gcc-nm
177 ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
179 mv gcc-ranlib gcc-ranlib-${version}
180 ln -sf gcc-ranlib-${version} gcc-ranlib
181 ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
184 mkdir -p "${destdir}/lib" && \
185 cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
188 # Compress info documents deleting index file for the package
189 if test -d "${destdir}/$infodir"
191 rm -f "${destdir}/${infodir}/dir"
192 lzip -9 "${destdir}/${infodir}"/* || true
195 # Compress and link man pages (if needed)
196 if test -d "${destdir}/$mandir"
199 cd "${destdir}/$mandir"
200 find . -type f -exec lzip -9 '{}' +
201 find . -type l | while read -r file
203 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
210 mkdir -p "${destdir}${docsdir}"
211 cp -p $docs "${destdir}${docsdir}/"
213 # Delete temporary build directory
215 if test -d ./gcc-build