commit: bcfddee58e1f43f7e7bd3507b269f166d4db6aa8 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org> AuthorDate: Sun Jan 25 14:11:36 2026 +0000 Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org> CommitDate: Sun Feb 1 11:42:10 2026 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bcfddee5
sysroot.eclass: Sanity check the QEMU-based wrapper script Meson will fail if the given exe_wrapper does not work, regardless of whether one is actually needed. This is bad if QEMU is not installed and worse if QEMU does not support the architecture. We therefore need to perform our own test up front. Don't bother doing this for the native case, as this should always work. Closes: https://bugs.gentoo.org/969083 Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org> eclass/sysroot.eclass | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass index 5775e409da02..0fae642bf593 100644 --- a/eclass/sysroot.eclass +++ b/eclass/sysroot.eclass @@ -109,6 +109,19 @@ sysroot_make_run_prefixed() { #!/bin/sh QEMU_SET_ENV="\${QEMU_SET_ENV}\${QEMU_SET_ENV+,}LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}\${LD_LIBRARY_PATH+:}${LIBGCC}" QEMU_LD_PREFIX="${MYROOT}" exec $(type -P "qemu-${QEMU_ARCH}") "\${@}" EOF + + # Meson will fail if the given exe_wrapper does not work, regardless of + # whether one is actually needed. This is bad if QEMU is not installed + # and worse if QEMU does not support the architecture. We therefore need + # to perform our own test up front. + local test="${SCRIPT}-test" + echo 'int main(void) { return 0; }' > "${test}.c" || die "failed to write ${test##*/}" + $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} "${test}.c" -o "${test}" || die "failed to build ${test##*/}" + + if ! "${SCRIPT}" "${test}" &>/dev/null; then + einfo "Failed to run ${test##*/}. Continuing without ${SCRIPT##*/} wrapper." + return 1 + fi fi echo "${SCRIPT}"
