diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 45e82494a8..af6ace6787 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -153,6 +153,8 @@ emerge_to_image() { # Make sure profile.env has been generated sudo -E ROOT="${root_fs_dir}" env-update --no-ldconfig + fixup_liblto_softlinks "$root_fs_dir" + # TODO(marineam): just call ${BUILD_LIBRARY_DIR}/check_root directly once # all tests are fatal, for now let the old function skip soname errors. ROOT="${root_fs_dir}" PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \ diff --git a/build_packages b/build_packages index 7933ec8c9f..df822efbd3 100755 --- a/build_packages +++ b/build_packages @@ -252,6 +252,8 @@ fi eclean-$BOARD -d packages +fixup_liblto_softlinks "${BOARD_ROOT}" + info "Checking build root" test_image_content "${BOARD_ROOT}" diff --git a/common.sh b/common.sh index 23509f7945..014b257307 100644 --- a/common.sh +++ b/common.sh @@ -966,3 +966,23 @@ clean_qemu_static() { *) die "Unsupported arch" ;; esac } + +# Fix up liblto softlink created by gcc-config +fixup_liblto_softlinks() { + local root="$1" + + info "fixup_liblto_softlinks: Looking for broken softlinks in '${root}'" + + local link + local target + # check both native (/usr/CHOST/) as well as cross compile (/usr/CHOST/CTARGET) paths + { ls -l "${root}/"usr/*/binutils-bin/lib/bfd-plugins/liblto_plugin.so 2>/dev/null; + ls -l "${root}/"usr/*/*/binutils-bin/lib/bfd-plugins/liblto_plugin.so 2>/dev/null; } \ + | sed 's:.* \([^[:space:]]\+\) -> \([^[:space:]]\+\):\1 \2:' \ + | while read link target; do + local newtarget=$(echo "$target" | sed "s:${root}:/:") + info " Fixing up broken $link -> $target" + info " sudo ln -sf $newtarget $link" + sudo ln -sf $newtarget $link + done +}