summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin39744 -> 39738 bytes
-rw-r--r--eclass/ada.eclass16
-rw-r--r--eclass/toolchain.eclass298
3 files changed, 172 insertions, 142 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index 81fc2a69d2e5..e71b76dccb40 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/ada.eclass b/eclass/ada.eclass
index 3c3fa3c01453..faff19a6ac85 100644
--- a/eclass/ada.eclass
+++ b/eclass/ada.eclass
@@ -57,7 +57,7 @@ _ADA_ECLASS=1
# @DESCRIPTION:
# All supported Ada implementations, most preferred last.
_ADA_ALL_IMPLS=(
- gnat_2021 gcc_12 gcc_13
+ gnat_2021 gcc_12 gcc_13 gcc_14 gcc_15
)
readonly _ADA_ALL_IMPLS
@@ -119,7 +119,7 @@ _ada_impl_supported() {
# keep in sync with _ADA_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
- gnat_2021|gcc_12|gcc_13)
+ gnat_2021|gcc_12|gcc_13|gcc_14|gcc_15)
return 0
;;
*)
@@ -213,7 +213,7 @@ ada_export() {
local impl var
case "${1}" in
- gnat_2021|gcc_12|gcc_13)
+ gnat_2021|gcc_12|gcc_13|gcc_14|gcc_15)
impl=${1}
shift
;;
@@ -241,6 +241,14 @@ ada_export() {
gcc_pv=13
slot=13
;;
+ gcc_14)
+ gcc_pv=14
+ slot=14
+ ;;
+ gcc_15)
+ gcc_pv=15
+ slot=15
+ ;;
*)
gcc_pv="9.9.9"
slot=9.9.9
@@ -294,7 +302,7 @@ ada_export() {
gnat_2021)
ADA_PKG_DEP="dev-lang/gnat-gpl:${slot}[ada]"
;;
- gcc_12|gcc_13)
+ gcc_12|gcc_13|gcc_14|gcc_15)
ADA_PKG_DEP="sys-devel/gcc:${slot}[ada]"
;;
*)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 138925777dd6..939c68113188 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -402,7 +402,7 @@ if tc_has_feature valgrind ; then
fi
if [[ ${PN} != gnat-gpl ]] && tc_has_feature ada ; then
- BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )"
+ BDEPEND+=" ada? ( || ( sys-devel/gcc:${SLOT}[ada] <sys-devel/gcc-${SLOT}[ada] dev-lang/gnat-gpl[ada] ) )"
fi
# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
@@ -411,7 +411,7 @@ if tc_has_feature d && tc_version_is_at_least 12.0 ; then
# D in 12+ is self-hosting and needs D to bootstrap.
# TODO: package some binary we can use, like for Ada
# bug #840182
- BDEPEND+=" d? ( || ( sys-devel/gcc[d(-)] <sys-devel/gcc-12[d(-)] ) )"
+ BDEPEND+=" d? ( || ( sys-devel/gcc:${SLOT}[d(-)] <sys-devel/gcc-${SLOT}[d(-)] <sys-devel/gcc-12[d(-)] ) )"
fi
if tc_has_feature rust && tc_version_is_at_least 14.0.0_pre20230421 ; then
@@ -775,7 +775,6 @@ tc_enable_hardened_gcc() {
sed -i \
-e "/^HARD_CFLAGS = /s|=|= ${hardened_gcc_flags} |" \
"${S}"/gcc/Makefile.in || die
-
}
# This is a historical wart. The original Gentoo/amd64 port used:
@@ -820,97 +819,62 @@ setup_multilib_osdirnames() {
sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die
}
-#---->> src_configure <<----
-
-toolchain_src_configure() {
- BUILD_CONFIG_TARGETS=()
- is-flagq '-O3' && BUILD_CONFIG_TARGETS+=( bootstrap-O3 )
-
- downgrade_arch_flags
- gcc_do_filter_flags
-
- if ! tc_version_is_at_least 11 && [[ $(gcc-major-version) -ge 12 ]] ; then
- # https://gcc.gnu.org/PR105695
- # bug #849359
- export ac_cv_std_swap_in_utility=no
- fi
-
- einfo "CFLAGS=\"${CFLAGS}\""
- einfo "CXXFLAGS=\"${CXXFLAGS}\""
- einfo "LDFLAGS=\"${LDFLAGS}\""
-
- # Force internal zip based jar script to avoid random
- # issues with 3rd party jar implementations. bug #384291
- export JAR=no
-
- local confgcc=( --host=${CHOST} )
+# @FUNCTION: toolchain_setup_ada
+# @INTERNAL
+# @DESCRIPTION:
+# Determine the most suitable GNAT (Ada compiler) for bootstrapping
+# and setup the environment, including wrappers, for building.
+toolchain_setup_ada() {
+ local latest_gcc=$(best_version -b "sys-devel/gcc")
+ latest_gcc="${latest_gcc#sys-devel/gcc-}"
+ latest_gcc=$(ver_cut 1 ${latest_gcc})
+
+ local ada_bootstrap
+ local ada_candidate
+ # GNAT can usually be built using the last major version and
+ # the current version, at least.
+ #
+ # We always prefer the version being built if possible
+ # as it has the greatest chance of success. Failing that,
+ # try GCC 10 and iterate upwards.
+ for ada_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
+ has_version -b "sys-devel/gcc:${ada_candidate}" || continue
- if is_crosscompile || tc-is-cross-compiler ; then
- # Straight from the GCC install doc:
- # "GCC has code to correctly determine the correct value for target
- # for nearly all native systems. Therefore, we highly recommend you
- # not provide a configure target when configuring a native compiler."
- confgcc+=( --target=${CTARGET} )
- fi
- [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
+ ebegin "Testing sys-devel/gcc:${ada_candidate} for Ada"
+ if has_version -b "sys-devel/gcc:${ada_candidate}[ada(-)]" ; then
+ ada_bootstrap=${ada_candidate}
- _need_ada_bootstrap_mangling() {
- if [[ ${CATEGORY}/${PN} == dev-lang/gnat-gpl ]] ; then
- _tc_use_if_iuse system-bootstrap && return 0
- return 1
+ eend 0
+ break
fi
+ eend 1
+ done
- _tc_use_if_iuse ada
- }
-
- if _need_ada_bootstrap_mangling ; then
- local latest_gcc=$(best_version -b "sys-devel/gcc")
- latest_gcc="${latest_gcc#sys-devel/gcc-}"
- latest_gcc=$(ver_cut 1 ${latest_gcc})
-
- local ada_bootstrap
- local ada_candidate
- # We always prefer the version being built if possible
- # as it has the greatest chance of success. Failing that,
- # try GCC 10 and iterate upwards.
- for ada_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
- has_version -b "sys-devel/gcc:${ada_candidate}" || continue
-
- ebegin "Testing sys-devel/gcc:${ada_candidate} for Ada"
- if has_version -b "sys-devel/gcc:${ada_candidate}[ada(-)]" ; then
- # Make sure we set a path to the Ada bootstrap if gcc[ada] is not already
- # installed. GNAT can usually be built using the last major version and
- # the current version, at least.
- ada_bootstrap=${ada_candidate}
-
- eend 0
- break
- fi
+ # As a last resort, use dev-lang/gnat-gpl.
+ # TODO: Make gnat-gpl coinstallable with gcc:10 (bug #940471).
+ if ver_test ${ada_bootstrap} -gt ${PV} || [[ -z ${ada_bootstrap} ]] ; then
+ ebegin "Testing dev-lang/gnat-gpl for Ada"
+ if has_version -b "dev-lang/gnat-gpl" ; then
+ ada_bootstrap=10
+ eend 0
+ else
eend 1
- done
-
- # As a last resort, use dev-lang/gnat-gpl.
- # TODO: Make gnat-gpl coinstallable with gcc:10.
- if ver_test ${ada_bootstrap} -gt ${PV} || [[ -z ${ada_bootstrap} ]] ; then
- ebegin "Testing dev-lang/gnat-gpl for Ada"
- if has_version -b "dev-lang/gnat-gpl" ; then
- ada_bootstrap=10
- eend 0
- else
- eend 1
- fi
fi
+ fi
- # OK, even gnat-gpl didn't work. Give up for now.
- # TODO: Source a newer, or build our own, bootstrap tarball.
- if [[ -z ${ada_bootstrap} ]] ; then
- die "Fallback ada-bootstrap path not yet implemented!"
+ # OK, even gnat-gpl didn't work. Give up for now.
+ # TODO: Source a newer, or build our own, bootstrap tarball (bug #940472).
+ if [[ -z ${ada_bootstrap} ]] ; then
+ eerror "Couldn't find a suitable GNAT compiler for Ada!"
+ eerror "Please try installing dev-lang/gnat-gpl."
+ eerror "For other platforms, you may need to use crossdev."
+ die "Fallback ada-bootstrap path not yet implemented!"
- #einfo "Using bootstrap GNAT compiler..."
- #export PATH="${BROOT}/opt/ada-bootstrap-${GCCMAJOR}/bin:${PATH}"
- fi
+ #einfo "Using bootstrap GNAT compiler..."
+ #export PATH="${BROOT}/opt/ada-bootstrap-${GCCMAJOR}/bin:${PATH}"
+ fi
- cat <<-"EOF" > "${T}"/ada.spec || die
+ cat <<-"EOF" > "${T}"/ada.spec || die
# Extracted from gcc/ada/gcc-interface/lang-specs.h
.adb:
@ada
@@ -955,69 +919,103 @@ toolchain_src_configure() {
%{gnatc*|gnats*: -o %j} %{-param*}
EOF
- # Easier to substitute these values in rather than escape
- # lots of bits above in heredoc.
- sed -i \
- -e "s:\${BROOT}:${BROOT}:" \
- -e "s:\${CBUILD}:${CBUILD}:" \
- -e "s:\${ada_bootstrap}:${ada_bootstrap}:" \
- "${T}"/ada.spec || die
-
- # The Makefile tries to find libgnat by querying $(CC) which
- # won't work for us as the stage1 compiler doesn't necessarily
- # have Ada support. Substitute the Ada compiler we found earlier.
- local adalib
- adalib=$(${CBUILD}-gcc-${ada_bootstrap} -print-libgcc-file-name || die "Finding adalib dir failed")
- adalib="${adalib%/*}/adalib"
- sed -i \
- -e "s:adalib=.*:adalib=${adalib}:" \
- "${S}"/gcc/ada/gcc-interface/Make-lang.in || die
-
- # Create bin wrappers because not all of the build system
- # respects GNATBIND or GNATMAKE.
- mkdir "${T}"/ada-wrappers || die
- local tool
- for tool in gnat{,bind,chop,clean,kr,link,ls,make,name,prep} ; do
- cat <<-EOF > "${T}"/ada-wrappers/${tool} || die
- #!/bin/bash
+ # Easier to substitute these values in rather than escape
+ # lots of bits above in heredoc.
+ sed -i \
+ -e "s:\${BROOT}:${BROOT}:" \
+ -e "s:\${CBUILD}:${CBUILD}:" \
+ -e "s:\${ada_bootstrap}:${ada_bootstrap}:" \
+ "${T}"/ada.spec || die
+
+ # The Makefile tries to find libgnat by querying $(CC) which
+ # won't work for us as the stage1 compiler doesn't necessarily
+ # have Ada support. Substitute the Ada compiler we found earlier.
+ local adalib
+ adalib=$(${CBUILD}-gcc-${ada_bootstrap} -print-libgcc-file-name || die "Finding adalib dir failed")
+ adalib="${adalib%/*}/adalib"
+ sed -i \
+ -e "s:adalib=.*:adalib=${adalib}:" \
+ "${S}"/gcc/ada/gcc-interface/Make-lang.in || die
+
+ # Create bin wrappers because not all of the build system
+ # respects GNATBIND or GNATMAKE.
+ mkdir "${T}"/ada-wrappers || die
+ local tool
+ for tool in gnat{,bind,chop,clean,kr,link,ls,make,name,prep} ; do
+ cat <<-EOF > "${T}"/ada-wrappers/${tool} || die
+ #!/bin/sh
exec $(type -P ${CBUILD}-${tool}-${ada_bootstrap}) -specs=${T}/ada.spec "\$@"
EOF
- chmod +x "${T}"/ada-wrappers/${tool} || die
+ chmod +x "${T}"/ada-wrappers/${tool} || die
- export "${tool^^}"=${CBUILD}-${tool}-${ada_bootstrap}
- done
+ export "${tool^^}"=${CBUILD}-${tool}-${ada_bootstrap}
+ done
- export PATH="${T}/ada-wrappers:${PATH}"
- export CC="$(tc-getCC) -specs=${T}/ada.spec"
+ export PATH="${T}/ada-wrappers:${PATH}"
+ export CC="$(tc-getCC) -specs=${T}/ada.spec"
+}
+
+# @FUNCTION: toolchain_setup_d
+# @INTERNAL
+# @DESCRIPTION:
+# Determine the most suitable GDC (D compiler) for bootstrapping
+# and setup the environment for building.
+toolchain_setup_d() {
+ local latest_gcc=$(best_version -b "sys-devel/gcc")
+ latest_gcc="${latest_gcc#sys-devel/gcc-}"
+ latest_gcc=$(ver_cut 1 ${latest_gcc})
+
+ local d_bootstrap
+ local d_candidate
+ # We always prefer the version being built if possible
+ # as it has the greatest chance of success. Failing that,
+ # try GCC 10 and iterate upwards.
+ for d_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
+ has_version -b "sys-devel/gcc:${d_candidate}" || continue
+
+ ebegin "Testing sys-devel/gcc:${d_candidate} for D"
+ if has_version -b "sys-devel/gcc:${d_candidate}[d(-)]" ; then
+ d_bootstrap=${d_candidate}
+
+ eend 0
+ break
+ fi
+ eend 1
+ done
+
+ if [[ -n ${d_bootstrap} ]] ; then
+ export GDC="${BROOT}/usr/${CTARGET}/gcc-bin/${d_bootstrap}/gdc"
fi
+}
- if _tc_use_if_iuse d ; then
- local latest_gcc=$(best_version -b "sys-devel/gcc")
- latest_gcc="${latest_gcc#sys-devel/gcc-}"
- latest_gcc=$(ver_cut 1 ${latest_gcc})
+#---->> src_configure <<----
- local d_bootstrap
- local d_candidate
- # We always prefer the version being built if possible
- # as it has the greatest chance of success. Failing that,
- # try GCC 10 and iterate upwards.
- for d_candidate in ${SLOT} $(seq 10 ${latest_gcc}) ; do
- has_version -b "sys-devel/gcc:${d_candidate}" || continue
+toolchain_src_configure() {
+ BUILD_CONFIG_TARGETS=()
+ is-flagq '-O3' && BUILD_CONFIG_TARGETS+=( bootstrap-O3 )
- ebegin "Testing sys-devel/gcc:${d_candidate} for D"
- if has_version -b "sys-devel/gcc:${d_candidate}[d(-)]" ; then
- d_bootstrap=${d_candidate}
+ downgrade_arch_flags
+ gcc_do_filter_flags
- eend 0
- break
- fi
- eend 1
- done
+ if ! tc_version_is_at_least 11 && [[ $(gcc-major-version) -ge 12 ]] ; then
+ # https://gcc.gnu.org/PR105695 (bug #849359)
+ export ac_cv_std_swap_in_utility=no
+ fi
- if [[ -n ${d_bootstrap} ]] ; then
- export GDC="${BROOT}/usr/${CTARGET}/gcc-bin/${d_bootstrap}/gdc"
- fi
+ einfo "CFLAGS=\"${CFLAGS}\""
+ einfo "CXXFLAGS=\"${CXXFLAGS}\""
+ einfo "LDFLAGS=\"${LDFLAGS}\""
+
+ local confgcc=( --host=${CHOST} )
+
+ if is_crosscompile || tc-is-cross-compiler ; then
+ # Straight from the GCC install doc:
+ # "GCC has code to correctly determine the correct value for target
+ # for nearly all native systems. Therefore, we highly recommend you
+ # not provide a configure target when configuring a native compiler."
+ confgcc+=( --target=${CTARGET} )
fi
+ [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} )
confgcc+=(
--prefix="${PREFIX}"
@@ -1073,6 +1071,18 @@ toolchain_src_configure() {
is_modula2 && GCC_LANG+=",m2"
is_rust && GCC_LANG+=",rust"
+ _need_ada_bootstrap_mangling() {
+ if [[ ${CATEGORY}/${PN} == dev-lang/gnat-gpl ]] ; then
+ _tc_use_if_iuse system-bootstrap && return 0
+ return 1
+ fi
+
+ _tc_use_if_iuse ada
+ }
+
+ _need_ada_bootstrap_mangling && toolchain_setup_ada
+ _tc_use_if_iuse d && toolchain_setup_d
+
confgcc+=( --enable-languages=${GCC_LANG} )
### general options
@@ -1813,7 +1823,7 @@ gcc_do_filter_flags() {
declare -A l1_cache_sizes=()
# Workaround for inconsistent cache sizes on hybrid P/E cores
# See PR111768 (and bug #904426, bug #908523, and bug #915389)
- if [[ ${CBUILD} == @(x86_64|i?86)* ]] && [[ ${CFLAGS} == *-march=native* ]] && tc-is-gcc ; then
+ if [[ ${CBUILD} == @(x86_64|i?86)* ]] && [[ "${CFLAGS}${CXXFLAGS}" == *-march=native* ]] && tc-is-gcc ; then
local x
local l1_cache_size
# Iterate over all cores and find their L1 cache size
@@ -2023,13 +2033,25 @@ gcc_do_make() {
# We only want to use the system's CFLAGS if not building a
# cross-compiler.
STAGE1_CFLAGS=${STAGE1_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
+ # multilib.eclass lacks get_abi_CXXFLAGS (bug #940501)
+ STAGE1_CXXFLAGS=${STAGE1_CXXFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CXXFLAGS}"}
STAGE1_LDFLAGS=${STAGE1_LDFLAGS-"${abi_ldflags} ${LDFLAGS}"}
BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}
BOOT_LDFLAGS=${BOOT_LDFLAGS-"${abi_ldflags} ${LDFLAGS}"}
LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}"
+ # If we need to in future, we could really simplify this
+ # to just be unconditional for stage1. It doesn't really
+ # matter there. If we want to go in the other direction
+ # and make this more conditional, we could check if
+ # the bootstrap compiler is < GCC 12. See bug #940470.
+ if _tc_use_if_iuse d && use hardened ; then
+ STAGE1_CXXFLAGS+=" -U_GLIBCXX_ASSERTIONS"
+ fi
+
emakeargs+=(
STAGE1_CFLAGS="${STAGE1_CFLAGS}"
+ STAGE1_CXXFLAGS="${STAGE1_CXXFLAGS}"
STAGE1_LDFLAGS="${STAGE1_LDFLAGS}"
BOOT_CFLAGS="${BOOT_CFLAGS}"
BOOT_LDFLAGS="${BOOT_LDFLAGS}"