1 # Build recipe for GCC.
3 # Copyright (c) 2015-2019 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 \
85 CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
89 --libdir=/usr/lib${libSuffix} \
93 --enable-languages=c,c++,objc,obj-c++,fortran \
94 --enable-clocale=generic \
95 --enable-threads=posix \
99 --enable-libstdcxx-time \
100 --enable-checking=release \
101 --enable-fully-dynamic-string \
102 --enable-default-ssp \
103 --enable-default-pie \
107 --disable-gnu-indirect-function \
108 --disable-libstdcxx-pch \
109 --disable-libmudflap \
110 --disable-libsanitizer \
112 --disable-libcilkrts \
119 BOOT_LDFLAGS="$QILDFLAGS" \
120 BOOT_CFLAGS="$QICFLAGS" \
121 BOOT_CXXFLAGS="$QICXXFLAGS"
123 make -j${jobs} V=1 DESTDIR="$destdir" install
125 # Strip ELF executables only excluding shared objects
126 find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
127 cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
130 cd .. && cd "$srcdir"
132 # Provide minimal libssp_nonshared.a so we don't need libssp from GCC
134 cc $QICFLAGS -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
135 -o __stack_chk_fail_local.o
136 ar r libssp_nonshared.a __stack_chk_fail_local.o
138 cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
139 strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
141 # Move misplaced file(s) for GDB
142 mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
143 mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
144 "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
146 # Provide compatibility and make soft links for package size
148 cd "${destdir}/usr/bin" || exit 1
149 mv gcc gcc-${version}
150 ln -sf gcc-${version} gcc
152 ln -sf gcc-${version} ${MACHTYPE}-gcc
153 ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
155 mv g++ g++-gcc-${version}
156 ln -sf g++-gcc-${version} g++
158 ln -sf g++-gcc-${version} ${MACHTYPE}-g++
159 ln -sf g++-gcc-${version} ${MACHTYPE}-c++
161 mv gfortran gfortran-${version}
162 ln -sf gfortran-${version} gfortran
163 ln -sf gfortran-${version} ${MACHTYPE}-gfortran
164 # Extra symlinks for fortran
170 mv gcc-ar gcc-ar-${version}
171 ln -sf gcc-ar-${version} gcc-ar
172 ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
174 mv gcc-nm gcc-nm-${version}
175 ln -sf gcc-nm-${version} gcc-nm
176 ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
178 mv gcc-ranlib gcc-ranlib-${version}
179 ln -sf gcc-ranlib-${version} gcc-ranlib
180 ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
183 mkdir -p "${destdir}/lib" && \
184 cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
187 # Compress info documents deleting index file for the package
188 if test -d "${destdir}/$infodir"
190 rm -f "${destdir}/${infodir}/dir"
191 lzip -9 "${destdir}/${infodir}"/* || true
194 # Compress and link man pages (if needed)
195 if test -d "${destdir}/$mandir"
198 cd "${destdir}/$mandir"
199 find . -type f -exec lzip -9 '{}' +
200 find . -type l | while read -r file
202 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
209 mkdir -p "${destdir}${docsdir}"
210 cp -p $docs "${destdir}${docsdir}/"
212 # Delete temporary build directory
214 if test -d ./gcc-build