diff options
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/Manifest.gz | bin | 39738 -> 39744 bytes | |||
-rw-r--r-- | eclass/toolchain.eclass | 189 |
2 files changed, 173 insertions, 16 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex c04c549024ab..81fc2a69d2e5 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 53b64a470e37..138925777dd6 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -401,8 +401,6 @@ if tc_has_feature valgrind ; then BDEPEND+=" valgrind? ( dev-debug/valgrind )" fi -# TODO: Add a pkg_setup & pkg_pretend check for whether the active compiler -# supports Ada. if [[ ${PN} != gnat-gpl ]] && tc_has_feature ada ; then BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )" fi @@ -558,6 +556,8 @@ SRC_URI=$(get_gcc_src_uri) toolchain_pkg_pretend() { if ! _tc_use_if_iuse cxx ; then + _tc_use_if_iuse ada && \ + ewarn 'Ada requires a C++ compiler, disabled due to USE="-cxx"' _tc_use_if_iuse go && \ ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"' _tc_use_if_iuse objc++ && \ @@ -854,6 +854,171 @@ toolchain_src_configure() { fi [[ -n ${CBUILD} ]] && confgcc+=( --build=${CBUILD} ) + _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 + } + + 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 + 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 + + # 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!" + + #einfo "Using bootstrap GNAT compiler..." + #export PATH="${BROOT}/opt/ada-bootstrap-${GCCMAJOR}/bin:${PATH}" + fi + + cat <<-"EOF" > "${T}"/ada.spec || die + # Extracted from gcc/ada/gcc-interface/lang-specs.h + .adb: + @ada + + .ads: + @ada + + # TODO: ADA_DUMPS_OPTIONS + @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} \ + %{nostdinc*} %{nostdlib*} \ + %{fcompare-debug-second:-gnatd_A} \ + %{O*} %{W*} %{w} %{p} %{pg:-p} \ + %{coverage:-fprofile-arcs -ftest-coverage} \ + %{Wall:-gnatwa} %{Werror:-gnatwe} %{w:-gnatws} \ + %{gnatea:-gnatez} %{g*&m*&f*} \ + %1 %{!S:%{o*:%w%*-gnatO}} \ + %i %{S:%W{o*}%{!o*:-o %w%b.s}} \ + %{gnatc*|gnats*: -o %j} %{-param*} \ + %{!gnatc*:%{!gnats*:%(invoke_as)}} + + @adawhy: + %{!c:%e-c required for gnat2why} \ + gnat1why %{I*} %{k8:-gnatk8} %{!Q:-quiet} \ + %{nostdinc*} %{nostdlib*} \ + %{a} \ + %{gnatea:-gnatez} %{g*&m*&f*} \ + %1 %{o*:%w%*-gnatO} \ + %i \ + %{gnatc*|gnats*: -o %j} %{-param*} + + @adascil: + %{!c:%e-c required for gnat2scil} \ + gnat1scil %{I*} %{k8:-gnatk8} %{!Q:-quiet} \ + %{nostdinc*} %{nostdlib*} \ + %{a} \ + %{gnatea:-gnatez} %{g*&m*&f*} \ + %1 %{o*:%w%*-gnatO} \ + %i \ + %{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 + exec $(type -P ${CBUILD}-${tool}-${ada_bootstrap}) -specs=${T}/ada.spec "\$@" + EOF + chmod +x "${T}"/ada-wrappers/${tool} || die + + export "${tool^^}"=${CBUILD}-${tool}-${ada_bootstrap} + done + + export PATH="${T}/ada-wrappers:${PATH}" + export CC="$(tc-getCC) -specs=${T}/ada.spec" + 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}) + + 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 + fi + confgcc+=( --prefix="${PREFIX}" --bindir="${BINPATH}" @@ -1309,7 +1474,7 @@ toolchain_src_configure() { fi if in_iuse ada ; then - confgcc+=( --disable-libada ) + confgcc+=( $(use_enable ada libada) ) fi if in_iuse cet ; then @@ -1438,6 +1603,10 @@ toolchain_src_configure() { einfo "DATAPATH: ${DATAPATH}" einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" einfo "Languages: ${GCC_LANG}" + einfo "GCC version: $($(tc-getCC) -v 2>&1 | grep ' version ' | awk '{ print $3 }')" + is_ada && einfo "GNAT version: $(${GNAT} 2>&1 | grep GNAT | awk '{ print $2 }')" + is_d && einfo "GDC version: $(${GDC} -v 2>&1 | grep ' version ' | awk '{ print $3 }')" + echo # Build in a separate build tree @@ -1878,18 +2047,6 @@ gcc_do_make() { pushd "${WORKDIR}"/build >/dev/null || die emake "${emakeargs[@]}" ${GCC_MAKE_TARGET} - if is_ada; then - # Without these links, it is not getting the good compiler - # TODO: Need to check why - ln -s gcc ../build/prev-gcc || die - ln -s ${CHOST} ../build/prev-${CHOST} || die - - # Building standard ada library - emake -C gcc gnatlib-shared - # Building gnat toold - emake -C gcc gnattools - fi - if ! is_crosscompile && _tc_use_if_iuse cxx && _tc_use_if_iuse doc ; then if type -p doxygen > /dev/null ; then cd "${CTARGET}"/libstdc++-v3/doc || die @@ -2150,7 +2307,7 @@ toolchain_src_install() { cd "${D}"${BINPATH} || die # Ugh: we really need to auto-detect this list. # It's constantly out of date. - for x in cpp gcc gccrs g++ c++ gcov g77 gfortran gccgo gnat* ; do + for x in cpp gcc gccrs g++ c++ gcov gdc g77 gfortran gccgo gnat* ; do # For some reason, g77 gets made instead of ${CTARGET}-g77... # this should take care of that if [[ -f ${x} ]] ; then |