make_chroot: install jq before building libcxx and libunwind

BUG=b/591306694
TEST=presubmit
RELEASE_NOTE=None

Change-Id: Icce4482ef540410a422f2c995a2ce124da0ec742
Reviewed-on: https://cos-review.googlesource.com/c/third_party/platform/crosutils/+/245788
Reviewed-by: Jimmy Chen <yinjie@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh
index 5c8adcf..b424e0e 100755
--- a/sdk_lib/make_chroot.sh
+++ b/sdk_lib/make_chroot.sh
@@ -239,6 +239,13 @@
   early_enter_chroot ${EMERGE_CMD} -uNv ${USEPKG} ${USEPKGONLY} ${EMERGE_JOBS} \
     sys-kernel/linux-headers sys-libs/glibc
 
+  # cros-workon.eclass runs jq while unpacking. jq is only a BDEPEND, which
+  # the --nodeps emerge below does not install, and the SDK does not ship it.
+  # Install it first so libcxx and libunwind can be built from source when the
+  # SDK binhost has no matching binpkgs (e.g. after an LLVM upgrade).
+  early_enter_chroot ${EMERGE_CMD} -uNv --oneshot ${USEPKG} ${EMERGE_JOBS} \
+    app-misc/jq
+
   # Next libcxx and libunwind. This is required due to the migration to LLVM
   # runtime builds.
   early_enter_chroot ${EMERGE_CMD} -uN --nodeps ${USEPKG} \