1 # Build recipe for GCC.
3 # Copyright (c) 2015-2018 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 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/devel"
24 tarname=${program}-${version}.tar.xz
27 #fetch=http://gnu.c3sl.ufpr.br/ftp/gcc/gcc-${version}/$tarname
28 fetch=ftp://gcc.gnu.org/pub/gcc/snapshots/${version}/$tarname
30 homepage=http://www.gnu.org/software/gcc
31 license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"
34 The GNU C Compiler Collection.
36 The GNU Compiler Collection (GCC) is a compiler system produced by the
37 GNU Project supporting various programming languages. GCC is a key
38 component of the GNU toolchain. The Free Software Foundation (FSF)
39 distributes GCC under the GNU General Public License (GNU GPL).
41 For more information about GCC, visit: $homepage
44 # Source documentation
45 docs="COPYING* README"
46 docsdir="${docdir}/${program}-${version}"
49 MACHTYPE="$(cc -dumpmachine)"
55 unpack "${tardir}/$tarname"
59 # Set sane permissions
60 chmod -R u+w,go-w,a+rX-s .
62 # Apply specific patches for the support in musl.
63 # http://port70.net/~nsz/musl/gcc-8.2.0
65 #patch -Np1 -i "${worktree}/patches/gcc/0001-ssp_nonshared.patch"
66 patch -Np1 -i "${worktree}/patches/gcc/musl-libssp.diff"
67 patch -Np1 -i "${worktree}/patches/gcc/0002-posix_memalign.patch"
68 patch -Np1 -i "${worktree}/patches/gcc/0003-libatomic-test-fix.patch"
69 patch -Np1 -i "${worktree}/patches/gcc/0004-libgomp-test-fix.patch"
70 patch -Np1 -i "${worktree}/patches/gcc/0005-libitm-test-fix.patch"
71 patch -Np1 -i "${worktree}/patches/gcc/0006-libvtv-test-fix.patch"
72 patch -Np1 -i "${worktree}/patches/gcc/0007-j2.patch"
73 patch -Np1 -i "${worktree}/patches/gcc/0008-s390x-muslldso.patch"
74 patch -Np1 -i "${worktree}/patches/gcc/0009-microblaze-pr65649.patch"
75 patch -Np1 -i "${worktree}/patches/gcc/0010-ldbl128-config.patch"
76 patch -Np1 -i "${worktree}/patches/gcc/0011-m68k.patch"
77 patch -Np1 -i "${worktree}/patches/gcc/0012-static-pie.patch"
79 # Create a separate build directory
84 ../${program}-${version}/configure SED=sed \
88 --libdir=/usr/lib${libSuffix} \
92 --enable-languages=c,c++,objc,obj-c++,fortran \
93 --enable-clocale=generic \
94 --enable-threads=posix \
98 --enable-libstdcxx-time \
99 --enable-checking=release \
100 --enable-fully-dynamic-string \
101 --enable-default-ssp \
102 --enable-default-pie \
106 --disable-gnu-indirect-function \
107 --disable-libstdcxx-pch \
108 --disable-libmudflap \
109 --disable-libsanitizer \
111 --disable-libcilkrts \
118 make -j${jobs} V=1 DESTDIR="$destdir" install-strip
121 cd .. && cd "$srcdir"
123 # Provide minimal libssp_nonshared.a so we don't need libssp from GCC
125 cc $QICFLAGS -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
126 -o __stack_chk_fail_local.o
127 ar r libssp_nonshared.a __stack_chk_fail_local.o
129 cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
130 strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
132 # Move misplaced file(s) for GDB
133 mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
134 mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
135 "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
137 # Provide compatibility and make soft links for package size
139 cd "${destdir}/usr/bin" || exit 1
140 mv gcc gcc-${version}
141 ln -sf gcc-${version} gcc
143 ln -sf gcc-${version} ${MACHTYPE}-gcc
144 ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
146 mv g++ g++-gcc-${version}
147 ln -sf g++-gcc-${version} g++
149 ln -sf g++-gcc-${version} ${MACHTYPE}-g++
150 ln -sf g++-gcc-${version} ${MACHTYPE}-c++
152 mv gfortran gfortran-${version}
153 ln -sf gfortran-${version} gfortran
154 ln -sf gfortran-${version} ${MACHTYPE}-gfortran
155 # Extra symlinks for fortran
161 mv gcc-ar gcc-ar-${version}
162 ln -sf gcc-ar-${version} gcc-ar
163 ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
165 mv gcc-nm gcc-nm-${version}
166 ln -sf gcc-nm-${version} gcc-nm
167 ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
169 mv gcc-ranlib gcc-ranlib-${version}
170 ln -sf gcc-ranlib-${version} gcc-ranlib
171 ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
174 mkdir -p "${destdir}/lib" && \
175 cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
178 # Compress info documents deleting index file for the package
179 if test -d "${destdir}/$infodir"
181 rm -f "${destdir}/${infodir}/dir"
182 lzip -9 "${destdir}/${infodir}"/* || true
185 # Compress and link man pages (if needed)
186 if test -d "${destdir}/$mandir"
189 cd "${destdir}/$mandir"
190 find . -type f -exec lzip -9 '{}' +
191 find . -type l | while read -r file
193 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
200 mkdir -p "${destdir}${docsdir}"
201 cp -p $docs "${destdir}${docsdir}/"
203 # Delete temporary build directory
205 if test -d ./gcc-build