archrelease: copy trunk to extra-x86_64
[arch-packages.git] / gcc / trunk / PKGBUILD
blobd3eed5d976e459b708c121563401d63025cbab4d
1 # Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
2 # Maintainer: Frederik Schwan <freswa at archlinux dot org>
3 # Contributor:  BartÅ‚omiej Piotrowski <bpiotrowski@archlinux.org>
4 # Contributor: Allan McRae <allan@archlinux.org>
5 # Contributor: Daniel Kozak <kozzi11@gmail.com>
7 # toolchain build order: linux-api-headers->glibc->binutils->gcc->glibc->binutils->gcc
8 # NOTE: libtool requires rebuilt with each new gcc version
10 pkgname=(gcc gcc-libs lib32-gcc-libs gcc-fortran gcc-objc gcc-ada gcc-go gcc-d libgccjit)
11 pkgver=11.2.0
12 _majorver=${pkgver%%.*}
13 _islver=0.24
14 pkgrel=4
15 pkgdesc='The GNU Compiler Collection'
16 arch=(x86_64)
17 license=(GPL3 LGPL FDL custom)
18 url='https://gcc.gnu.org'
19 makedepends=(
20   binutils
21   doxygen
22   gcc-ada
23   git
24   lib32-glibc
25   lib32-gcc-libs
26   libisl
27   libmpc
28   libxcrypt
29   python
30   zstd
32 checkdepends=(
33   dejagnu
34   expect
35   inetutils
36   python-pytest
37   tcl
39 options=(!emptydirs !lto debug)
40 _libdir=usr/lib/gcc/$CHOST/${pkgver%%+*}
41 # _commit=6beb39ee6c465c21d0cc547fd66b445100cdcc35
42 # source=(git://gcc.gnu.org/git/gcc.git#commit=$_commit
43 source=(https://sourceware.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.xz{,.sig}
44         c89 c99
45         gdc_phobos_path.patch
46         gcc-ada-repro.patch
48 validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9  # bpiotrowski@archlinux.org
49               86CFFCA918CF3AF47147588051E8B148A9999C34  # evangelos@foutrelis.com
50               13975A70E63C361C73AE69EF6EEB81F8981C74C7  # richard.guenther@gmail.com
51               D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
52 sha256sums=('d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b'
53             'SKIP'
54             'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
55             '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a'
56             'c86372c207d174c0918d4aedf1cb79f7fc093649eb1ad8d9450dccc46849d308'
57             '1773f5137f08ac1f48f0f7297e324d5d868d55201c03068670ee4602babdef2f')
59 prepare() {
60   [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
61   cd gcc
63   # Do not run fixincludes
64   sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
66   # Arch Linux installs x86_64 libraries /lib
67   sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
69   # D hacks
70   patch -Np1 -i "$srcdir/gdc_phobos_path.patch"
72   # Reproducible gcc-ada
73   patch -Np0 < "$srcdir/gcc-ada-repro.patch"
75   mkdir -p "$srcdir/gcc-build"
76   mkdir -p "$srcdir/libgccjit-build"
79 build() {
80   local _confflags="--prefix=/usr \
81       --libdir=/usr/lib \
82       --libexecdir=/usr/lib \
83       --mandir=/usr/share/man \
84       --infodir=/usr/share/info \
85       --with-bugurl=https://bugs.archlinux.org/ \
86       --with-linker-hash-style=gnu \
87       --with-system-zlib \
88       --enable-__cxa_atexit \
89       --enable-cet=auto \
90       --enable-checking=release \
91       --enable-clocale=gnu \
92       --enable-default-pie \
93       --enable-default-ssp \
94       --enable-gnu-indirect-function \
95       --enable-gnu-unique-object \
96       --enable-linker-build-id \
97       --enable-lto \
98       --enable-multilib \
99       --enable-plugin \
100       --enable-shared \
101       --enable-threads=posix \
102       --disable-libssp \
103       --disable-libstdcxx-pch \
104       --disable-werror \
105       --with-build-config=bootstrap-lto \
106       --enable-link-serialization=1 \
107       gdc_include_dir=/usr/include/dlang/gdc"
109   cd gcc-build
111   # Credits @allanmcrae
112   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
113   # TODO: properly deal with the build issues resulting from this
114   CFLAGS=${CFLAGS/-Werror=format-security/}
115   CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
117   "$srcdir/gcc/configure" \
118     --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d \
119     --enable-bootstrap \
120     $_confflags
122   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
123   make -O STAGE1_CFLAGS="-O2" \
124           BOOT_CFLAGS="$CFLAGS" \
125           BOOT_LDFLAGS="$LDFLAGS" \
126           LDFLAGS_FOR_TARGET="$LDFLAGS" \
127           bootstrap
129   # make documentation
130   make -O -C $CHOST/libstdc++-v3/doc doc-man-doxygen
132   # Build libgccjit separately, to avoid building all compilers with --enable-host-shared
133   # which brings a performance penalty
134   cd "${srcdir}"/libgccjit-build
136   "$srcdir/gcc/configure" \
137     --enable-languages=jit \
138     --disable-bootstrap \
139     --enable-host-shared \
140     $_confflags
142   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
143   make -O STAGE1_CFLAGS="-O2" \
144           BOOT_CFLAGS="$CFLAGS" \
145           BOOT_LDFLAGS="$LDFLAGS" \
146           LDFLAGS_FOR_TARGET="$LDFLAGS" \
147           all-gcc
149   cp -a gcc/libgccjit.so* ../gcc-build/gcc/
152 check() {
153   cd gcc-build
155   # disable libphobos test to avoid segfaults and other unfunny ways to waste my time
156   sed -i '/maybe-check-target-libphobos \\/d' Makefile
158   # do not abort on error as some are "expected"
159   make -O -k check || true
160   "$srcdir/gcc/contrib/test_summary"
163 package_gcc-libs() {
164   pkgdesc='Runtime libraries shipped by GCC'
165   depends=('glibc>=2.27')
166   options=(!emptydirs !strip)
167   provides=($pkgname-multilib libgo.so libgfortran.so libgphobos.so
168             libubsan.so libasan.so libtsan.so liblsan.so)
169   replaces=($pkgname-multilib libgphobos)
171   cd gcc-build
172   make -C $CHOST/libgcc DESTDIR="$pkgdir" install-shared
173   rm -f "$pkgdir/$_libdir/libgcc_eh.a"
175   for lib in libatomic \
176              libgfortran \
177              libgo \
178              libgomp \
179              libitm \
180              libquadmath \
181              libsanitizer/{a,l,ub,t}san \
182              libstdc++-v3/src \
183              libvtv; do
184     make -C $CHOST/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
185   done
187   make -C $CHOST/libobjc DESTDIR="$pkgdir" install-libs
188   make -C $CHOST/libstdc++-v3/po DESTDIR="$pkgdir" install
190   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
191   rm -rf "$pkgdir"/$_libdir/include/d/
192   rm -f "$pkgdir"/usr/lib/libgphobos.spec
194   for lib in libgomp \
195              libitm \
196              libquadmath; do
197     make -C $CHOST/$lib DESTDIR="$pkgdir" install-info
198   done
200   # remove files provided by lib32-gcc-libs
201   rm -rf "$pkgdir"/usr/lib32/
203   # Install Runtime Library Exception
204   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
205     "$pkgdir/usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
208 package_gcc() {
209   pkgdesc="The GNU Compiler Collection - C and C++ frontends"
210   depends=("gcc-libs=$pkgver-$pkgrel" 'binutils>=2.28' libmpc zstd libisl.so)
211   groups=('base-devel')
212   optdepends=('lib32-gcc-libs: for generating code for 32-bit ABI')
213   provides=($pkgname-multilib)
214   replaces=($pkgname-multilib)
215   options=(!emptydirs staticlibs debug)
217   cd gcc-build
219   make -C gcc DESTDIR="$pkgdir" install-driver install-cpp install-gcc-ar \
220     c++.install-common install-headers install-plugin install-lto-wrapper
222   install -m755 -t "$pkgdir/usr/bin/" gcc/gcov{,-tool}
223   install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1}
225   make -C $CHOST/libgcc DESTDIR="$pkgdir" install
226   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install
227   rm -f "$pkgdir"/usr/lib{,32}/libgcc_s.so*
229   make -C $CHOST/libstdc++-v3/src DESTDIR="$pkgdir" install
230   make -C $CHOST/libstdc++-v3/include DESTDIR="$pkgdir" install
231   make -C $CHOST/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
232   make -C $CHOST/libstdc++-v3/python DESTDIR="$pkgdir" install
233   make -C $CHOST/32/libstdc++-v3/src DESTDIR="$pkgdir" install
234   make -C $CHOST/32/libstdc++-v3/include DESTDIR="$pkgdir" install
235   make -C $CHOST/32/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
237   make DESTDIR="$pkgdir" install-libcc1
238   install -d "$pkgdir/usr/share/gdb/auto-load/usr/lib"
239   mv "$pkgdir"/usr/lib/libstdc++.so.6.*-gdb.py \
240     "$pkgdir/usr/share/gdb/auto-load/usr/lib/"
241   rm "$pkgdir"/usr/lib{,32}/libstdc++.so*
243   make DESTDIR="$pkgdir" install-fixincludes
244   make -C gcc DESTDIR="$pkgdir" install-mkheaders
246   make -C lto-plugin DESTDIR="$pkgdir" install
247   install -dm755 "$pkgdir"/usr/lib/bfd-plugins/
248   ln -s /${_libdir}/liblto_plugin.so \
249     "$pkgdir/usr/lib/bfd-plugins/"
251   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_{libsubinclude,toolexeclib}HEADERS
252   make -C $CHOST/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
253   make -C $CHOST/libquadmath DESTDIR="$pkgdir" install-nodist_libsubincludeHEADERS
254   make -C $CHOST/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
255   make -C $CHOST/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
256   make -C $CHOST/libsanitizer/tsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
257   make -C $CHOST/libsanitizer/lsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
258   make -C $CHOST/32/libgomp DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
259   make -C $CHOST/32/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
260   make -C $CHOST/32/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
261   make -C $CHOST/32/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
263   make -C gcc DESTDIR="$pkgdir" install-man install-info
264   rm "$pkgdir"/usr/share/man/man1/{gccgo,gfortran,gdc}.1
265   rm "$pkgdir"/usr/share/info/{gccgo,gfortran,gnat-style,gnat_rm,gnat_ugn,gdc}.info
267   make -C libcpp DESTDIR="$pkgdir" install
268   make -C gcc DESTDIR="$pkgdir" install-po
270   # many packages expect this symlink
271   ln -s gcc "$pkgdir"/usr/bin/cc
273   # POSIX conformance launcher scripts for c89 and c99
274   install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89"
275   install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99"
277   # install the libstdc++ man pages
278   make -C $CHOST/libstdc++-v3/doc DESTDIR="$pkgdir" doc-install-man
280   # remove files provided by lib32-gcc-libs
281   rm -f "$pkgdir"/usr/lib32/lib{stdc++,gcc_s}.so
283   # byte-compile python libraries
284   python -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
285   python -O -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
287   # Install Runtime Library Exception
288   install -d "$pkgdir/usr/share/licenses/$pkgname/"
289   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
290     "$pkgdir/usr/share/licenses/$pkgname/"
293 package_gcc-fortran() {
294   pkgdesc='Fortran front-end for GCC'
295   depends=("gcc=$pkgver-$pkgrel" libisl.so)
296   provides=($pkgname-multilib)
297   replaces=($pkgname-multilib)
299   cd gcc-build
300   make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
301     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
302   make -C $CHOST/32/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
303     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
304   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
305   make -C gcc DESTDIR="$pkgdir" fortran.install-{common,man,info}
306   install -Dm755 gcc/f951 "$pkgdir/${_libdir}/f951"
308   ln -s gfortran "$pkgdir/usr/bin/f95"
310   # Install Runtime Library Exception
311   install -d "$pkgdir/usr/share/licenses/$pkgname/"
312   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
313     "$pkgdir/usr/share/licenses/$pkgname/"
316 package_gcc-objc() {
317   pkgdesc='Objective-C front-end for GCC'
318   depends=("gcc=$pkgver-$pkgrel" libisl.so)
319   provides=($pkgname-multilib)
320   replaces=($pkgname-multilib)
322   cd gcc-build
323   make DESTDIR="$pkgdir" -C $CHOST/libobjc install-headers
324   install -dm755 "$pkgdir/${_libdir}"
325   install -m755 gcc/cc1obj{,plus} "$pkgdir/${_libdir}/"
327   # Install Runtime Library Exception
328   install -d "$pkgdir/usr/share/licenses/$pkgname/"
329   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
330     "$pkgdir/usr/share/licenses/$pkgname/"
333 package_gcc-ada() {
334   pkgdesc='Ada front-end for GCC (GNAT)'
335   depends=("gcc=$pkgver-$pkgrel" libisl.so)
336   provides=($pkgname-multilib)
337   replaces=($pkgname-multilib)
338   options=(!emptydirs staticlibs debug)
340   cd gcc-build/gcc
341   make DESTDIR="$pkgdir" ada.install-{common,info}
342   install -m755 gnat1 "$pkgdir/${_libdir}"
344   cd "$srcdir"/gcc-build/$CHOST/libada
345   make DESTDIR="${pkgdir}" INSTALL="install" \
346     INSTALL_DATA="install -m644" install-libada
348   cd "$srcdir"/gcc-build/$CHOST/32/libada
349   make DESTDIR="${pkgdir}" INSTALL="install" \
350     INSTALL_DATA="install -m644" install-libada
352   ln -s gcc "$pkgdir/usr/bin/gnatgcc"
354   # insist on dynamic linking, but keep static libraries because gnatmake complains
355   mv "$pkgdir"/${_libdir}/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib"
356   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib/libgnarl.so"
357   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib/libgnat.so"
358   rm -f "$pkgdir"/${_libdir}/adalib/libgna{rl,t}.so
360   install -d "$pkgdir/usr/lib32/"
361   mv "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib32"
362   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib32/libgnarl.so"
363   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib32/libgnat.so"
364   rm -f "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}.so
366   # Install Runtime Library Exception
367   install -d "$pkgdir/usr/share/licenses/$pkgname/"
368   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
369     "$pkgdir/usr/share/licenses/$pkgname/"
372 package_gcc-go() {
373   pkgdesc='Go front-end for GCC'
374   depends=("gcc=$pkgver-$pkgrel" libisl.so)
375   provides=("go=1.12.2" $pkgname-multilib)
376   replaces=($pkgname-multilib)
377   conflicts=(go)
379   cd gcc-build
380   make -C $CHOST/libgo DESTDIR="$pkgdir" install-exec-am
381   make -C $CHOST/32/libgo DESTDIR="$pkgdir" install-exec-am
382   make DESTDIR="$pkgdir" install-gotools
383   make -C gcc DESTDIR="$pkgdir" go.install-{common,man,info}
385   rm -f "$pkgdir"/usr/lib{,32}/libgo.so*
386   install -Dm755 gcc/go1 "$pkgdir/${_libdir}/go1"
388   # Install Runtime Library Exception
389   install -d "$pkgdir/usr/share/licenses/$pkgname/"
390   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
391     "$pkgdir/usr/share/licenses/$pkgname/"
394 package_lib32-gcc-libs() {
395   pkgdesc='32-bit runtime libraries shipped by GCC'
396   depends=('lib32-glibc>=2.27')
397   provides=(libgo.so libgfortran.so libubsan.so libasan.so)
398   groups=(multilib-devel)
399   options=(!emptydirs !strip)
401   cd gcc-build
403   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install-shared
404   rm -f "$pkgdir/$_libdir/32/libgcc_eh.a"
406   for lib in libatomic \
407              libgfortran \
408              libgo \
409              libgomp \
410              libitm \
411              libquadmath \
412              libsanitizer/{a,l,ub}san \
413              libstdc++-v3/src \
414              libvtv; do
415     make -C $CHOST/32/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
416   done
418   make -C $CHOST/32/libobjc DESTDIR="$pkgdir" install-libs
420   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
421   rm -f "$pkgdir"/usr/lib32/libgphobos.spec
423   # remove files provided by gcc-libs
424   rm -rf "$pkgdir"/usr/lib
426   # Install Runtime Library Exception
427   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
428     "$pkgdir/usr/share/licenses/lib32-gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
431 package_gcc-d() {
432   pkgdesc="D frontend for GCC"
433   depends=("gcc=$pkgver-$pkgrel" libisl.so)
434   provides=(gdc)
435   replaces=(gdc)
436   options=(staticlibs debug)
438   cd gcc-build
439   make -C gcc DESTDIR="$pkgdir" d.install-{common,man,info}
441   install -Dm755 gcc/gdc "$pkgdir"/usr/bin/gdc
442   install -Dm755 gcc/d21 "$pkgdir"/"$_libdir"/d21
444   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
445   rm -f "$pkgdir/usr/lib/"lib{gphobos,gdruntime}.so*
446   rm -f "$pkgdir/usr/lib32/"lib{gphobos,gdruntime}.so*
448   install -d "$pkgdir"/usr/include/dlang
449   ln -s /"${_libdir}"/include/d "$pkgdir"/usr/include/dlang/gdc
451   # Install Runtime Library Exception
452   install -d "$pkgdir/usr/share/licenses/$pkgname/"
453   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
454     "$pkgdir/usr/share/licenses/$pkgname/"
457 package_libgccjit() {
458   pkgdesc="Just-In-Time Compilation with GCC backend"
459   depends=("gcc=$pkgver-$pkgrel" libisl.so)
461   cd gcc-build
462   make -C gcc DESTDIR="$pkgdir" jit.install-common jit.install-info
464   # Install Runtime Library Exception
465   install -d "$pkgdir/usr/share/licenses/$pkgname/"
466   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
467     "$pkgdir/usr/share/licenses/$pkgname/"