James Le Cuirot <[email protected]> writes:

> 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.

I'm still not 100% sure Meson is right here but I also don't have a
better suggestion, and you could argue its behaviour is good in that it
diagnoses a broken wrapper ASAP rather than possibly hours into a build
of many packages :/

>
> Don't bother doing this for the native case, as this should always work.

Reviewed-by: Sam James <[email protected]>

>
> Closes: https://bugs.gentoo.org/969083
> Signed-off-by: James Le Cuirot <[email protected]>
> ---
>  eclass/sysroot.eclass | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
> index 5775e409da024..0fae642bf593c 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}"

Attachment: signature.asc
Description: PGP signature

Reply via email to