Using the brace expression {ld.so,lld} in the find command results
in musl's lld being printed, but still returns an error code due to the
lack of glibc's ld.so. See the mentioned bug.

Also, usage of find is not really needed there, since we want to simply
check the existence of paths and there is no need for a recursive check.

Fix that by using a simple [[ -L ]] check.

Bug: https://bugs.gentoo.org/969092
Signed-off-by: Michal Rostecki <[email protected]>
---
 eclass/sysroot.eclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
index f17d6bcec2b4..5ce3a1076704 100644
--- a/eclass/sysroot.eclass
+++ b/eclass/sysroot.eclass
@@ -83,7 +83,14 @@ sysroot_make_run_prefixed() {
        if [[ ${QEMU_ARCH} == $(qemu_arch "${CBUILD}") ]]; then
                # glibc: ld.so is a symlink, ldd is a binary.
                # musl: ld.so doesn't exist, ldd is a symlink.
-               local DLINKER=$(find "${MYEROOT}"/usr/bin/{ld.so,ldd} -type l 
-print -quit 2>/dev/null || die "failed to find dynamic linker")
+               local DLINKER candidate
+               for candidate in "${MYEROOT}"/usr/bin/ld.so 
"${MYEROOT}"/usr/bin/ldd; do
+                       if [[ -L ${candidate} ]]; then
+                               DLINKER=${candidate}
+                               break
+                       fi
+               done
+               [[ -n ${DLINKER} ]] || die "failed to find dynamic linker"
 
                # musl symlinks ldd to ld-musl.so to libc.so. We want the 
ld-musl.so
                # path, not the libc.so path, so don't resolve the symlinks 
entirely.
-- 
2.52.0



Reply via email to