diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index d99eca9d26..c0512bcfe6 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -396,19 +396,15 @@ sudo sh -c "echo STAGE3=$STAGE3 > $CHROOT_STATE" info "Updating portage" early_enter_chroot emerge -uNv --quiet portage -info "Updating toolchain" -early_enter_chroot emerge -uNv --quiet $USEPKG '>=sys-devel/gcc-4.4' \ - sys-libs/glibc sys-devel/binutils sys-kernel/linux-headers - -# HACK: Select the latest toolchain. We're assuming that when this is -# ran, the chroot has no experimental versions of new toolchains, just -# one that is very old, and one that was just emerged. -GCC_ATOM="$(early_enter_chroot portageq best_version / sys-devel/gcc)" -early_enter_chroot emerge --unmerge "<${GCC_ATOM}" -CHOST="$(early_enter_chroot portageq envvar CHOST)" -LATEST="$(early_enter_chroot gcc-config -l | grep "${CHOST}" | tail -n1 | \ - cut -f3 -d' ')" -early_enter_chroot gcc-config "${LATEST}" +info "Updating host toolchain" +early_enter_chroot emerge -uNv --quiet crossdev +TOOLCHAIN_ARGS=( --deleteold ) +if [[ ${FLAGS_usepkg} -eq ${FLAGS_FALSE} ]]; then + TOOLCHAIN_ARGS+=( --nousepkg ) +fi +# Note: early_enter_chroot executes as root. +early_enter_chroot "${CHROOT_TRUNK}/chromite/bin/cros_setup_toolchains" \ + --hostonly "${TOOLCHAIN_ARGS[@]}" # dhcpcd is included in 'world' by the stage3 that we pull in for some reason. # We have no need to install it in our host environment, so pull it out here. @@ -427,8 +423,10 @@ if [ -n "${INITIALIZE_CHROOT}" ]; then fi # Update chroot. -UPDATE_ARGS=() -if [[ $FLAGS_usepkg -eq $FLAGS_TRUE ]]; then +# Skip toolchain update because it already happened above, and the chroot is +# not ready to emerge all cross toolchains. +UPDATE_ARGS=( --skip_toolchain_update ) +if [[ ${FLAGS_usepkg} -eq ${FLAGS_TRUE} ]]; then UPDATE_ARGS+=( --usepkg ) else UPDATE_ARGS+=( --nousepkg ) @@ -448,6 +446,11 @@ if [[ "$FLAGS_chroot" != "$DEFAULT_CHROOT_DIR" ]]; then CHROOT_EXAMPLE_OPT="--chroot=$FLAGS_chroot" fi +# As a final pass, build all desired cross-toolchains. +info "Updating toolchains" +enter_chroot sudo "${CHROOT_TRUNK}/chromite/bin/cros_setup_toolchains" \ + "${TOOLCHAIN_ARGS[@]}" + print_time_elapsed cat < /dev/null; then - LATEST=$(gcc-config -l | awk -v chost="${CHOST}" '$2 ~ chost { print $2 }' | \ - sort -V | tail -n 1 ) - sudo -E gcc-config "${LATEST}" +if [ "${FLAGS_skip_toolchain_update}" -eq "${FLAGS_FALSE}" ]; then + TOOLCHAIN_FLAGS="" + # This should really only be skipped while bootstrapping. + if [ "${FLAGS_usepkg}" -eq "${FLAGS_FALSE}" ]; then + TOOLCHAIN_FLAGS="--nousepkg" + fi + # Expand the path before sudo, as root doesn't have the same path magic. + sudo $(type -p cros_setup_toolchains) ${TOOLCHAIN_FLAGS} fi # Second pass, update everything else.