PKGNAME=gcc-runtime-15
PKGSEC=devel
PKGDEP="glibc"
BUILDDEP="texinfo"
PKGDES="GNU Compiler Collection (runtime libraries, version 15)"

# Note: Multi-level Autotools source tree.
# Note:
# '--with-build-config=bootstrap-lto' is disabled, since it produces .a
# libraries containing thin LTO bytecodes, and programs depending on
# libbfd won't link.
AUTOTOOLS_STRICT=0
AUTOTOOLS_AFTER=(
    '--prefix=/usr'
    '--libdir=/usr/lib'
    '--libexecdir=/usr/lib'
    '--mandir=/usr/share/man'
    '--infodir=/usr/share/info'
    '--with-bugurl=https://github.com/AOSC-Dev/aosc-os-abbs/issues'
    '--enable-shared'
    '--enable-threads=posix'
    '--with-system-zlib'
    '--enable-gnu-indirect-function'
    '--enable-__cxa_atexit'
    '--disable-libunwind-exceptions'
    '--enable-clocale=gnu'
    '--disable-libstdcxx-pch'
    '--disable-libssp'
    '--enable-gnu-unique-object'
    '--enable-linker-build-id'
    '--with-isl'
    '--enable-lto'
    '--enable-plugin'
    '--enable-install-libiberty'
    '--disable-multilib'
    '--disable-werror'
    '--enable-pie'
    '--enable-checking=release'
    '--enable-libstdcxx-dual-abi'
    '--with-default-libstdcxx-abi=new'
    '--enable-default-pie'
    '--enable-default-ssp'
    '--enable-bootstrap'
    '--disable-fixincludes'
    '--enable-version-specific-runtime-libs'
    '--with-gcc-major-version-only'
    '--program-suffix=-15'
)

# Note: Languages to enable.
LANGS__NOGO="c,c++,fortran,lto,objc,obj-c++,m2,d,ada"
LANGS__GO="c,c++,fortran,lto,go,objc,obj-c++,m2,d,ada"
LANGS__RETRO="c,c++,fortran,lto,objc,obj-c++"

AUTOTOOLS_AFTER__AMD64=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__GO}"
    '--with-arch=x86-64'
    '--with-tune=znver4'
)
AUTOTOOLS_AFTER__ARM64=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__GO}"
    '--disable-fixed-point'
    '--with-arch=armv8-a'
    '--enable-fix-cortex-a53-835769'
    '--enable-fix-cortex-a53-843419'
)
AUTOTOOLS_AFTER__ARMV4=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--disable-fixed-point'
    '--with-arch=armv4'
    '--with-tune=strongarm110'
    '--with-float=soft'
)
AUTOTOOLS_AFTER__ARMV6HF=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--disable-fixed-point'
    '--with-arch=armv6'
    '--with-tune=arm1176jzf-s'
    '--with-float=hard'
    '--with-fpu=vfpv2'
)
AUTOTOOLS_AFTER__ARMV7HF=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--disable-fixed-point'
    '--with-arch=armv7-a'
    '--with-float=hard'
    '--with-fpu=neon'
)
AUTOTOOLS_AFTER__I486=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--with-cpu=i486'
    '--with-tune=bonnell'
)
AUTOTOOLS_AFTER__LOONGARCH64=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__NOGO/,ada/}"
    '--with-abi=lp64d'
    '--with-arch=la64v1.0'
    '--with-tune=la664'
)
AUTOTOOLS_AFTER__LOONGARCH64_NOSIMD=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__NOGO/,ada/}"
    '--with-abi=lp64d'
    '--with-arch=loongarch64'
)
AUTOTOOLS_AFTER__LOONGSON2F=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--with-abi=64'
    '--with-arch=mips3'
    '--with-tune=loongson2f'
)
AUTOTOOLS_AFTER__LOONGSON3=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__NOGO/,ada/}"
    '--with-abi=64'
    '--with-arch=gs464'
    '--with-tune=gs464e'
    '--with-mips-fix-loongson3-llsc'
)
AUTOTOOLS_AFTER__M68K=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--with-cpu=68020'
)
AUTOTOOLS_AFTER__POWERPC=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--with-cpu=powerpc'
    '--with-tune=G4'
    '--with-long-double-128'
    '--enable-secureplt'
)
AUTOTOOLS_AFTER__PPC64=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__RETRO}"
    '--with-cpu=powerpc64'
    '--with-tune=G5'
    '--with-long-double-128'
    '--enable-secureplt'
)
AUTOTOOLS_AFTER__PPC64EL=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__GO}"
    '--with-libphobos-druntime-only=no'
    '--with-cpu=power8'
    '--with-tune=power9'
    '--with-long-double-128'
    '--with-long-double-format=ieee'
    '--enable-secureplt'
    '--enable-targets=powerpcle-linux'
)
# FIXME: Poor RISC-V... segfaults with bootstrap-lto build profile.
# /tmp/ccIPTTDI.s: Assembler messages:
# /tmp/ccIPTTDI.s: Internal error (Segmentation fault).
# Please report this bug.
# make[4]: *** [/tmp/cc50KDC5.mk:10: /tmp/ccHnyNPc.ltrans4.ltrans.o] Error 1
# make[4]: *** Waiting for unfinished jobs....
AUTOTOOLS_AFTER__RISCV64=(
    "${AUTOTOOLS_AFTER[@]}"
    "--enable-languages=${LANGS__GO}"
    '--with-arch=rv64gc'
    '--with-abi=lp64d'
    '--with-isa-spec=20191213'
)

ABMK="profiledbootstrap"
# Note: Handled by build system.
AB_FLAGS_SPECS=0
# Note: Known safe.
AB_FLAGS_O3=1

# Note: -O3 bloats binary sizes, we don't want that for Afterglow.
AB_FLAGS_O3__RETRO=0

# Note: Some target libraries (libstdc++, etc.) should not be built with LTO.
NOLTO=1

# FIXME:
#
# configure.ac:35: error: Please use exactly Autoconf 2.69 instead of 2.72.
# config/override.m4:12: _GCC_AUTOCONF_VERSION_CHECK is expanded from...
# configure.ac:35: the top level
# autom4te: error: /usr/bin/m4 failed with exit status: 1
# aclocal: error: /usr/bin/autom4te failed with exit status: 1
# autoreconf: error: aclocal failed with exit status: 1
RECONF=0

# Note: Extra Provides for Spiral (Debian compatibilty).
PKGPROV="libgcc1_spiral libgcc-s1_spiral"

# Note: Debian's GCC is currently at 1:.
PKGEPOCH_SPIRAL=1

PKGESS=1

# Needed by Afterglow, whereas FAIL_ARCH defaults to mainline-only.
FAIL_ARCH="!(mainline|retro)"
