commit:     1ebd639ccc8605f3e69b5973788101264902559e
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 22 22:29:39 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Dec 22 22:29:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=1ebd639c

crossdev: refuse to install crossdev on all CHOST ABIs, not just default

In bug #500338 attempt to install toolchain for secondary ABY (x86 on amd64
system) clobbered native tools with tools that target 
--systroot=/usr/${CTARGET}.

That is never an intended state. Block all CHOSTs and suggest using
sys-devel/multilib-gcc-wrapper for distcc-like workloads.

Bug: https://bugs.gentoo.org/500338
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 crossdev | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/crossdev b/crossdev
index cec8170..b0c44c5 100755
--- a/crossdev
+++ b/crossdev
@@ -486,6 +486,7 @@ show_repo_cfg() {
 setup_portage_vars() {
        local arch=${ARCH} arch_set=${ARCH+set}
        local chost=${CHOST} chost_set=${CHOST+set}
+       local abi
        unset ARCH CHOST
        eval $(portageq envvar -v PORT_LOGDIR PORTAGE_TMPDIR ARCH CHOST)
        parse_repo_config
@@ -496,6 +497,17 @@ setup_portage_vars() {
        HCHOST=${CHOST}
        [[ ${chost_set} == "set" ]] && CHOST=${chost} || unset CHOST
 
+       # Collect all CHOST* visible for for host. We need to make sure
+       # not to clobber any of native CHOSTs.
+       HCHOSTS=(${HCHOST})
+       for abi in $(portageq envvar ABI MULTILIB_ABIS DEFAULT_ABI); do
+               HCHOSTS+=($(portageq envvar CHOST_${abi}))
+       done
+       # uniq
+       HCHOSTS=(
+               $(printf "%s\n" "${HCHOSTS[@]}" | sort -u)
+       )
+
        # see if user told us where to write things, otherwise
        # set up some repos.conf magic if possible.  if not,
        # install our stuff to the first overlay in the list.
@@ -682,6 +694,7 @@ UOPTS=
 TARCH=
 HARCH=
 HCHOST=
+HCHOSTS=()
 CTARGET=
 MULTILIB_ABIS="default"
 MULTILIB_USE=""
@@ -844,6 +857,15 @@ if [[ ${HCHOST} == "${CTARGET}" ]] ; then
        exit 1
 fi
 
+for hchost in "${HCHOSTS[@]}"; do
+       if [[ ${hchost} == "${CTARGET}" ]] ; then
+               eerror "Refusing to create a cross-compiler using the same"
+               eerror "target name as your host utils."
+               eerror "Consider using sys-devel/multilib-gcc-wrapper package."
+               exit 1
+       fi
+done
+
 # grab user settings
 d="${CONFIGROOT}/crossdev/${CTARGET}"
 for v in MULTILIB_ABIS USE BVER GVER KVER LVER STAGE CFLAGS LDFLAGS ASFLAGS ; 
do
@@ -935,7 +957,7 @@ info() {
 hr -
 einfo "crossdev version:      ${CROSSDEV_VER}"
 einfo "Host Portage ARCH:     ${HARCH}"
-einfo "Host Portage System:   ${HCHOST}"
+einfo "Host Portage System:   ${HCHOST} (${HCHOSTS[*]})"
 einfo "Target Portage ARCH:   ${TARCH}"
 einfo "Target System:         ${CTARGET}"
 einfo "Stage:                 ${STAGE} (${STAGE_DISP[${STAGE}]})"

Reply via email to