1 # Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
2 # Contributor: Allan McRae <allan@archlinux.org>
3 # Contributor: Daniel Kozak <kozzi11@gmail.com>
5 # toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc
6 # NOTE: libtool requires rebuilt with each new gcc version
8 pkgname=(gcc gcc-libs gcc-fortran gcc-objc gcc-ada gcc-go lib32-gcc-libs gcc-d)
10 _majorver=${pkgver%%.*}
13 pkgdesc='The GNU Compiler Collection'
15 license=(GPL LGPL FDL custom)
16 url='https://gcc.gnu.org'
17 makedepends=(binutils libmpc gcc-ada doxygen lib32-glibc lib32-gcc-libs python git libxcrypt)
18 checkdepends=(dejagnu inetutils)
20 _libdir=usr/lib/gcc/$CHOST/${pkgver%%+*}
21 # _commit=6beb39ee6c465c21d0cc547fd66b445100cdcc35
22 # source=(git://gcc.gnu.org/git/gcc.git#commit=$_commit
23 source=(https://sourceware.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.xz{,.sig}
24 http://isl.gforge.inria.fr/isl-${_islver}.tar.xz
28 ipa-fix-bit-CPP-when-combined-with-IPA-bit-CP.patch
29 ipa-fix-ICE-in-get_default_value.patch
31 gcc11-Wno-format-security.patch
33 validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
34 86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
35 13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
36 D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
37 sha256sums=('4c4a6fb8a8396059241c2e674b85b351c26a5d678274007f076957afa1cc9ddf'
39 '043105cc544f416b48736fff8caf077fb0663a717d06b1113f16e391ac99ebad'
40 'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
41 '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a'
42 'c86372c207d174c0918d4aedf1cb79f7fc093649eb1ad8d9450dccc46849d308'
43 '1ef190ed4562c4db8c1196952616cd201cfdd788b65f302ac2cc4dabb4d72cee'
44 'fcb11c9bcea320afd202b031b48f8750aeaedaa4b0c5dddcd2c0a16381e927e4'
45 '42865f2af3f48140580c4ae70b6ea03b5bdca0f29654773ef0d42ce00d60ea16'
46 '1773f5137f08ac1f48f0f7297e324d5d868d55201c03068670ee4602babdef2f'
47 '504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
50 [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
53 # link isl for in-tree build
54 ln -s ../isl-${_islver} isl
56 # Do not run fixincludes
57 sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
59 # Arch Linux installs x86_64 libraries /lib
60 sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
62 # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
63 sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
66 patch -p1 -i "$srcdir/gdc_phobos_path.patch"
68 # Reproducible gcc-ada
69 patch -Np0 < "$srcdir/gcc-ada-repro.patch"
71 # configure.ac: When adding -Wno-format, also add -Wno-format-security
72 patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
74 mkdir -p "$srcdir/gcc-build"
80 # using -pipe causes spurious test-suite failures
81 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
82 CFLAGS=${CFLAGS/-pipe/}
83 CXXFLAGS=${CXXFLAGS/-pipe/}
85 "$srcdir/gcc/configure" --prefix=/usr \
87 --libexecdir=/usr/lib \
88 --mandir=/usr/share/man \
89 --infodir=/usr/share/info \
90 --with-bugurl=https://bugs.archlinux.org/ \
91 --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d \
93 --with-linker-hash-style=gnu \
95 --enable-__cxa_atexit \
97 --enable-checking=release \
98 --enable-clocale=gnu \
99 --enable-default-pie \
100 --enable-default-ssp \
101 --enable-gnu-indirect-function \
102 --enable-gnu-unique-object \
103 --enable-install-libiberty \
104 --enable-linker-build-id \
109 --enable-threads=posix \
111 --disable-libstdcxx-pch \
112 --disable-libunwind-exceptions \
114 gdc_include_dir=/usr/include/dlang/gdc
119 make -C $CHOST/libstdc++-v3/doc doc-man-doxygen
125 # disable libphobos test to avoid segfaults and other unfunny ways to waste my time
126 sed -i '/maybe-check-target-libphobos \\/d' Makefile
128 # do not abort on error as some are "expected"
129 make -k check || true
130 "$srcdir/gcc/contrib/test_summary"
134 pkgdesc='Runtime libraries shipped by GCC'
135 depends=('glibc>=2.27')
137 provides=($pkgname-multilib libgo.so libgfortran.so libgphobos.so
138 libubsan.so libasan.so libtsan.so liblsan.so)
139 replaces=($pkgname-multilib libgphobos)
142 make -C $CHOST/libgcc DESTDIR="$pkgdir" install-shared
143 rm -f "$pkgdir/$_libdir/libgcc_eh.a"
145 for lib in libatomic \
151 libsanitizer/{a,l,ub,t}san \
154 make -C $CHOST/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
157 make -C $CHOST/libobjc DESTDIR="$pkgdir" install-libs
158 make -C $CHOST/libstdc++-v3/po DESTDIR="$pkgdir" install
160 make -C $CHOST/libphobos DESTDIR="$pkgdir" install
161 rm -rf "$pkgdir"/$_libdir/include/d/
162 rm -f "$pkgdir"/usr/lib/libgphobos.spec
167 make -C $CHOST/$lib DESTDIR="$pkgdir" install-info
170 # remove files provided by lib32-gcc-libs
171 rm -rf "$pkgdir"/usr/lib32/
173 # Install Runtime Library Exception
174 install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
175 "$pkgdir/usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
179 pkgdesc="The GNU Compiler Collection - C and C++ frontends"
180 depends=("gcc-libs=$pkgver-$pkgrel" 'binutils>=2.28' libmpc)
181 groups=('base-devel')
182 optdepends=('lib32-gcc-libs: for generating code for 32-bit ABI')
183 provides=($pkgname-multilib)
184 replaces=($pkgname-multilib)
185 options+=(staticlibs)
189 make -C gcc DESTDIR="$pkgdir" install-driver install-cpp install-gcc-ar \
190 c++.install-common install-headers install-plugin install-lto-wrapper
192 install -m755 -t "$pkgdir/usr/bin/" gcc/gcov{,-tool}
193 install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1}
195 make -C $CHOST/libgcc DESTDIR="$pkgdir" install
196 make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install
197 rm -f "$pkgdir"/usr/lib{,32}/libgcc_s.so*
199 make -C $CHOST/libstdc++-v3/src DESTDIR="$pkgdir" install
200 make -C $CHOST/libstdc++-v3/include DESTDIR="$pkgdir" install
201 make -C $CHOST/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
202 make -C $CHOST/libstdc++-v3/python DESTDIR="$pkgdir" install
203 make -C $CHOST/32/libstdc++-v3/src DESTDIR="$pkgdir" install
204 make -C $CHOST/32/libstdc++-v3/include DESTDIR="$pkgdir" install
205 make -C $CHOST/32/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
207 make DESTDIR="$pkgdir" install-libcc1
208 install -d "$pkgdir/usr/share/gdb/auto-load/usr/lib"
209 mv "$pkgdir"/usr/lib/libstdc++.so.6.*-gdb.py \
210 "$pkgdir/usr/share/gdb/auto-load/usr/lib/"
211 rm "$pkgdir"/usr/lib{,32}/libstdc++.so*
213 make DESTDIR="$pkgdir" install-fixincludes
214 make -C gcc DESTDIR="$pkgdir" install-mkheaders
216 make -C lto-plugin DESTDIR="$pkgdir" install
217 install -dm755 "$pkgdir"/usr/lib/bfd-plugins/
218 ln -s /${_libdir}/liblto_plugin.so \
219 "$pkgdir/usr/lib/bfd-plugins/"
221 make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_{libsubinclude,toolexeclib}HEADERS
222 make -C $CHOST/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
223 make -C $CHOST/libquadmath DESTDIR="$pkgdir" install-nodist_libsubincludeHEADERS
224 make -C $CHOST/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
225 make -C $CHOST/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
226 make -C $CHOST/libsanitizer/tsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
227 make -C $CHOST/libsanitizer/lsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
228 make -C $CHOST/32/libgomp DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
229 make -C $CHOST/32/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
230 make -C $CHOST/32/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
231 make -C $CHOST/32/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
233 make -C libiberty DESTDIR="$pkgdir" install
234 install -m644 libiberty/pic/libiberty.a "$pkgdir/usr/lib"
236 make -C gcc DESTDIR="$pkgdir" install-man install-info
237 rm "$pkgdir"/usr/share/man/man1/{gccgo,gfortran,gdc}.1
238 rm "$pkgdir"/usr/share/info/{gccgo,gfortran,gnat-style,gnat_rm,gnat_ugn,gdc}.info
240 make -C libcpp DESTDIR="$pkgdir" install
241 make -C gcc DESTDIR="$pkgdir" install-po
243 # many packages expect this symlink
244 ln -s gcc "$pkgdir"/usr/bin/cc
246 # POSIX conformance launcher scripts for c89 and c99
247 install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89"
248 install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99"
250 # install the libstdc++ man pages
251 make -C $CHOST/libstdc++-v3/doc DESTDIR="$pkgdir" doc-install-man
253 # remove files provided by lib32-gcc-libs
254 rm -f "$pkgdir"/usr/lib32/lib{stdc++,gcc_s}.so
256 # byte-compile python libraries
257 python -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
258 python -O -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
260 # Install Runtime Library Exception
261 install -d "$pkgdir/usr/share/licenses/$pkgname/"
262 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
263 "$pkgdir/usr/share/licenses/$pkgname/"
266 package_gcc-fortran() {
267 pkgdesc='Fortran front-end for GCC'
268 depends=("gcc=$pkgver-$pkgrel")
269 provides=($pkgname-multilib)
270 replaces=($pkgname-multilib)
273 make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
274 install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
275 make -C $CHOST/32/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
276 install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
277 make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
278 make -C gcc DESTDIR="$pkgdir" fortran.install-{common,man,info}
279 install -Dm755 gcc/f951 "$pkgdir/${_libdir}/f951"
281 ln -s gfortran "$pkgdir/usr/bin/f95"
283 # Install Runtime Library Exception
284 install -d "$pkgdir/usr/share/licenses/$pkgname/"
285 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
286 "$pkgdir/usr/share/licenses/$pkgname/"
290 pkgdesc='Objective-C front-end for GCC'
291 depends=("gcc=$pkgver-$pkgrel")
292 provides=($pkgname-multilib)
293 replaces=($pkgname-multilib)
296 make DESTDIR="$pkgdir" -C $CHOST/libobjc install-headers
297 install -dm755 "$pkgdir/${_libdir}"
298 install -m755 gcc/cc1obj{,plus} "$pkgdir/${_libdir}/"
300 # Install Runtime Library Exception
301 install -d "$pkgdir/usr/share/licenses/$pkgname/"
302 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
303 "$pkgdir/usr/share/licenses/$pkgname/"
307 pkgdesc='Ada front-end for GCC (GNAT)'
308 depends=("gcc=$pkgver-$pkgrel")
309 provides=($pkgname-multilib)
310 replaces=($pkgname-multilib)
311 options+=(staticlibs)
314 make DESTDIR="$pkgdir" ada.install-{common,info}
315 install -m755 gnat1 "$pkgdir/${_libdir}"
317 cd "$srcdir"/gcc-build/$CHOST/libada
318 make DESTDIR="${pkgdir}" INSTALL="install" \
319 INSTALL_DATA="install -m644" install-libada
321 cd "$srcdir"/gcc-build/$CHOST/32/libada
322 make DESTDIR="${pkgdir}" INSTALL="install" \
323 INSTALL_DATA="install -m644" install-libada
325 ln -s gcc "$pkgdir/usr/bin/gnatgcc"
327 # insist on dynamic linking, but keep static libraries because gnatmake complains
328 mv "$pkgdir"/${_libdir}/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib"
329 ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib/libgnarl.so"
330 ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib/libgnat.so"
331 rm -f "$pkgdir"/${_libdir}/adalib/libgna{rl,t}.so
333 install -d "$pkgdir/usr/lib32/"
334 mv "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib32"
335 ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib32/libgnarl.so"
336 ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib32/libgnat.so"
337 rm -f "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}.so
339 # Install Runtime Library Exception
340 install -d "$pkgdir/usr/share/licenses/$pkgname/"
341 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
342 "$pkgdir/usr/share/licenses/$pkgname/"
346 pkgdesc='Go front-end for GCC'
347 depends=("gcc=$pkgver-$pkgrel")
348 provides=("go=1.12.2" $pkgname-multilib)
349 replaces=($pkgname-multilib)
353 make -C $CHOST/libgo DESTDIR="$pkgdir" install-exec-am
354 make -C $CHOST/32/libgo DESTDIR="$pkgdir" install-exec-am
355 make DESTDIR="$pkgdir" install-gotools
356 make -C gcc DESTDIR="$pkgdir" go.install-{common,man,info}
358 rm -f "$pkgdir"/usr/lib{,32}/libgo.so*
359 install -Dm755 gcc/go1 "$pkgdir/${_libdir}/go1"
361 # Install Runtime Library Exception
362 install -d "$pkgdir/usr/share/licenses/$pkgname/"
363 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
364 "$pkgdir/usr/share/licenses/$pkgname/"
367 package_lib32-gcc-libs() {
368 pkgdesc='32-bit runtime libraries shipped by GCC'
369 depends=('lib32-glibc>=2.27')
370 provides=(libgo.so libgfortran.so libubsan.so libasan.so)
371 groups=(multilib-devel)
372 options=(!emptydirs !strip)
376 make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install-shared
377 rm -f "$pkgdir/$_libdir/32/libgcc_eh.a"
379 for lib in libatomic \
385 libsanitizer/{a,l,ub}san \
388 make -C $CHOST/32/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
391 make -C $CHOST/32/libobjc DESTDIR="$pkgdir" install-libs
393 make -C $CHOST/libphobos DESTDIR="$pkgdir" install
394 rm -f "$pkgdir"/usr/lib32/libgphobos.spec
396 # remove files provided by gcc-libs
397 rm -rf "$pkgdir"/usr/lib
399 # Install Runtime Library Exception
400 install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
401 "$pkgdir/usr/share/licenses/lib32-gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
405 pkgdesc="D frontend for GCC"
406 depends=("gcc=$pkgver-$pkgrel")
409 options=('staticlibs')
412 make -C gcc DESTDIR="$pkgdir" d.install-{common,man,info}
414 install -Dm755 gcc/gdc "$pkgdir"/usr/bin/gdc
415 install -Dm755 gcc/d21 "$pkgdir"/"$_libdir"/d21
417 make -C $CHOST/libphobos DESTDIR="$pkgdir" install
418 rm -f "$pkgdir/usr/lib/"lib{gphobos,gdruntime}.so*
419 rm -f "$pkgdir/usr/lib32/"lib{gphobos,gdruntime}.so*
421 install -d "$pkgdir"/usr/include/dlang
422 ln -s /"${_libdir}"/include/d "$pkgdir"/usr/include/dlang/gdc
424 # Install Runtime Library Exception
425 install -d "$pkgdir/usr/share/licenses/$pkgname/"
426 ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
427 "$pkgdir/usr/share/licenses/$pkgname/"