PKGNAME=gcc-runtime-14
PKGSEC=devel
PKGDEP="glibc"
PKGDES="GNU Compiler Collection (runtime libraries only)"

# The following configuration:
#
# 1.  Enables support for C, C++, Fortran, "LTO", Go, ObjC, and ObjC++;
#     a. Mind here, Object C/C++ support is not enabled, we will provide that
#        in the "llvm" package as they provide a higher quality support for them;
#     b. Fortran is needed for many mathematical packages, as well as some audio/
#        video codecs, remove support for fortran if you know what you are doing;
#     c. "LTO" is not really a language, but it enables GCC to use LTO flags, and
#        thus provide respective optimizations later;
#     d. ObjC and ObjC++ is mainly used by the libobjc2 library and what is
#        dependent on it;
# 2.  Enables shared libraries for linking
#     (this is probably a good choice to reduce binary sizes of any packages that
#     links to GCC runtime libraries);
# 3.  Enables POSIX style threading;
# 4.  Enables linking to system Zlib;
# 5.  Disables libunwind support for exception detection;
# 6.  Enables GNU style C locales (you probably would not want to change this);
# 7.  Disables pre-compiled headers for libstdcxx;
# 8.  Disables libssp linking (not needed);
# 9.  Enables GNU unique object;
# 10. Enables linker build ID;
# 11. Enables LTO support (as mentioned in note 1, section c);
# 12. Enables isl for Graphite loop optimization;
# 13. Enables plugin support;
# 14. Enables libiberty installation
#     (you may disable "--enable-install-libiberty" if you really feel the urge...);
# 15. Disables multilib support
#     (you may remove "--disable-multilib" to enable the support for it, however
#     you will need a copy of GCC with multilib support to build);
#     a. AOSC OS uses subsystems to provide binary support for foreign architectures.
# 16. Enable release level checking;
# 17. Enables support for GNU indirect function
#     (you may disable this by removing "--enable-gnu-indirect-function");
# 18. Use the new "cxx11/new" for libstdc++, available since GCC 5. The old
#     "gcc4-compatbile" ABI was used until Core 5.
# 19. --enable-default-pie enables PIE by default (-fpie or `-fPIE`?).
# 20. --enable-default-ssp enables --fstack-protector-strong by default.

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"
	"--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"
	"--enable-version-specific-runtime-libs"
	"--with-gcc-major-version-only"
	"--program-suffix=-14"
)

AUTOTOOLS_AFTER__NOGO="--enable-languages=c,c++,fortran,lto,objc,obj-c++,m2,d,ada"
AUTOTOOLS_AFTER__GO="--enable-languages=c,c++,fortran,lto,go,objc,obj-c++,m2,d,ada"
AUTOTOOLS_AFTER__RETRO="--enable-languages=c,c++,fortran,lto,objc,obj-c++"

AUTOTOOLS_AFTER__AMD64=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__GO}"
)
AUTOTOOLS_AFTER__ARM64=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__GO}"
	"--disable-altivec"
	"--disable-fixed-point"
	"--with-arch=armv8-a"
	"--enable-fix-cortex-a53-835769"
	"--enable-fix-cortex-a53-843419"
)
AUTOTOOLS_AFTER__ARMV4=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--disable-altivec"
	"--disable-fixed-point"
	"--with-arch=armv4"
	"--with-tune=strongarm110"
	"--with-float=soft"
)
AUTOTOOLS_AFTER__ARMV6HF=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--disable-altivec"
	"--disable-fixed-point"
	"--with-arch=armv6"
	"--with-tune=arm1176jzf-s"
	"--with-float=hard"
	"--with-fpu=vfpv2"
)
AUTOTOOLS_AFTER__ARMV7HF=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--disable-altivec"
	"--disable-fixed-point"
	"--with-arch=armv7-a"
	"--with-float=hard"
	"--with-fpu=neon"
)
AUTOTOOLS_AFTER__I486=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--with-cpu=i486"
	"--with-tune=bonnell"
)
AUTOTOOLS_AFTER__LOONGARCH64=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__NOGO/,ada/}"
	"--with-abi=lp64d"
	"--with-arch=loongarch64"
	"--with-tune=la464"
)
AUTOTOOLS_AFTER__LOONGARCH64_NOSIMD=(
	"${AUTOTOOLS_AFTER__LOONGARCH64[@]}"
)
AUTOTOOLS_AFTER__LOONGSON2F=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--with-abi=64"
	"--with-arch=mips3"
	"--with-tune=loongson2f"
)
AUTOTOOLS_AFTER__LOONGSON3=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__NOGO/,ada/}"
	"--with-abi=64"
	"--with-arch=gs464"
	"--with-tune=gs464e"
	"--with-mips-fix-loongson3-llsc"
)
AUTOTOOLS_AFTER__M68K=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--with-cpu=68020"
)
AUTOTOOLS_AFTER__POWERPC=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--with-cpu=G3"
	"--with-tune=G4"
	"--with-long-double-128"
	"--enable-secureplt"
)
AUTOTOOLS_AFTER__PPC64=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__RETRO}"
	"--with-cpu=G5"
	"--with-tune=G5"
	"--with-long-double-128"
	"--enable-secureplt"
)
AUTOTOOLS_AFTER__PPC64EL=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__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"
)
AUTOTOOLS_AFTER__RISCV64=(
	"${AUTOTOOLS_AFTER[@]}"
	"${AUTOTOOLS_AFTER__GO}"
	"--with-arch=rv64gc"
	"--with-abi=lp64d"
	"--with-isa-spec=2.2"
)

ABMK="profiledbootstrap"
ABMK__LOONGSON3="bootstrap"
# FIXME: ICE during compilation with profiling.
#
# during RTL pass: cse1
# .../gcc-13.2.0/libgcc/libgcc2.c: In function ‘__cmpti2’:
# .../gcc-13.2.0/libgcc/libgcc2.c:1309:1: internal compiler error: in mode_size_inline, at ./insn-modes-inline.h:18
# 1309 | }
#      | ^
# during RTL pass: cse1
# .../gcc-13.2.0/libgcc/libgcc2.c: In function ‘__ashlti3’:
#.../gcc-13.2.0/libgcc/libgcc2.c:435:1: internal compiler error: in mode_size_inline, at ./insn-modes-inline.h:18
#  435 | }
#      | ^
ABMK__LOONGARCH64="bootstrap"
ABMK__LOONGARCH64_NOSIMD="${ABMK__LOONGARCH64}"
AB_FLAGS_SPECS=0
AB_FLAGS_O3=1

AB_FLAGS_O3__ARMV4=0
AB_FLAGS_O3__ARMV6HF=0
AB_FLAGS_O3__ARMV7HF=0
AB_FLAGS_O3__I486=0
AB_FLAGS_O3__LOONGSON2F=0
AB_FLAGS_O3__M68K=0
AB_FLAGS_O3__POWERPC=0
AB_FLAGS_O3__PPC64=0
AB_FLAGS_OS__ARMV4=0
AB_FLAGS_OS__ARMV6HF=0
AB_FLAGS_OS__ARMV7HF=0
AB_FLAGS_OS__I486=0
AB_FLAGS_OS__LOONGSON2F=0
AB_FLAGS_OS__M68K=0
AB_FLAGS_OS__POWERPC=0
AB_FLAGS_OS__PPC64=0

NOLTO=1

RECONF=0

PKGBREAK="gcc<=9.3.1-2"
PKGREP="gcc<=9.3.1-2"

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

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

# Breaks the pre-core-13 gcc.
PKGBREAK="gcc<=14.3.0-1 gcc-runtime<=14.3.0-1"
