archrelease: copy trunk to community-x86_64
[ArchLinux/community.git] / gcc12 / trunk / PKGBUILD
blob3b27cc2b6a3f9b8bd912bc34e9e8121ba65359f7
1 # Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
2 # Contributor: Giancarlo Razzolini <grazzolini@archlinux.org>
3 # Contributor: Frederik Schwan <freswa at archlinux dot org>
4 # Contributor: BartÅ‚omiej Piotrowski <bpiotrowski@archlinux.org>
5 # Contributor: Allan McRae <allan@archlinux.org>
6 # Contributor: Daniel Kozak <kozzi11@gmail.com>
8 # toolchain build order: linux-api-headers->glibc->binutils->gcc->glibc->binutils->gcc
9 # NOTE: libtool requires rebuilt with each new gcc version
11 pkgname=(gcc12 gcc12-libs gcc12-fortran)
12 pkgver=12.3.0
13 _majorver=${pkgver%%.*}
14 _commit=8fc1a49c9312b05d925b7d21f1d2145d70818151
15 pkgrel=1
16 pkgdesc='The GNU Compiler Collection'
17 arch=(x86_64)
18 license=(GPL3 LGPL FDL custom)
19 url='https://gcc.gnu.org'
20 makedepends=(
21   binutils
22   doxygen
23   gcc-ada
24   gcc-d
25   git
26   libisl
27   libmpc
28   python
29   zstd
31 checkdepends=(
32   dejagnu
33   expect
34   inetutils
35   python-pytest
36   tcl
38 options=(!emptydirs !lto)
39 _libdir=usr/lib/gcc/$CHOST/${pkgver%%+*}
40 source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
41         c89 c99
43 validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9  # bpiotrowski@archlinux.org
44               86CFFCA918CF3AF47147588051E8B148A9999C34  # evangelos@foutrelis.com
45               13975A70E63C361C73AE69EF6EEB81F8981C74C7  # richard.guenther@gmail.com
46               D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
47 sha256sums=('SKIP'
48             'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
49             '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a')
51 prepare() {
52   [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
53   cd gcc
55   # Do not run fixincludes
56   sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
58   # Arch Linux installs x86_64 libraries /lib
59   sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
61   mkdir -p "$srcdir/gcc-build"
64 build() {
65   local _confflags=(
66       --prefix=/usr
67       --libdir=/usr/lib
68       --libexecdir=/usr/lib
69       --mandir=/usr/share/man
70       --infodir=/usr/share/info
71       --with-bugurl=https://bugs.archlinux.org/
72       --with-build-config=bootstrap-lto
73       --with-linker-hash-style=gnu
74       --with-system-zlib
75       --enable-__cxa_atexit
76       --enable-cet=auto
77       --enable-checking=release
78       --enable-clocale=gnu
79       --enable-default-pie
80       --enable-default-ssp
81       --enable-gnu-indirect-function
82       --enable-gnu-unique-object
83       --enable-libstdcxx-backtrace
84       --enable-link-serialization=1
85       --enable-linker-build-id
86       --enable-lto
87       --disable-multilib
88       --enable-plugin
89       --enable-shared
90       --enable-threads=posix
91       --disable-libssp
92       --disable-libstdcxx-pch
93       --disable-werror
94       --program-suffix=-12
95       --enable-version-specific-runtime-libs
96   )
98   cd gcc-build
100   # Credits @allanmcrae
101   # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
102   # TODO: properly deal with the build issues resulting from this
103   CFLAGS=${CFLAGS/-Werror=format-security/}
104   CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
106   "$srcdir/gcc/configure" \
107     --enable-languages=c,c++,fortran \
108     --enable-bootstrap \
109     "${_confflags[@]:?_confflags unset}"
111   # see https://bugs.archlinux.org/task/71777 for rationale re *FLAGS handling
112   make -O STAGE1_CFLAGS="-O2" \
113           BOOT_CFLAGS="$CFLAGS" \
114           BOOT_LDFLAGS="$LDFLAGS" \
115           LDFLAGS_FOR_TARGET="$LDFLAGS" \
116           bootstrap
118   # make documentation
119   make -O -C $CHOST/libstdc++-v3/doc doc-man-doxygen
122 check() {
123   cd gcc-build
125   # do not abort on error as some are "expected"
126   make -O -k check || true
127   "$srcdir/gcc/contrib/test_summary"
130 package_gcc12-libs() {
131   pkgdesc='Runtime libraries shipped by GCC (12.x.x)'
132   depends=('glibc>=2.27')
133   options=(!emptydirs !strip)
135   cd gcc-build
136   make -C $CHOST/libgcc DESTDIR="$pkgdir" install-shared
137   mv "${pkgdir}/${_libdir}"/../lib/* "${pkgdir}/${_libdir}"
138   rmdir "${pkgdir}/${_libdir}"/../lib
139   rm -f "$pkgdir/$_libdir/libgcc_eh.a"
141   for lib in libatomic \
142              libgfortran \
143              libgomp \
144              libitm \
145              libquadmath \
146              libsanitizer/{a,l,ub,t}san \
147              libstdc++-v3/src \
148              libvtv; do
149     make -C $CHOST/$lib DESTDIR="$pkgdir" install-toolexeclibLTLIBRARIES
150   done
152   make -C $CHOST/libstdc++-v3/po DESTDIR="$pkgdir" install
154   rm -rf "$pkgdir"/$_libdir/include/d/
155   rm -f "$pkgdir"/usr/lib/libgphobos.spec
157   # Install Runtime Library Exception
158   install -Dm644 "$srcdir/gcc/COPYING.RUNTIME" \
159     "$pkgdir/usr/share/licenses/gcc12-libs/RUNTIME.LIBRARY.EXCEPTION"
161   # remove conflicting files
162   rm -rf "${pkgdir}"/usr/share/locale
165 package_gcc12() {
166   pkgdesc="The GNU Compiler Collection - C and C++ frontends (12.x.x)"
167   depends=("gcc12-libs" 'binutils>=2.28' libmpc zstd libisl.so)
168   options=(!emptydirs staticlibs)
170   cd gcc-build
172   make -C gcc DESTDIR="$pkgdir" install-driver install-cpp install-gcc-ar \
173     c++.install-common install-headers install-plugin install-lto-wrapper
175   install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1,gcov{,-tool}}
177   make -C $CHOST/libgcc DESTDIR="$pkgdir" install
178   rm -f "$pkgdir"/usr/lib/libgcc_s.so*
180   make -C $CHOST/libstdc++-v3/src DESTDIR="$pkgdir" install
181   make -C $CHOST/libstdc++-v3/include DESTDIR="$pkgdir" install
182   make -C $CHOST/libstdc++-v3/libsupc++ DESTDIR="$pkgdir" install
183   make -C $CHOST/libstdc++-v3/python DESTDIR="$pkgdir" install
184   rm -f "${pkgdir}/${_libdir}"/libstdc++.so*
186   make DESTDIR="$pkgdir" install-fixincludes
187   make -C gcc DESTDIR="$pkgdir" install-mkheaders
189   make -C lto-plugin DESTDIR="$pkgdir" install
190   install -dm755 "$pkgdir"/${_libdir}/bfd-plugins/
191   ln -s /${_libdir}/liblto_plugin.so \
192     "$pkgdir/${_libdir}/bfd-plugins/"
194   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_{libsubinclude,toolexeclib}HEADERS
195   make -C $CHOST/libitm DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
196   make -C $CHOST/libquadmath DESTDIR="$pkgdir" install-nodist_libsubincludeHEADERS
197   make -C $CHOST/libsanitizer DESTDIR="$pkgdir" install-nodist_{saninclude,toolexeclib}HEADERS
198   make -C $CHOST/libsanitizer/asan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
199   make -C $CHOST/libsanitizer/tsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
200   make -C $CHOST/libsanitizer/lsan DESTDIR="$pkgdir" install-nodist_toolexeclibHEADERS
202   make -C libcpp DESTDIR="$pkgdir" install
203   make -C gcc DESTDIR="$pkgdir" install-po
205   # many packages expect this symlink
206   ln -s gcc "$pkgdir"/usr/bin/cc-12
208   # create cc-rs compatible symlinks
209   # https://github.com/rust-lang/cc-rs/blob/1.0.73/src/lib.rs#L2578-L2581
210   for binary in {c++,g++,gcc,gcc-ar,gcc-nm,gcc-ranlib}; do
211     ln -s /usr/bin/${binary} "${pkgdir}"/usr/bin/x86_64-linux-gnu-${binary}-12
212   done
214   # POSIX conformance launcher scripts for c89 and c99
215   install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89-12"
216   install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99-12"
218   # byte-compile python libraries
219   python -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
220   python -O -m compileall "$pkgdir/usr/share/gcc-${pkgver%%+*}/"
222   # Install Runtime Library Exception
223   install -d "$pkgdir/usr/share/licenses/$pkgname/"
224   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
225     "$pkgdir/usr/share/licenses/$pkgname/"
227   # remove conflicting files
228   rm -rf "${pkgdir}"/usr/share/locale
231 package_gcc12-fortran() {
232   pkgdesc='Fortran front-end for GCC (12.x.x)'
233   depends=("gcc12" libisl.so)
235   cd gcc-build
236   make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
237     install-{toolexeclibDATA,nodist_fincludeHEADERS,gfor_cHEADERS}
238   make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
239   make -C gcc DESTDIR="$pkgdir" fortran.install-common
240   install -Dm755 gcc/f951 "$pkgdir/${_libdir}/f951"
242   ln -s gfortran "$pkgdir/usr/bin/f95-12"
244   # Install Runtime Library Exception
245   install -d "$pkgdir/usr/share/licenses/$pkgname/"
246   ln -s /usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION \
247     "$pkgdir/usr/share/licenses/$pkgname/"