On 1/25/26 6:01 PM, Sam James wrote:
> 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 :/


The particular failure here is that it tests whether the CHOST compiler
produces outputs that successfully run, so you may also consider it as
an early smoketest à la sys-libs/glibc `glibc_sanity_check() { ...; }`.

It is certainly right for meson, and debatable whether it's right for an
ebuild environment.


cross files can use:

```
[properties]
skip_sanity_check = true
```

However, defining a wrapper that doesn't work will mean
meson.can_run_host_binaries() will return false results and this will
break *other* packages doing user code checks.

So I still recommend this patch. ;)



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


Reviewed-by: Eli Schwartz <[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}"


-- 
Eli Schwartz

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to