--- /usr/portage/dev-lang/rust/rust-1.60.0.ebuild 2022-04-08 22:09:51.000000000 +0100 +++ rust-1.60.0.ebuild 2022-05-04 13:33:54.356462331 +0100 @@ -246,8 +246,11 @@ src_prepare() { if ! use system-bootstrap; then local rust_stage0_root="${WORKDIR}"/rust-stage0 - local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" - + if [[ ${ABI} == x32 ]]; then + local rust_stage0="rust-${RUST_STAGE0_VERSION}-x86_64-unknown-linux-gnu" + else + local rust_stage0="rust-${RUST_STAGE0_VERSION}-$(rust_abi)" + fi "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig \ --without=rust-docs --destdir="${rust_stage0_root}" --prefix=/ || die fi @@ -300,7 +303,19 @@ # in case of prefix it will be already prefixed, as --print sysroot returns full path [[ -d ${rust_stage0_root} ]] || die "${rust_stage0_root} is not a directory" - rust_target="$(rust_abi)" + # If this is x32 but using 64 bit rust-bin then "Canadian + # cross-compile". + # This requires amd64 abi to bootstrap the build toolchain even if + # not enabled + if [[ ${ABI} == x32 ]] && \ + [[ $(rustc --print cfg | \ + awk -F= -v key="target_pointer_width" '$1==key {print $2}') == \"64\" ]]; then + CBUILD=x86_64-linux-linux-gnu + use abi_x86_64 || abis+=( amd64 ) + fi + rust_target="$(rust_abi ${CTARGET})" + rust_host="$(rust_abi ${CHOST})" + rust_build="$(rust_abi ${CBUILD})" cat <<- _EOF_ > "${S}"/config.toml changelog-seen = 2 @@ -325,8 +340,8 @@ build-stage = 2 test-stage = 2 doc-stage = 2 - build = "${rust_target}" - host = ["${rust_target}"] + build = "${rust_build}" + host = ["${rust_host}"] target = [${rust_targets}] cargo = "${rust_stage0_root}/bin/cargo" rustc = "${rust_stage0_root}/bin/rustc" @@ -386,6 +401,11 @@ compression-formats = ["xz"] _EOF_ + cat <<- _EOF_ >> "${S}"/config.env + PKG_CONFIG_ALLOW_CROSS=1 + CFG_COMPILER_HOST_TRIPLE=$(rust_abi $(get_abi_CHOST ${DEFAULT_ABI})) + _EOF_ + for v in $(multilib_get_enabled_abi_pairs); do rust_target=$(rust_abi $(get_abi_CHOST ${v##*.})) arch_cflags="$(get_abi_CFLAGS ${v##*.})" @@ -410,7 +430,8 @@ fi if use system-llvm; then cat <<- _EOF_ >> "${S}"/config.toml - llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config" + llvm-config = "$(get_llvm_prefix + "${LLVM_MAX_SLOT}")/bin/$(get_abi_CHOST ${v##*.})-llvm-config" _EOF_ fi done