MSYS2-packages/gcc/PKGBUILD
Christoph Reiter a2ee04bf00 More CPEs
2024-03-24 20:09:34 +01:00

299 lines
9.9 KiB
Bash

# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Martell Malone <martellmalone@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
# toolchain build order: win32-api-headers->msys2-runtime->binutils->gcc->binutils->msys2-runtime
# NOTE: libtool requires rebuilt with each new gcc version
pkgbase=gcc
pkgname=('gcc' 'gcc-libs')
pkgver=13.2.0
pkgrel=2
pkgdesc="The GNU Compiler Collection"
arch=('i686' 'x86_64')
license=('spdx:GPL-2.0-or-later' 'spdx:GPL-3.0-or-later' 'spdx:LGPL-2.1-or-later' 'spdx:LGPL-3.0-or-later' 'spdx:GCC-exception-3.1' 'spdx:GFDL-1.3-or-later')
url="https://gcc.gnu.org/"
msys2_references=(
"cpe: cpe:/a:gnu:gcc"
)
makedepends=('gcc' 'binutils' 'autotools'
'mpc-devel' 'gmp-devel' 'mpfr-devel' 'isl-devel' 'zlib-devel'
'windows-default-manifest' 'gperf')
options=('!emptydirs') # '!strip' 'debug')
source=(https://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/gcc-${pkgver}.tar.xz
0001-Cygwin-use-SysV-ABI-on-x86_64.patch
0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch
0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch
0004-Cygwin-MinGW-skip-test.patch
0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch
0006-Cygwin-fix-some-implicit-declaration-warnings-and-re.patch
0007-Cygwin-__cxa-atexit.patch
0008-Cygwin-libgomp-soname.patch
0009-Cygwin-g-time.patch
0010-Cygwin-newlib-ftm.patch
0011-Cygwin-define-STD_UNIX.patch
0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch
0102-Cygwin-testsuite-fixes-for-libgccjit.patch
0950-11.2.0-configure-msys2.patch
0951-11.2.0-msys2-spec.patch
0953-11.2.0-testsuite-msys2.patch)
sha256sums=('e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da'
'bc788aa466a83184d285cc2f6c1ffc40c6ed416dd08c6999015262a53f1ab1b5'
'704acfaeb11d24d3fe5aab34bc883c184ca93aff03d752016c9a50fdd82c5655'
'c5676fd62d5f7f69be26062b95d42ef47f28151af83b83efa3998ecd8e939e19'
'03ecf29419119286ebcef35864f9bd26d3bf3eaa355945856953204ed727e173'
'06214859ae4030ce30bb68aa35aa4a9ac92d1e79e34133089dcbfeb7cc8066e8'
'a843c038042811265d6ce5917b0c76b709e2591822e5cab53a32b7e9c806da29'
'e27f82af1eb7a4aad955ec36d5fd7d9a4c24575845bcf718372df9bc2b099eb6'
'de5692673731f90b888bf301a547481ab8e3cc0029713b6fd5abaabd860250f0'
'a40e7025507130a2a5d2eb2eea8ba4b053398c307cd55b3c9421a8507bd315ed'
'2658eb376f7829179963978b69a048ed105a41508adc55d0fc0d607c14181926'
'83b6aea4a462ae80121fd68d42c6234d02e20865132197a10575bbf95fd33b7e'
'c5aeab9609f90a8430c43bb50172b63c3155eb10082369f81fac58a395d2e2ee'
'3707b0aab99b203cbd9e513be46c7d4600de06e6c8344160b7fb1779061d08da'
'8a29a40ee426ee786da97656c35d2e9c17838b12c1b750cecf857760da273381'
'959ef644853398fe6f2c291a43e5e5bfac4dc973ce6ae7ff23734135cb9a5b60'
'adb8baaa35dcfbea9ab60694262d0958e090495146d50df1a0844a977832aef9')
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _fname in "$@"
do
msg2 "Applying ${_fname}"
patch -Nbp1 -i "${srcdir}"/${_fname}
done
}
del_file_exists() {
for _fname in "$@"
do
if [ -f $_fname ] || [ -d $_fname ]; then
rm -rf $_fname
fi
done
}
# =========================================== #
prepare() {
cd ${srcdir}/gcc-${pkgver}
# Remove files created by patches
rm -f config/mt-cygwin \
gcc/ada/system-cygwin-x86_64.ads \
libgomp/config/cygwin/plugin-suffix.h \
libgcc/config/i386/t-msys \
gcc/config/i386/msys.h \
gcc/config/i386/msys-w64.h \
gcc/config/i386/t-msys-w64 > /dev/null 2>&1 | true
# Cygwin patches
apply_patch_with_msg \
0001-Cygwin-use-SysV-ABI-on-x86_64.patch \
0002-Cygwin-add-dummy-pthread-tsaware-and-large-address-a.patch \
0003-Cygwin-handle-dllimport-properly-in-medium-model-V2.patch \
0004-Cygwin-MinGW-skip-test.patch \
0005-Cygwin-define-RTS_CONTROL_ENABLE-and-DTR_CONTROL_ENA.patch \
0006-Cygwin-fix-some-implicit-declaration-warnings-and-re.patch \
0007-Cygwin-__cxa-atexit.patch \
0008-Cygwin-libgomp-soname.patch \
0009-Cygwin-g-time.patch \
0010-Cygwin-newlib-ftm.patch \
0011-Cygwin-define-STD_UNIX.patch \
0101-Cygwin-enable-libgccjit-not-just-for-MingW.patch \
0102-Cygwin-testsuite-fixes-for-libgccjit.patch
# MSYS2 Patches
apply_patch_with_msg \
0950-11.2.0-configure-msys2.patch \
0951-11.2.0-msys2-spec.patch \
0953-11.2.0-testsuite-msys2.patch
# Do not run fixincludes
#sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
echo ${pkgver} > gcc/BASE-VER
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
}
build() {
mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
case ${CARCH} in
i686)
_arch=pentium4
_arch_conf="--disable-sjlj-exceptions"
;;
x86_64)
_arch=nocona
_arch_conf=
;;
esac
# libgcc is built with -g0, but INHIBIT_LIBC_CFLAGS can
# be used to undo that.
if check_option "debug" "y"; then
export INHIBIT_LIBC_CFLAGS="-g2"
fi
# using -pipe causes spurious test-suite failures
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48565
CFLAGS=${CFLAGS/-pipe/}
CXXFLAGS=${CXXFLAGS/-pipe/}
export lt_cv_deplibs_check_method='pass_all'
${srcdir}/gcc-${pkgver}/configure \
--build=${CHOST} \
--prefix=/usr \
--libexecdir=/usr/lib \
--enable-bootstrap \
--enable-shared --enable-shared-libgcc --enable-static \
--enable-version-specific-runtime-libs \
--with-arch=${_arch} \
--with-tune=generic \
--disable-multilib \
${_arch_conf} \
--enable-__cxa_atexit \
--with-dwarf2 \
--enable-languages=c,c++,lto \
--enable-graphite \
--enable-threads=posix \
--enable-libatomic \
--enable-libgomp \
--disable-libitm \
--enable-libquadmath \
--enable-libquadmath-support \
--disable-libssp \
--disable-win32-registry \
--disable-symvers \
--with-gnu-ld \
--with-gnu-as \
--disable-isl-version-check \
--enable-checking=release \
--without-libiconv-prefix \
--without-libintl-prefix \
--with-system-zlib \
--enable-linker-build-id \
--enable-libstdcxx-filesystem-ts
make
# make documentation
#cd $CHOST/libstdc++-v3
#make doc-man-doxygen
}
#check() {
# cd ${srcdir}/build-${CARCH}
# # do not abort on error as some are "expected"
# make -k check || true
# ${srcdir}/gcc-${pkgver}/contrib/test_summary
#}
package_gcc-libs()
{
pkgdesc="Runtime libraries shipped by GCC"
cd ${srcdir}/build-${CARCH}
make -j1 -C $CHOST/libgcc DESTDIR=${pkgdir} install-shared
for lib in libgomp libstdc++-v3/src; do
make -j1 -C $CHOST/$lib DESTDIR=${pkgdir} install-toolexeclibLTLIBRARIES
done
make -j1 -C $CHOST/libstdc++-v3/po DESTDIR=${pkgdir} install
make -j1 -C $CHOST/libgomp DESTDIR=${pkgdir} install-info
make -j1 -C $CHOST/libquadmath DESTDIR=${pkgdir} install-info
make -j1 DESTDIR=${pkgdir} install-target-libquadmath
#make -j1 DESTDIR=${pkgdir} install-target-libssp
make -j1 DESTDIR=${pkgdir} install-target-libatomic
#make -j1 DESTDIR=${pkgdir} install-target-libcilkrts
make -j1 DESTDIR=${pkgdir} install-target-libvtv
rm -f ${pkgdir}/*.dll
rm -rf ${pkgdir}/usr/lib/
rm -rf ${pkgdir}/usr/share/gcc-${pkgver}
# remove static libraries
#find ${pkgdir} -name *.a -delete
# Install Runtime Library Exception
install -Dm644 ${srcdir}/gcc-${pkgver}/COPYING.RUNTIME \
${pkgdir}/usr/share/licenses/gcc-libs/RUNTIME.LIBRARY.EXCEPTION
}
package_gcc()
{
pkgdesc="The GNU Compiler Collection - C and C++ frontends"
depends=("gcc-libs=${pkgver}-${pkgrel}" 'binutils' 'gmp' 'isl' 'mpc' 'mpfr' 'msys2-runtime-devel' 'msys2-w32api-headers' 'msys2-w32api-runtime' 'windows-default-manifest')
#options=("!strip")
provides=('msys2-devel')
conflicts=('gcc-fortran<=11.3.0-4')
cd ${srcdir}/build-${CARCH}
if check_option "strip" "n"; then
export STRIP=true
fi
make -j1 DESTDIR=${pkgdir} install
# install -d ${pkgdir}/usr/share/gdb/auto-load/usr/lib
# mv $pkg{pkgdir}dir{,/usr/share/gdb/auto-load}/usr/lib/libstdc++.so.6.0.18-gdb.py
# unfortunately it is much, much easier to install the lot and clean-up the mess...
# remove all DLLs
rm -f ${pkgdir}/usr/bin/*.dll
rm -f ${pkgdir}/usr/lib/libiberty.a
# rm -f ${pkgdir}/usr/lib/gcc/${CHOST}/${pkgver}/libatomic{.dll,}.a
rm -f ${pkgdir}/usr/share/info/{libgomp,libquadmath}.info
rm -f ${pkgdir}/usr/share/locale/{de,fr}/LC_MESSAGES/libstdc++.mo
# remove static libraries - note libstdc++.a is needed for the binutils and glibc testsuite
#rm ${pkgdir}/usr/lib/gcc/${CHOST}/${pkgver}/lib{gomp,quadmath}{.dll,}.a
# many packages expect this symlinks
ln -s gcc ${pkgdir}/usr/bin/cc
cp -f ${pkgdir}/usr/bin/cpp.exe ${pkgdir}/usr/lib/cpp
# POSIX conformance launcher scripts for c89 and c99
cat > $pkgdir/usr/bin/c89 <<"EOF"
#!/bin/sh
fl="-std=c89"
for opt; do
case "\$opt" in
-ansi|-std=c89|-std=iso9899:1990) fl="";;
-std=*) echo "`basename \$0` called with non ANSI/ISO C option \$opt" >&2
exit 1;;
esac
done
exec /usr/bin/gcc $fl ${1+"$@"}
EOF
cat > ${pkgdir}/usr/bin/c99 <<"EOF"
#!/bin/sh
fl="-std=c99"
for opt; do
case "\$opt" in
-std=c99|-std=iso9899:1999) fl="";;
-std=*) echo "`basename \$0` called with non ISO C99 option \$opt" >&2
exit 1;;
esac
done
exec /usr/bin/gcc $fl ${1+"$@"}
EOF
chmod 755 ${pkgdir}/usr/bin/c{8,9}9
# install the libstdc++ man pages
# install -dm755 ${pkgdir}/usr/share/man/man3
# install -m644 -t ${pkgdir}/usr/share/man/man3 \
# ${CHOST}/libstdc++-v3/doc/doxygen/man/man3/*.3
# Install Runtime Library Exception
install -Dm644 ${srcdir}/gcc-${pkgver}/COPYING.RUNTIME \
${pkgdir}/usr/share/licenses/gcc/RUNTIME.LIBRARY.EXCEPTION
}