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 a category for the output of the package name
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 # Delete non-shared version of libssp (provided on the musl package)
132 rm -f "${destdir}/usr/lib${libSuffix}"/libssp_nonshared.a
134 # Strip ELF executables only excluding shared objects
135 find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
136 cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
138 # Strip static libraries in order to reduce the package size
139 find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
140 cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true
143 cd .. && cd "$srcdir"
145 # Move misplaced file(s) for GDB
146 mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
147 mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
148 "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
150 # Provide compatibility and make soft links for package size
152 cd "${destdir}/usr/bin" || exit 1
153 mv gcc gcc-${version}
154 ln -sf gcc-${version} gcc
156 ln -sf gcc-${version} ${MACHTYPE}-gcc
157 ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
159 mv g++ g++-gcc-${version}
160 ln -sf g++-gcc-${version} g++
162 ln -sf g++-gcc-${version} ${MACHTYPE}-g++
163 ln -sf g++-gcc-${version} ${MACHTYPE}-c++
165 mv gfortran gfortran-${version}
166 ln -sf gfortran-${version} gfortran
167 ln -sf gfortran-${version} ${MACHTYPE}-gfortran
168 # Extra symlinks for fortran
174 mv gcc-ar gcc-ar-${version}
175 ln -sf gcc-ar-${version} gcc-ar
176 ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
178 mv gcc-nm gcc-nm-${version}
179 ln -sf gcc-nm-${version} gcc-nm
180 ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
182 mv gcc-ranlib gcc-ranlib-${version}
183 ln -sf gcc-ranlib-${version} gcc-ranlib
184 ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
187 mkdir -p "${destdir}/lib" && \
188 cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
191 # Compress info documents deleting index file for the package
192 if test -d "${destdir}/$infodir"
194 rm -f "${destdir}/${infodir}/dir"
195 lzip -9 "${destdir}/${infodir}"/* || true
198 # Compress and link man pages (if needed)
199 if test -d "${destdir}/$mandir"
202 cd "${destdir}/$mandir"
203 find . -type f -exec lzip -9 '{}' +
204 find . -type l | while read -r file
206 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
213 mkdir -p "${destdir}${docsdir}"
214 cp -p $docs "${destdir}${docsdir}/"
216 # Delete temporary build directory
218 if test -d ./gcc-build