From 14dc3ec7c8229ec20b67cdee4486d4566d2b96db Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Fri, 29 Nov 2019 08:07:11 +0100 Subject: [PATCH 1/2] build_library: make toolchain build rust for cross-builds To make packages-matrix build rust sources for arm64-usr, we need to make toolchain include the rust target for arm. Unfortunately, catalyst does not support the cross-build rust target by default. We also cannot add `dev-lang/rust` to `$TOOLCHAIN_PKGS`, because then catalyst would tries to build a `cross-*/rust` package, which does not exist. So we need to manually run emerge for rust, without `--newuse -u` options. If the `--newuse -u` options are given, the rust will not be installed at all. --- build_library/catalyst_toolchains.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build_library/catalyst_toolchains.sh b/build_library/catalyst_toolchains.sh index 2ab4c46dae..f5ef591e5f 100644 --- a/build_library/catalyst_toolchains.sh +++ b/build_library/catalyst_toolchains.sh @@ -35,6 +35,11 @@ build_target_toolchain() { # --root is required because run_merge overrides ROOT= PORTAGE_CONFIGROOT="$ROOT" \ run_merge -u --root="$ROOT" --sysroot="$ROOT" "${TOOLCHAIN_PKGS[@]}" + + export clst_myemergeopts="$( echo "$clst_myemergeopts" | sed -e 's/--newuse//' )" + + PORTAGE_CONFIGROOT="$ROOT" \ + run_merge --root="$ROOT" --sysroot="$ROOT" dev-lang/rust } configure_crossdev_overlay / /tmp/crossdev From e9565ef8a44c85439b344ee787ea2da42cb2bb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20L=C3=BCke?= Date: Mon, 2 Dec 2019 15:28:06 +0100 Subject: [PATCH 2/2] build_library/toolchain_util.sh: Install Rust from cross-compilation toolchain --- build_library/toolchain_util.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build_library/toolchain_util.sh b/build_library/toolchain_util.sh index 5ab2c6e470..0951d7d971 100644 --- a/build_library/toolchain_util.sh +++ b/build_library/toolchain_util.sh @@ -324,6 +324,15 @@ install_cross_toolchain() { else $sudo emerge "${emerge_flags[@]}" \ "cross-${cross_chost}/gdb" "${cross_pkgs[@]}" + if [ "${cross_chost}" = aarch64-cros-linux-gnu ]; then + # Here we need to take only the binary packages from the toolchain builds + # because the standard Rust packages don't include the arm64 cross target. + # Building from source is ok because the cross-compiler got installed. + FILTERED="$(echo $PORTAGE_BINHOST | tr ' ' '\n' | grep toolchain | xargs echo)" + # If no aarch64 folder exists, try to remove any existing Rust packages. + [ ! -d /usr/lib/rust-*/rustlib/aarch64-unknown-linux-gnu ] && ($sudo emerge -C dev-lang/rust || true) + $sudo PORTAGE_BINHOST="$FILTERED" emerge "${emerge_flags[@]}" dev-lang/rust + fi fi # Setup environment and wrappers for our shiny new toolchain