archrelease: copy trunk to extra-x86_64
[arch-packages.git] / gcc / repos / core-x86_64 / PKGBUILD
blob6bc839a5103aec0ff6dc7121e1366c25d02a941d
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-ada gcc-d gcc-fortran gcc-go gcc-objc lto-dump libgccjit)
11 pkgver=13.1.1
12 _majorver=${pkgver%%.*}
13 _commit=9a167ee2f8b9a0859fbab6cfdc276cf1f272effe
14 pkgrel=1
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   gcc-d
24   git
25   lib32-glibc
26   lib32-gcc-libs
27   libisl
28   libmpc
29   python
30   zstd
32 checkdepends=(
33   dejagnu
34   expect
35   inetutils
36   python-pytest
37   tcl
39 options=(!emptydirs !lto)
40 _libdir=usr/lib/gcc/$CHOST/${pkgver%%+*}
41 source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
42         c89 c99
43         gcc-ada-repro.patch
45 validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9  # bpiotrowski@archlinux.org
46               86CFFCA918CF3AF47147588051E8B148A9999C34  # evangelos@foutrelis.com
47               13975A70E63C361C73AE69EF6EEB81F8981C74C7  # richard.guenther@gmail.com
48               D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
49 sha256sums=('SKIP'
50             'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
51             '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a'
52             '1773f5137f08ac1f48f0f7297e324d5d868d55201c03068670ee4602babdef2f')
54 prepare() {
55   [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
56   cd gcc
58   # Do not run fixincludes
59   sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
61   # Arch Linux installs x86_64 libraries /lib
62   sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
64   # Reproducible gcc-ada
65   patch -Np0 < "$srcdir/gcc-ada-repro.patch"
67   mkdir -p "$srcdir/gcc-build"
68   mkdir -p "$srcdir/libgccjit-build"
71 build() {
72   local _confflags=(
73       --prefix=/usr
74       --libdir=/usr/lib
75       --libexecdir=/usr/lib
76       --mandir=/usr/share/man
77       --infodir=/usr/share/info
78       --with-bugurl=https://bugs.archlinux.org/
79       --with-build-config=bootstrap-lto
80       --with-linker-hash-style=gnu
81       --with-system-zlib
82       --enable-__cxa_atexit
83       --enable-cet=auto
84       --enable-checking=release
85       --enable-clocale=gnu
86       --enable-default-pie
87       --enable-default-ssp
88       --enable-gnu-indirect-function
89       --enable-gnu-unique-object
90       --enable-libstdcxx-backtrace
91       --enable-link-serialization=1
92       --enable-linker-build-id
93       --enable-lto
94       --enable-multilib
95       --enable-plugin
96       --enable-shared
97       --enable-threads=posix
98       --disable-libssp
99       --disable-libstdcxx-pch
100       --disable-werror
101   )
103   cd gcc-build
105   # Credits @allanmcrae
106   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
107   # TODO: properly deal with the build issues resulting from this
108   CFLAGS=${CFLAGS/-Werror=format-security/}
109   CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
111   "$srcdir/gcc/configure" \
112     --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ \
113     --enable-bootstrap \
114     "${_confflags[@]:?_confflags unset}"
116   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
117   make -O STAGE1_CFLAGS="-O2" \
118           BOOT_CFLAGS="$CFLAGS" \
119           BOOT_LDFLAGS="$LDFLAGS" \
120           LDFLAGS_FOR_TARGET="$LDFLAGS" \
121           bootstrap
123   # make documentation
124   make -O -C $CHOST/libstdc++-v3/doc doc-man-doxygen
126   # Build libgccjit separately, to avoid building all compilers with --enable-host-shared
127   # which brings a performance penalty
128   cd "${srcdir}"/libgccjit-build
130   "$srcdir/gcc/configure" \
131     --enable-languages=jit \
132     --disable-bootstrap \
133     --enable-host-shared \
134     "${_confflags[@]:?_confflags unset}"
136   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
137   make -O STAGE1_CFLAGS="-O2" \
138           BOOT_CFLAGS="$CFLAGS" \
139           BOOT_LDFLAGS="$LDFLAGS" \
140           LDFLAGS_FOR_TARGET="$LDFLAGS" \
141           all-gcc
143   cp -a gcc/libgccjit.so* ../gcc-build/gcc/
146 check() {
147   cd gcc-build
149   # disable libphobos test to avoid segfaults
150   sed -i '/maybe-check-target-libphobos \\/d' Makefile
152   # do not abort on error as some are "expected"
153   make -O -k check || true
154   "$srcdir/gcc/contrib/test_summary"
157 package_gcc-libs() {
158   pkgdesc='Runtime libraries shipped by GCC'
159   depends=('glibc>=2.27')
160   options=(!emptydirs !strip)
161   provides=($pkgname-multilib libgo.so libgfortran.so libgphobos.so
162             libubsan.so libasan.so libtsan.so liblsan.so)
163   replaces=($pkgname-multilib libgphobos)
165   cd gcc-build
166   make -C $CHOST/libgcc DESTDIR="$pkgdir" install-shared
167   rm -f "$pkgdir/$_libdir/libgcc_eh.a"
169   for lib in libatomic \
170              libgfortran \
171              libgo \
172              libgomp \
173              libitm \
174              libquadmath \
175              libsanitizer/{a,l,ub,t}san \
176              libstdc++-v3/src \
177              libvtv; do
178     make -C $CHOST/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
179   done
181   make -C $CHOST/libobjc DESTDIR="$pkgdir" install-libs
182   make -C $CHOST/libstdc++-v3/po DESTDIR="$pkgdir" install
184   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
185   rm -rf "$pkgdir"/$_libdir/include/d/
186   rm -f "$pkgdir"/usr/lib/libgphobos.spec
188   for lib in libgomp \
189              libitm \
190              libquadmath; do
191     make -C $CHOST/$lib DESTDIR="$pkgdir" install-info
192   done
194   # remove files provided by lib32-gcc-libs
195   rm -rf "$pkgdir"/usr/lib32/
197   # Install Runtime Library Exception
198   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
199     "$pkgdir/usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
202 package_gcc() {
203   pkgdesc="The GNU Compiler Collection - C and C++ frontends"
204   depends=("gcc-libs=$pkgver-$pkgrel" 'binutils>=2.28' libmpc zstd libisl.so)
205   optdepends=('lib32-gcc-libs: for generating code for 32-bit ABI')
206   provides=($pkgname-multilib)
207   replaces=($pkgname-multilib)
208   options=(!emptydirs staticlibs)
210   cd gcc-build
212   make -C gcc DESTDIR="$pkgdir" install-driver install-cpp install-gcc-ar \
213     c++.install-common install-headers install-plugin install-lto-wrapper
215   install -m755 -t "$pkgdir/usr/bin/" gcc/gcov{,-tool}
216   install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1}
218   make -C $CHOST/libgcc DESTDIR="$pkgdir" install
219   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install
220   rm -f "$pkgdir"/usr/lib{,32}/libgcc_s.so*
222   make -C $CHOST/libstdc++-v3/src DESTDIR="$pkgdir" install
223   make -C $CHOST/libstdc++-v3/include DESTDIR="$pkgdir" install
224   make -C $CHOST/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
225   make -C $CHOST/libstdc++-v3/python DESTDIR="$pkgdir" install
226   make -C $CHOST/32/libstdc++-v3/src DESTDIR="$pkgdir" install
227   make -C $CHOST/32/libstdc++-v3/include DESTDIR="$pkgdir" install
228   make -C $CHOST/32/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
230   make DESTDIR="$pkgdir" install-libcc1
231   install -d "$pkgdir/usr/share/gdb/auto-load/usr/lib"
232   mv "$pkgdir"/usr/lib/libstdc++.so.6.*-gdb.py \
233     "$pkgdir/usr/share/gdb/auto-load/usr/lib/"
234   rm "$pkgdir"/usr/lib{,32}/libstdc++.so*
236   make DESTDIR="$pkgdir" install-fixincludes
237   make -C gcc DESTDIR="$pkgdir" install-mkheaders
239   make -C lto-plugin DESTDIR="$pkgdir" install
240   install -dm755 "$pkgdir"/usr/lib/bfd-plugins/
241   ln -s /${_libdir}/liblto_plugin.so \
242     "$pkgdir/usr/lib/bfd-plugins/"
244   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_{libsubinclude,toolexeclib}HEADERS
245   make -C $CHOST/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
246   make -C $CHOST/libquadmath DESTDIR="$pkgdir" install-nodist_libsubincludeHEADERS
247   make -C $CHOST/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
248   make -C $CHOST/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
249   make -C $CHOST/libsanitizer/tsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
250   make -C $CHOST/libsanitizer/lsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
251   make -C $CHOST/32/libgomp DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
252   make -C $CHOST/32/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
253   make -C $CHOST/32/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
254   make -C $CHOST/32/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
256   make -C gcc DESTDIR="$pkgdir" install-man install-info
257   rm "$pkgdir"/usr/share/man/man1/{gccgo,gfortran,lto-dump,gdc}.1
258   rm "$pkgdir"/usr/share/info/{gccgo,gfortran,gnat-style,gnat_rm,gnat_ugn,gdc}.info
260   make -C libcpp DESTDIR="$pkgdir" install
261   make -C gcc DESTDIR="$pkgdir" install-po
263   # many packages expect this symlink
264   ln -s gcc "$pkgdir"/usr/bin/cc
266   # create cc-rs compatible symlinks
267   # https://github.com/rust-lang/cc-rs/blob/1.0.73/src/lib.rs#L2578-L2581
268   for binary in {c++,g++,gcc,gcc-ar,gcc-nm,gcc-ranlib}; do
269     ln -s /usr/bin/${binary} "${pkgdir}"/usr/bin/x86_64-linux-gnu-${binary}
270   done
272   # POSIX conformance launcher scripts for c89 and c99
273   install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89"
274   install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99"
276   # install the libstdc++ man pages
277   make -C $CHOST/libstdc++-v3/doc DESTDIR="$pkgdir" doc-install-man
279   # remove files provided by lib32-gcc-libs
280   rm -f "$pkgdir"/usr/lib32/lib{stdc++,gcc_s}.so
282   # byte-compile python libraries
283   python -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
284   python -O -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
286   # Install Runtime Library Exception
287   install -d "$pkgdir/usr/share/licenses/$pkgname/"
288   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
289     "$pkgdir/usr/share/licenses/$pkgname/"
292 package_gcc-fortran() {
293   pkgdesc='Fortran front-end for GCC'
294   depends=("gcc=$pkgver-$pkgrel" libisl.so)
295   provides=($pkgname-multilib)
296   replaces=($pkgname-multilib)
298   cd gcc-build
299   make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
300     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
301   make -C $CHOST/32/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
302     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
303   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
304   make -C gcc DESTDIR="$pkgdir" fortran.install-{common,man,info}
305   install -Dm755 gcc/f951 "$pkgdir/${_libdir}/f951"
307   ln -s gfortran "$pkgdir/usr/bin/f95"
309   # Install Runtime Library Exception
310   install -d "$pkgdir/usr/share/licenses/$pkgname/"
311   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
312     "$pkgdir/usr/share/licenses/$pkgname/"
315 package_gcc-objc() {
316   pkgdesc='Objective-C front-end for GCC'
317   depends=("gcc=$pkgver-$pkgrel" libisl.so)
318   provides=($pkgname-multilib)
319   replaces=($pkgname-multilib)
321   cd gcc-build
322   make DESTDIR="$pkgdir" -C $CHOST/libobjc install-headers
323   install -dm755 "$pkgdir/${_libdir}"
324   install -m755 gcc/cc1obj{,plus} "$pkgdir/${_libdir}/"
326   # Install Runtime Library Exception
327   install -d "$pkgdir/usr/share/licenses/$pkgname/"
328   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
329     "$pkgdir/usr/share/licenses/$pkgname/"
332 package_gcc-ada() {
333   pkgdesc='Ada front-end for GCC (GNAT)'
334   depends=("gcc=$pkgver-$pkgrel" libisl.so)
335   provides=($pkgname-multilib)
336   replaces=($pkgname-multilib)
337   options=(!emptydirs staticlibs)
339   cd gcc-build/gcc
340   make DESTDIR="$pkgdir" ada.install-{common,info}
341   install -m755 gnat1 "$pkgdir/${_libdir}"
343   cd "$srcdir"/gcc-build/$CHOST/libada
344   make DESTDIR="${pkgdir}" INSTALL="install" \
345     INSTALL_DATA="install -m644" install-libada
347   cd "$srcdir"/gcc-build/$CHOST/32/libada
348   make DESTDIR="${pkgdir}" INSTALL="install" \
349     INSTALL_DATA="install -m644" install-libada
351   ln -s gcc "$pkgdir/usr/bin/gnatgcc"
353   # insist on dynamic linking, but keep static libraries because gnatmake complains
354   mv "$pkgdir"/${_libdir}/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib"
355   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib/libgnarl.so"
356   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib/libgnat.so"
357   rm -f "$pkgdir"/${_libdir}/adalib/libgna{rl,t}.so
359   install -d "$pkgdir/usr/lib32/"
360   mv "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib32"
361   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib32/libgnarl.so"
362   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib32/libgnat.so"
363   rm -f "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}.so
365   # Install Runtime Library Exception
366   install -d "$pkgdir/usr/share/licenses/$pkgname/"
367   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
368     "$pkgdir/usr/share/licenses/$pkgname/"
371 package_gcc-go() {
372   pkgdesc='Go front-end for GCC'
373   depends=("gcc=$pkgver-$pkgrel" libisl.so)
374   provides=("go=1.18" $pkgname-multilib)
375   replaces=($pkgname-multilib)
376   conflicts=(go)
378   cd gcc-build
379   make -C $CHOST/libgo DESTDIR="$pkgdir" install-exec-am
380   make -C $CHOST/32/libgo DESTDIR="$pkgdir" install-exec-am
381   make DESTDIR="$pkgdir" install-gotools
382   make -C gcc DESTDIR="$pkgdir" go.install-{common,man,info}
384   rm -f "$pkgdir"/usr/lib{,32}/libgo.so*
385   install -Dm755 gcc/go1 "$pkgdir/${_libdir}/go1"
387   # Install Runtime Library Exception
388   install -d "$pkgdir/usr/share/licenses/$pkgname/"
389   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
390     "$pkgdir/usr/share/licenses/$pkgname/"
393 package_lib32-gcc-libs() {
394   pkgdesc='32-bit runtime libraries shipped by GCC'
395   depends=('lib32-glibc>=2.27')
396   provides=(libgo.so libgfortran.so libubsan.so libasan.so)
397   options=(!emptydirs !strip)
399   cd gcc-build
401   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install-shared
402   rm -f "$pkgdir/$_libdir/32/libgcc_eh.a"
404   for lib in libatomic \
405              libgfortran \
406              libgo \
407              libgomp \
408              libitm \
409              libquadmath \
410              libsanitizer/{a,l,ub}san \
411              libstdc++-v3/src \
412              libvtv; do
413     make -C $CHOST/32/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
414   done
416   make -C $CHOST/32/libobjc DESTDIR="$pkgdir" install-libs
418   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
419   rm -f "$pkgdir"/usr/lib32/libgphobos.spec
421   # remove files provided by gcc-libs
422   rm -rf "$pkgdir"/usr/lib
424   # Install Runtime Library Exception
425   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
426     "$pkgdir/usr/share/licenses/lib32-gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
429 package_gcc-d() {
430   pkgdesc="D frontend for GCC"
431   depends=("gcc=$pkgver-$pkgrel" libisl.so)
432   provides=(gdc)
433   replaces=(gdc)
434   options=(staticlibs)
436   cd gcc-build
437   make -C gcc DESTDIR="$pkgdir" d.install-{common,man,info}
439   install -Dm755 gcc/gdc "$pkgdir"/usr/bin/gdc
440   install -Dm755 gcc/d21 "$pkgdir"/"$_libdir"/d21
442   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
443   rm -f "$pkgdir/usr/lib/"lib{gphobos,gdruntime}.so*
444   rm -f "$pkgdir/usr/lib32/"lib{gphobos,gdruntime}.so*
446   # Install Runtime Library Exception
447   install -d "$pkgdir/usr/share/licenses/$pkgname/"
448   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
449     "$pkgdir/usr/share/licenses/$pkgname/"
452 #package_gcc-rust() {
453 #  pkgdesc="Rust frontend for GCC"
454 #  depends=("gcc=$pkgver-$pkgrel" libisl.so)
455 #  replaces=(gcc-rust-git)
457 #  cd gcc-build
458 #  make -C gcc DESTDIR="$pkgdir" rust.install-{common,man,info}
460 #  install -Dm755 gcc/gccrs "$pkgdir"/usr/bin/gccrs
461 #  install -Dm755 gcc/rust1 "$pkgdir"/"$_libdir"/rust1
463 #  # Install Runtime Library Exception
464 #  install -d "$pkgdir/usr/share/licenses/$pkgname/"
465 #  ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
466 #    "$pkgdir/usr/share/licenses/$pkgname/"
469 package_lto-dump() {
470   pkgdesc="Dump link time optimization object files"
471   depends=("gcc=$pkgver-$pkgrel" libisl.so)
473   cd gcc-build
474   make -C gcc DESTDIR="$pkgdir" lto.install-{common,man,info}
476   # Install Runtime Library Exception
477   install -d "$pkgdir/usr/share/licenses/$pkgname/"
478   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
479     "$pkgdir/usr/share/licenses/$pkgname/"
482 package_libgccjit() {
483   pkgdesc="Just-In-Time Compilation with GCC backend"
484   depends=("gcc=$pkgver-$pkgrel" libisl.so)
486   cd gcc-build
487   make -C gcc DESTDIR="$pkgdir" jit.install-common jit.install-info
489   # Install Runtime Library Exception
490   install -d "$pkgdir/usr/share/licenses/$pkgname/"
491   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
492     "$pkgdir/usr/share/licenses/$pkgname/"