From 3f3b2f2e8c03df01418600db8db4a29b4ce4493d Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 5 Aug 2015 14:22:04 -0700 Subject: [PATCH] build_image: Run ldconfig in qemu ldconfig does not work for non-native arches. Create a new build_image routine run_ldconfig that uses qemu user emulation to run the board ldconfig on the board rootfs when the board and SDK arches are different. See: http://code.google.com/p/chromium/issues/detail?id=378377 Prior to calling run_ldconfig the board rootfs must have ldconfig installed. To arrange this move the call of run_ldconfig to after the base package install. Fixes build_image errors like these when building for arm64: /sbin/ldconfig: /lib64/libXXX is for unknown machine 183. Signed-off-by: Geoff Levand --- build_library/build_image_util.sh | 19 +++++++++++++++++-- build_library/dev_image_util.sh | 1 + build_library/prod_image_util.sh | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index dc331f632f..f838b83337 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -93,6 +93,21 @@ generate_update() { upload_image -d "${update}.DIGESTS" "${update}".{bin,gz,zip} } +# ldconfig cannot generate caches for non-native arches. +# Use qemu & the native ldconfig to work around that. +# http://code.google.com/p/chromium/issues/detail?id=378377 +run_ldconfig() { + local root_fs_dir=$1 + case ${ARCH} in + arm64) + sudo qemu-aarch64 "${root_fs_dir}"/usr/sbin/ldconfig -r "${root_fs_dir}";; + x86|amd64) + sudo ldconfig -r "${root_fs_dir}";; + *) + die "Unable to run ldconfig for ARCH ${ARCH}" + esac +} + # Basic command to emerge binary packages into the target image. # Arguments to this command are passed as addition options/arguments # to the basic emerge command. @@ -103,8 +118,8 @@ emerge_to_image() { PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \ emerge --root-deps=rdeps --usepkgonly --jobs=$FLAGS_jobs -v "$@" - # Make sure profile.env and ld.so.cache has been generated - sudo -E ROOT="${root_fs_dir}" env-update + # Make sure profile.env has been generated + sudo -E ROOT="${root_fs_dir}" env-update --no-ldconfig # TODO(marineam): just call ${BUILD_LIBRARY_DIR}/check_root directly once # all tests are fatal, for now let the old function skip soname errors. diff --git a/build_library/dev_image_util.sh b/build_library/dev_image_util.sh index 94dbd4076b..38a28edfb4 100755 --- a/build_library/dev_image_util.sh +++ b/build_library/dev_image_util.sh @@ -96,6 +96,7 @@ create_dev_image() { set_image_profile dev emerge_to_image "${root_fs_dir}" @system ${base_pkg} + run_ldconfig "${root_fs_dir}" write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}" write_licenses "${root_fs_dir}" "${BUILD_DIR}/${image_licenses}" diff --git a/build_library/prod_image_util.sh b/build_library/prod_image_util.sh index c7d68a26c3..9193e62355 100755 --- a/build_library/prod_image_util.sh +++ b/build_library/prod_image_util.sh @@ -47,6 +47,7 @@ create_prod_image() { set_image_profile prod extract_prod_gcc "${root_fs_dir}" emerge_to_image "${root_fs_dir}" "${base_pkg}" + run_ldconfig "${root_fs_dir}" write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}" write_licenses "${root_fs_dir}" "${BUILD_DIR}/${image_licenses}" extract_docs "${root_fs_dir}"