OCaml 4.14.0 rebuild
[arch-packages.git] / gcc / repos / core-x86_64 / PKGBUILD
blob1952b313793de11f8e58aa1bbe7016a64cbce8f9
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 lto-dump libgccjit)
11 pkgver=12.1.1
12 _commit=681c73db9bd156f9b65a73ccc6c4a0a697fe70d6
13 _majorver=${pkgver%%.*}
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   gcc-d
24   git
25   lib32-glibc
26   lib32-gcc-libs
27   libisl
28   libmpc
29   libxcrypt
30   python
31   zstd
33 checkdepends=(
34   dejagnu
35   expect
36   inetutils
37   python-pytest
38   tcl
40 options=(!emptydirs !lto debug)
41 _libdir=usr/lib/gcc/$CHOST/${pkgver%%+*}
42 # _commit=6beb39ee6c465c21d0cc547fd66b445100cdcc35
43 # source=(git://gcc.gnu.org/git/gcc.git#commit=$_commit
44 source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
45         c89 c99
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=('SKIP'
53             'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
54             '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a'
55             '1773f5137f08ac1f48f0f7297e324d5d868d55201c03068670ee4602babdef2f')
57 prepare() {
58   [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
59   cd gcc
61   # Do not run fixincludes
62   sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
64   # Arch Linux installs x86_64 libraries /lib
65   sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
67   # Reproducible gcc-ada
68   patch -Np0 < "$srcdir/gcc-ada-repro.patch"
70   mkdir -p "$srcdir/gcc-build"
71   mkdir -p "$srcdir/libgccjit-build"
74 build() {
75   local _confflags=(
76       --prefix=/usr
77       --libdir=/usr/lib
78       --libexecdir=/usr/lib
79       --mandir=/usr/share/man
80       --infodir=/usr/share/info
81       --with-bugurl=https://bugs.archlinux.org/
82       --with-build-config=bootstrap-lto
83       --with-linker-hash-style=gnu
84       --with-system-zlib
85       --enable-__cxa_atexit
86       --enable-cet=auto
87       --enable-checking=release
88       --enable-clocale=gnu
89       --enable-default-pie
90       --enable-default-ssp
91       --enable-gnu-indirect-function
92       --enable-gnu-unique-object
93       --enable-libstdcxx-backtrace
94       --enable-link-serialization=1
95       --enable-linker-build-id
96       --enable-lto
97       --enable-multilib
98       --enable-plugin
99       --enable-shared
100       --enable-threads=posix
101       --disable-libssp
102       --disable-libstdcxx-pch
103       --disable-werror
104   )
106   cd gcc-build
108   # Credits @allanmcrae
109   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
110   # TODO: properly deal with the build issues resulting from this
111   CFLAGS=${CFLAGS/-Werror=format-security/}
112   CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
114   "$srcdir/gcc/configure" \
115     --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d \
116     --enable-bootstrap \
117     "${_confflags[@]:?_confflags unset}"
119   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
120   make -O STAGE1_CFLAGS="-O2" \
121           BOOT_CFLAGS="$CFLAGS" \
122           BOOT_LDFLAGS="$LDFLAGS" \
123           LDFLAGS_FOR_TARGET="$LDFLAGS" \
124           bootstrap
126   # make documentation
127   make -O -C $CHOST/libstdc++-v3/doc doc-man-doxygen
129   # Build libgccjit separately, to avoid building all compilers with --enable-host-shared
130   # which brings a performance penalty
131   cd "${srcdir}"/libgccjit-build
133   "$srcdir/gcc/configure" \
134     --enable-languages=jit \
135     --disable-bootstrap \
136     --enable-host-shared \
137     "${_confflags[@]:?_confflags unset}"
139   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
140   make -O STAGE1_CFLAGS="-O2" \
141           BOOT_CFLAGS="$CFLAGS" \
142           BOOT_LDFLAGS="$LDFLAGS" \
143           LDFLAGS_FOR_TARGET="$LDFLAGS" \
144           all-gcc
146   cp -a gcc/libgccjit.so* ../gcc-build/gcc/
149 check() {
150   cd gcc-build
152   # disable libphobos test to avoid segfaults
153   sed -i '/maybe-check-target-libphobos \\/d' Makefile
155   # do not abort on error as some are "expected"
156   make -O -k check || true
157   "$srcdir/gcc/contrib/test_summary"
160 package_gcc-libs() {
161   pkgdesc='Runtime libraries shipped by GCC'
162   depends=('glibc>=2.27')
163   options=(!emptydirs !strip)
164   provides=($pkgname-multilib libgo.so libgfortran.so libgphobos.so
165             libubsan.so libasan.so libtsan.so liblsan.so)
166   replaces=($pkgname-multilib libgphobos)
168   cd gcc-build
169   make -C $CHOST/libgcc DESTDIR="$pkgdir" install-shared
170   rm -f "$pkgdir/$_libdir/libgcc_eh.a"
172   for lib in libatomic \
173              libgfortran \
174              libgo \
175              libgomp \
176              libitm \
177              libquadmath \
178              libsanitizer/{a,l,ub,t}san \
179              libstdc++-v3/src \
180              libvtv; do
181     make -C $CHOST/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
182   done
184   make -C $CHOST/libobjc DESTDIR="$pkgdir" install-libs
185   make -C $CHOST/libstdc++-v3/po DESTDIR="$pkgdir" install
187   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
188   rm -rf "$pkgdir"/$_libdir/include/d/
189   rm -f "$pkgdir"/usr/lib/libgphobos.spec
191   for lib in libgomp \
192              libitm \
193              libquadmath; do
194     make -C $CHOST/$lib DESTDIR="$pkgdir" install-info
195   done
197   # remove files provided by lib32-gcc-libs
198   rm -rf "$pkgdir"/usr/lib32/
200   # Install Runtime Library Exception
201   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
202     "$pkgdir/usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
205 package_gcc() {
206   pkgdesc="The GNU Compiler Collection - C and C++ frontends"
207   depends=("gcc-libs=$pkgver-$pkgrel" 'binutils>=2.28' libmpc zstd libisl.so)
208   groups=('base-devel')
209   optdepends=('lib32-gcc-libs: for generating code for 32-bit ABI')
210   provides=($pkgname-multilib)
211   replaces=($pkgname-multilib)
212   options=(!emptydirs staticlibs debug)
214   cd gcc-build
216   make -C gcc DESTDIR="$pkgdir" install-driver install-cpp install-gcc-ar \
217     c++.install-common install-headers install-plugin install-lto-wrapper
219   install -m755 -t "$pkgdir/usr/bin/" gcc/gcov{,-tool}
220   install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1}
222   make -C $CHOST/libgcc DESTDIR="$pkgdir" install
223   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install
224   rm -f "$pkgdir"/usr/lib{,32}/libgcc_s.so*
226   make -C $CHOST/libstdc++-v3/src DESTDIR="$pkgdir" install
227   make -C $CHOST/libstdc++-v3/include DESTDIR="$pkgdir" install
228   make -C $CHOST/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
229   make -C $CHOST/libstdc++-v3/python DESTDIR="$pkgdir" install
230   make -C $CHOST/32/libstdc++-v3/src DESTDIR="$pkgdir" install
231   make -C $CHOST/32/libstdc++-v3/include DESTDIR="$pkgdir" install
232   make -C $CHOST/32/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
234   make DESTDIR="$pkgdir" install-libcc1
235   install -d "$pkgdir/usr/share/gdb/auto-load/usr/lib"
236   mv "$pkgdir"/usr/lib/libstdc++.so.6.*-gdb.py \
237     "$pkgdir/usr/share/gdb/auto-load/usr/lib/"
238   rm "$pkgdir"/usr/lib{,32}/libstdc++.so*
240   make DESTDIR="$pkgdir" install-fixincludes
241   make -C gcc DESTDIR="$pkgdir" install-mkheaders
243   make -C lto-plugin DESTDIR="$pkgdir" install
244   install -dm755 "$pkgdir"/usr/lib/bfd-plugins/
245   ln -s /${_libdir}/liblto_plugin.so \
246     "$pkgdir/usr/lib/bfd-plugins/"
248   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_{libsubinclude,toolexeclib}HEADERS
249   make -C $CHOST/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
250   make -C $CHOST/libquadmath DESTDIR="$pkgdir" install-nodist_libsubincludeHEADERS
251   make -C $CHOST/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
252   make -C $CHOST/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
253   make -C $CHOST/libsanitizer/tsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
254   make -C $CHOST/libsanitizer/lsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
255   make -C $CHOST/32/libgomp DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
256   make -C $CHOST/32/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
257   make -C $CHOST/32/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
258   make -C $CHOST/32/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
260   make -C gcc DESTDIR="$pkgdir" install-man install-info
261   rm "$pkgdir"/usr/share/man/man1/{gccgo,gfortran,lto-dump,gdc}.1
262   rm "$pkgdir"/usr/share/info/{gccgo,gfortran,gnat-style,gnat_rm,gnat_ugn,gdc}.info
264   make -C libcpp DESTDIR="$pkgdir" install
265   make -C gcc DESTDIR="$pkgdir" install-po
267   # many packages expect this symlink
268   ln -s gcc "$pkgdir"/usr/bin/cc
270   # POSIX conformance launcher scripts for c89 and c99
271   install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89"
272   install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99"
274   # install the libstdc++ man pages
275   make -C $CHOST/libstdc++-v3/doc DESTDIR="$pkgdir" doc-install-man
277   # remove files provided by lib32-gcc-libs
278   rm -f "$pkgdir"/usr/lib32/lib{stdc++,gcc_s}.so
280   # byte-compile python libraries
281   python -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
282   python -O -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
284   # Install Runtime Library Exception
285   install -d "$pkgdir/usr/share/licenses/$pkgname/"
286   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
287     "$pkgdir/usr/share/licenses/$pkgname/"
290 package_gcc-fortran() {
291   pkgdesc='Fortran front-end for GCC'
292   depends=("gcc=$pkgver-$pkgrel" libisl.so)
293   provides=($pkgname-multilib)
294   replaces=($pkgname-multilib)
296   cd gcc-build
297   make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
298     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
299   make -C $CHOST/32/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
300     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
301   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
302   make -C gcc DESTDIR="$pkgdir" fortran.install-{common,man,info}
303   install -Dm755 gcc/f951 "$pkgdir/${_libdir}/f951"
305   ln -s gfortran "$pkgdir/usr/bin/f95"
307   # Install Runtime Library Exception
308   install -d "$pkgdir/usr/share/licenses/$pkgname/"
309   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
310     "$pkgdir/usr/share/licenses/$pkgname/"
313 package_gcc-objc() {
314   pkgdesc='Objective-C front-end for GCC'
315   depends=("gcc=$pkgver-$pkgrel" libisl.so)
316   provides=($pkgname-multilib)
317   replaces=($pkgname-multilib)
319   cd gcc-build
320   make DESTDIR="$pkgdir" -C $CHOST/libobjc install-headers
321   install -dm755 "$pkgdir/${_libdir}"
322   install -m755 gcc/cc1obj{,plus} "$pkgdir/${_libdir}/"
324   # Install Runtime Library Exception
325   install -d "$pkgdir/usr/share/licenses/$pkgname/"
326   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
327     "$pkgdir/usr/share/licenses/$pkgname/"
330 package_gcc-ada() {
331   pkgdesc='Ada front-end for GCC (GNAT)'
332   depends=("gcc=$pkgver-$pkgrel" libisl.so)
333   provides=($pkgname-multilib)
334   replaces=($pkgname-multilib)
335   options=(!emptydirs staticlibs debug)
337   cd gcc-build/gcc
338   make DESTDIR="$pkgdir" ada.install-{common,info}
339   install -m755 gnat1 "$pkgdir/${_libdir}"
341   cd "$srcdir"/gcc-build/$CHOST/libada
342   make DESTDIR="${pkgdir}" INSTALL="install" \
343     INSTALL_DATA="install -m644" install-libada
345   cd "$srcdir"/gcc-build/$CHOST/32/libada
346   make DESTDIR="${pkgdir}" INSTALL="install" \
347     INSTALL_DATA="install -m644" install-libada
349   ln -s gcc "$pkgdir/usr/bin/gnatgcc"
351   # insist on dynamic linking, but keep static libraries because gnatmake complains
352   mv "$pkgdir"/${_libdir}/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib"
353   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib/libgnarl.so"
354   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib/libgnat.so"
355   rm -f "$pkgdir"/${_libdir}/adalib/libgna{rl,t}.so
357   install -d "$pkgdir/usr/lib32/"
358   mv "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}-${_majorver}.so "$pkgdir/usr/lib32"
359   ln -s libgnarl-${_majorver}.so "$pkgdir/usr/lib32/libgnarl.so"
360   ln -s libgnat-${_majorver}.so "$pkgdir/usr/lib32/libgnat.so"
361   rm -f "$pkgdir"/${_libdir}/32/adalib/libgna{rl,t}.so
363   # Install Runtime Library Exception
364   install -d "$pkgdir/usr/share/licenses/$pkgname/"
365   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
366     "$pkgdir/usr/share/licenses/$pkgname/"
369 package_gcc-go() {
370   pkgdesc='Go front-end for GCC'
371   depends=("gcc=$pkgver-$pkgrel" libisl.so)
372   provides=("go=1.18" $pkgname-multilib)
373   replaces=($pkgname-multilib)
374   conflicts=(go)
376   cd gcc-build
377   make -C $CHOST/libgo DESTDIR="$pkgdir" install-exec-am
378   make -C $CHOST/32/libgo DESTDIR="$pkgdir" install-exec-am
379   make DESTDIR="$pkgdir" install-gotools
380   make -C gcc DESTDIR="$pkgdir" go.install-{common,man,info}
382   rm -f "$pkgdir"/usr/lib{,32}/libgo.so*
383   install -Dm755 gcc/go1 "$pkgdir/${_libdir}/go1"
385   # Install Runtime Library Exception
386   install -d "$pkgdir/usr/share/licenses/$pkgname/"
387   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
388     "$pkgdir/usr/share/licenses/$pkgname/"
391 package_lib32-gcc-libs() {
392   pkgdesc='32-bit runtime libraries shipped by GCC'
393   depends=('lib32-glibc>=2.27')
394   provides=(libgo.so libgfortran.so libubsan.so libasan.so)
395   groups=(multilib-devel)
396   options=(!emptydirs !strip)
398   cd gcc-build
400   make -C $CHOST/32/libgcc DESTDIR="$pkgdir" install-shared
401   rm -f "$pkgdir/$_libdir/32/libgcc_eh.a"
403   for lib in libatomic \
404              libgfortran \
405              libgo \
406              libgomp \
407              libitm \
408              libquadmath \
409              libsanitizer/{a,l,ub}san \
410              libstdc++-v3/src \
411              libvtv; do
412     make -C $CHOST/32/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
413   done
415   make -C $CHOST/32/libobjc DESTDIR="$pkgdir" install-libs
417   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
418   rm -f "$pkgdir"/usr/lib32/libgphobos.spec
420   # remove files provided by gcc-libs
421   rm -rf "$pkgdir"/usr/lib
423   # Install Runtime Library Exception
424   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
425     "$pkgdir/usr/share/licenses/lib32-gcc-libs/RUNTIME.LIBRARY.EXCEPTION"
428 package_gcc-d() {
429   pkgdesc="D frontend for GCC"
430   depends=("gcc=$pkgver-$pkgrel" libisl.so)
431   provides=(gdc)
432   replaces=(gdc)
433   options=(staticlibs debug)
435   cd gcc-build
436   make -C gcc DESTDIR="$pkgdir" d.install-{common,man,info}
438   install -Dm755 gcc/gdc "$pkgdir"/usr/bin/gdc
439   install -Dm755 gcc/d21 "$pkgdir"/"$_libdir"/d21
441   make -C $CHOST/libphobos DESTDIR="$pkgdir" install
442   rm -f "$pkgdir/usr/lib/"lib{gphobos,gdruntime}.so*
443   rm -f "$pkgdir/usr/lib32/"lib{gphobos,gdruntime}.so*
445   # Install Runtime Library Exception
446   install -d "$pkgdir/usr/share/licenses/$pkgname/"
447   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
448     "$pkgdir/usr/share/licenses/$pkgname/"
451 package_lto-dump() {
452   pkgdesc="Dump link time optimization object files"
453   depends=("gcc=$pkgver-$pkgrel" libisl.so)
455   cd gcc-build
456   make -C gcc DESTDIR="$pkgdir" lto.install-{common,man,info}
458   # Install Runtime Library Exception
459   install -d "$pkgdir/usr/share/licenses/$pkgname/"
460   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
461     "$pkgdir/usr/share/licenses/$pkgname/"
464 package_libgccjit() {
465   pkgdesc="Just-In-Time Compilation with GCC backend"
466   depends=("gcc=$pkgver-$pkgrel" libisl.so)
468   cd gcc-build
469   make -C gcc DESTDIR="$pkgdir" jit.install-common jit.install-info
471   # Install Runtime Library Exception
472   install -d "$pkgdir/usr/share/licenses/$pkgname/"
473   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
474     "$pkgdir/usr/share/licenses/$pkgname/"