summaryrefslogtreecommitdiff
path: root/eclass/toolchain.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r--eclass/toolchain.eclass122
1 files changed, 91 insertions, 31 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 939c68113188..6a816a66275d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -402,7 +402,16 @@ if tc_has_feature valgrind ; then
fi
if [[ ${PN} != gnat-gpl ]] && tc_has_feature ada ; then
- BDEPEND+=" ada? ( || ( sys-devel/gcc:${SLOT}[ada] <sys-devel/gcc-${SLOT}[ada] dev-lang/gnat-gpl[ada] ) )"
+ BDEPEND+="
+ ada? (
+ || (
+ sys-devel/gcc:${SLOT}[ada]
+ <sys-devel/gcc-${SLOT}[ada]
+ <dev-lang/ada-bootstrap-${SLOT}
+ dev-lang/gnat-gpl[ada]
+ )
+ )
+ "
fi
# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler
@@ -831,6 +840,7 @@ toolchain_setup_ada() {
local ada_bootstrap
local ada_candidate
+ local ada_bootstrap_type
# GNAT can usually be built using the last major version and
# the current version, at least.
#
@@ -843,6 +853,7 @@ toolchain_setup_ada() {
ebegin "Testing sys-devel/gcc:${ada_candidate} for Ada"
if has_version -b "sys-devel/gcc:${ada_candidate}[ada(-)]" ; then
ada_bootstrap=${ada_candidate}
+ ada_bootstrap_type=gcc
eend 0
break
@@ -850,12 +861,30 @@ toolchain_setup_ada() {
eend 1
done
- # As a last resort, use dev-lang/gnat-gpl.
- # TODO: Make gnat-gpl coinstallable with gcc:10 (bug #940471).
+ # As a penultimate resort, try dev-lang/ada-bootstrap.
if ver_test ${ada_bootstrap} -gt ${PV} || [[ -z ${ada_bootstrap} ]] ; then
- ebegin "Testing dev-lang/gnat-gpl for Ada"
+ ebegin "Testing fallback dev-lang/ada-bootstrap for Ada"
+ if has_version -b "<dev-lang/ada-bootstrap-${SLOT}" ; then
+ # TODO: Figure out ada-bootstrap versioning/slots
+
+ #local latest_ada_bootstrap=$(best_version -b "<dev-lang/ada-bootstrap-${SLOT}")
+ #latest_ada_bootstrap="${latest_ada_bootstrap#dev-lang/ada-bootstrap-}"
+ #latest_ada_bootstrap=$(ver_cut 1 ${latest_ada_bootstrap})
+ ada_bootstrap="10"
+ ada_bootstrap_type=ada-bootstrap
+
+ eend 0
+ else
+ eend 1
+ fi
+ fi
+
+ # As a last resort, try dev-lang/gnat-gpl.
+ if ver_test ${ada_bootstrap} -gt ${PV} || [[ -z ${ada_bootstrap} ]] ; then
+ ebegin "Testing fallback dev-lang/gnat-gpl for Ada"
if has_version -b "dev-lang/gnat-gpl" ; then
ada_bootstrap=10
+ ada_bootstrap_type=gcc
eend 0
else
eend 1
@@ -866,12 +895,9 @@ toolchain_setup_ada() {
# 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 "Please try installing dev-lang/ada-bootstrap or failing that, 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}"
+ die "Couldn't find an Ada bootstrap compiler!"
fi
cat <<-"EOF" > "${T}"/ada.spec || die
@@ -886,7 +912,7 @@ toolchain_setup_ada() {
@ada:
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} \
%{!S:%{!c:%e-c or -S required for Ada}} \
- ${BROOT}/usr/libexec/gcc/${CBUILD}/${ada_bootstrap}/gnat1 %{I*} %{k8:-gnatk8} %{!Q:-quiet} \
+ ${gnat1_path} %{I*} %{k8:-gnatk8} %{!Q:-quiet} \
%{nostdinc*} %{nostdlib*} \
%{fcompare-debug-second:-gnatd_A} \
%{O*} %{W*} %{w} %{p} %{pg:-p} \
@@ -919,17 +945,29 @@ toolchain_setup_ada() {
%{gnatc*|gnats*: -o %j} %{-param*}
EOF
- # Easier to substitute these values in rather than escape
- # lots of bits above in heredoc.
+ old_path="${PATH}"
+ case ${ada_bootstrap_type} in
+ ada-bootstrap)
+ export PATH="${BROOT}/usr/lib/ada-bootstrap/bin:${PATH}"
+ gnat1_path=${BROOT}/usr/lib/ada-bootstrap/libexec/gcc/${CBUILD}/${ada_bootstrap}/gnat1
+ ;;
+ *)
+ gnat1_path=${BROOT}/usr/libexec/gcc/${CBUILD}/${ada_bootstrap}/gnat1
+ ;;
+ esac
+
+ # Easier to substitute these values in rather than escape lots of
+ # bits above in the heredoc.
sed -i \
-e "s:\${BROOT}:${BROOT}:" \
-e "s:\${CBUILD}:${CBUILD}:" \
+ -e "s:\${gnat1_path}:${gnat1_path}:" \
-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.
+ # 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"
@@ -937,21 +975,21 @@ toolchain_setup_ada() {
-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.
+ # 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
+ #!/bin/sh
+ exec $(type -P ${CBUILD}-${tool}-${ada_bootstrap}) "\$@"
+ EOF
- export "${tool^^}"=${CBUILD}-${tool}-${ada_bootstrap}
+ export "${tool^^}"="${T}"/ada-wrappers/${tool}
done
+ chmod +x "${T}"/ada-wrappers/gnat{,bind,chop,clean,kr,link,ls,make,name,prep} || die
- export PATH="${T}/ada-wrappers:${PATH}"
+ export PATH="${T}/ada-wrappers:${old_path}"
export CC="$(tc-getCC) -specs=${T}/ada.spec"
}
@@ -1488,10 +1526,20 @@ toolchain_src_configure() {
fi
if in_iuse cet ; then
- if [[ ${CTARGET} == i[[34567]]86-*-linux* || ${CTARGET} == x86_64-*-gnu* ]] ; then
- confgcc+=( $(use_enable cet) )
- fi
- [[ ${CTARGET} == aarch64-*-gnu* ]] && confgcc+=( $(use_enable cet standard-branch-protection) )
+ # Usage: triple_arch triple_env cet_name
+ enable_cet_for() {
+ if [[ ${CTARGET} == ${1}-* ]] ; then
+ if use cet && [[ ${CTARGET} == *-${2}* ]]; then
+ confgcc+=( --enable-${3} )
+ else
+ confgcc+=( --disable-${3} )
+ fi
+ fi
+ }
+
+ enable_cet_for 'i[34567]86' 'linux' 'cet'
+ enable_cet_for 'x86_64' 'gnu' 'cet'
+ enable_cet_for 'aarch64' 'gnu' 'standard-branch-protection'
fi
if in_iuse systemtap ; then
@@ -2028,6 +2076,14 @@ gcc_do_make() {
# using not-O0 is just a build-time speed improvement anyway.
if ! tc-is-gcc || ver_test $(gcc-fullversion) -lt 10 ; then
STAGE1_CFLAGS="-O0"
+ STAGE1_CXXFLAGS="-O0"
+ # We have a very good host compiler but it may be a bit too good, and
+ # know about flags that the version we are compiling does not know
+ # about. In principle we could check e.g. which gnat1 we are using as
+ # a bootstrap. It's simpler to do it unconditionally for now.
+ elif _tc_use_if_iuse ada || _tc_use_if_iuse d; then
+ STAGE1_CFLAGS="-O2"
+ STAGE1_CXXFLAGS="-O2"
fi
# We only want to use the system's CFLAGS if not building a
@@ -2123,8 +2179,10 @@ toolchain_src_test() {
(
# Workaround our -Wformat-security default which breaks
# various tests as it adds unexpected warning output.
- GCC_TESTS_CFLAGS+=" -Wno-format-security -Wno-format"
- GCC_TESTS_CXXFLAGS+=" -Wno-format-security -Wno-format"
+ if tc_version_is_at_least 13 ; then
+ GCC_TESTS_CFLAGS+=" -Wno-format-security -Wno-format"
+ GCC_TESTS_CXXFLAGS+=" -Wno-format-security -Wno-format"
+ fi
# Workaround our -Wtrampolines default which breaks
# tests too.
@@ -2134,8 +2192,10 @@ toolchain_src_test() {
GCC_TESTS_LDFLAGS+=" -Wl,--no-warn-execstack"
# Avoid confusing tests like Fortran/C interop ones where
# CFLAGS are used.
- GCC_TESTS_CFLAGS+=" -Wno-complain-wrong-lang"
- GCC_TESTS_CXXFLAGS+=" -Wno-complain-wrong-lang"
+ if tc_version_is_at_least 13 ; then
+ GCC_TESTS_CFLAGS+=" -Wno-complain-wrong-lang"
+ GCC_TESTS_CXXFLAGS+=" -Wno-complain-wrong-lang"
+ fi
# Issues with Ada tests:
# gnat.dg/align_max.adb