make_chroot: Install the build tools before toolchain updates.

libtool needs newer sandbox and is auto updated after GCC update.
Let's move the build of some important tools before the toolchain
update.

BUG=chromium:842316
TEST=libtool builds in chromiumos-sdk.

Change-Id: I413953e1c9b8adc1f65df74e6feb36e4f6df651d
Reviewed-on: https://chromium-review.googlesource.com/1056037
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh
index 0fcf367..4191dc8 100755
--- a/sdk_lib/make_chroot.sh
+++ b/sdk_lib/make_chroot.sh
@@ -606,9 +606,17 @@
 info "Updating ncurses"
 early_enter_chroot emerge -uNvq sys-libs/ncurses
 
-# The stage3 contains an old version of bison and glibc 2.26+ wants a newer one.
-info "Updating bison"
-early_enter_chroot emerge -uNvq sys-devel/bison
+# Update these packages early because they cause build failures when they're
+# concurrently emerged during the main update below.
+# Specific packages:
+#   sys-apps/sandbox upgrade breaks dev-libs/nss, also needed by newer libtool.
+#   sys-devel/patch 2.6 misapplies git patches in dev-embedded/coreboot-sdk.
+#   older sys-devel/automake makes media-libs/freetype build flaky.
+#   glibc 2.26+ needs a newer bison.
+info "Updating preinstalled build tools"
+early_enter_chroot ${EMERGE_CMD} -uNv ${USEPKG} --select ${EMERGE_JOBS} \
+  sys-apps/sandbox '>=sys-devel/patch-2.7' sys-devel/automake sys-devel/bison
+
 
 info "Updating host toolchain"
 if [[ ! -e "${FLAGS_chroot}/usr/bin/crossdev" ]]; then
@@ -637,16 +645,6 @@
     "${CHROOT_TRUNK_DIR}/src/scripts/run_chroot_version_hooks" --init_latest
 fi
 
-# Update these packages early because they cause build failures when they're
-# concurrently emerged during the main update below.
-# Specific packages:
-#   sys-apps/sandbox upgrade breaks dev-libs/nss.
-#   sys-devel/patch 2.6 misapplies git patches in dev-embedded/coreboot-sdk.
-#   older sys-devel/automake makes media-libs/freetype build flaky.
-info "Updating preinstalled build tools"
-early_enter_chroot ${EMERGE_CMD} -uNv ${USEPKG} --select ${EMERGE_JOBS} \
-  sys-apps/sandbox '>=sys-devel/patch-2.7' sys-devel/automake
-
 # Update chroot.
 # Skip toolchain update because it already happened above, and the chroot is
 # not ready to emerge all cross toolchains.