[PATCH-for-10.2 2/2] tcg/tci: Disable Int128 support

Philippe Mathieu-Daudé posted 2 patches 1 week, 4 days ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
[PATCH-for-10.2 2/2] tcg/tci: Disable Int128 support
Posted by Philippe Mathieu-Daudé 1 week, 4 days ago
Disable Int128 on TCI, otherwise build fails:

  In file included from ../../tcg/optimize.c:29:
  In file included from include/tcg/tcg-op-common.h:12:
  In file included from include/exec/helper-proto-common.h:10:
  In file included from include/qemu/atomic128.h:62:
  In file included from host/include/aarch64/host/atomic128-cas.h.inc:16:
  host/include/generic/host/atomic128-cas.h.inc:37:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
     37 |     Int128 old = *ptr_align;
        |            ^     ~~~~~~~~~~
  host/include/generic/host/atomic128-cas.h.inc:39:52: warning: incompatible pointer types passing 'Int128 *' (aka 'struct Int128 *') to parameter of type '__int128_t *' (aka '__int128 *') [-Wincompatible-pointer-types]
     39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
        |                                                    ^~~~
  host/include/generic/host/atomic128-cas.h.inc:39:58: error: passing 'Int128' (aka 'struct Int128') to parameter of incompatible type '__int128_t' (aka '__int128')
     39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
        |                                                          ^~~
  host/include/generic/host/atomic128-cas.h.inc:50:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
     50 |     Int128 old = *ptr_align;
        |            ^     ~~~~~~~~~~
  host/include/generic/host/atomic128-cas.h.inc:52:62: error: invalid operands to binary expression ('Int128' (aka 'struct Int128') and 'Int128')
     52 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old & val, true,
        |                                                          ~~~ ^ ~~~
  host/include/generic/host/atomic128-cas.h.inc:63:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
     63 |     Int128 old = *ptr_align;
        |            ^     ~~~~~~~~~~
  host/include/generic/host/atomic128-cas.h.inc:65:62: error: invalid operands to binary expression ('Int128' (aka 'struct Int128') and 'Int128')
     65 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old | val, true,
        |                                                          ~~~ ^ ~~~
  1 warning and 6 errors generated.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index d9293294d8e..692a62e6c18 100644
--- a/meson.build
+++ b/meson.build
@@ -2996,7 +2996,7 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
 
 # has_int128_type is set to false on Emscripten to avoid errors by libffi
 # during runtime.
-has_int128_type = host_os != 'emscripten' and cc.compiles('''
+has_int128_type = host_os != 'emscripten' and tcg_arch != 'tci' and cc.compiles('''
   __int128_t a;
   __uint128_t b;
   int main(void) { b = a; }''')
-- 
2.51.0


Re: [PATCH-for-10.2 2/2] tcg/tci: Disable Int128 support
Posted by Richard Henderson 1 week, 4 days ago
On 12/2/25 10:46, Philippe Mathieu-Daudé wrote:
> Disable Int128 on TCI, otherwise build fails:
> 
>    In file included from ../../tcg/optimize.c:29:
>    In file included from include/tcg/tcg-op-common.h:12:
>    In file included from include/exec/helper-proto-common.h:10:
>    In file included from include/qemu/atomic128.h:62:
>    In file included from host/include/aarch64/host/atomic128-cas.h.inc:16:
>    host/include/generic/host/atomic128-cas.h.inc:37:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
>       37 |     Int128 old = *ptr_align;
>          |            ^     ~~~~~~~~~~
>    host/include/generic/host/atomic128-cas.h.inc:39:52: warning: incompatible pointer types passing 'Int128 *' (aka 'struct Int128 *') to parameter of type '__int128_t *' (aka '__int128 *') [-Wincompatible-pointer-types]
>       39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
>          |                                                    ^~~~
>    host/include/generic/host/atomic128-cas.h.inc:39:58: error: passing 'Int128' (aka 'struct Int128') to parameter of incompatible type '__int128_t' (aka '__int128')
>       39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
>          |                                                          ^~~
>    host/include/generic/host/atomic128-cas.h.inc:50:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
>       50 |     Int128 old = *ptr_align;
>          |            ^     ~~~~~~~~~~
>    host/include/generic/host/atomic128-cas.h.inc:52:62: error: invalid operands to binary expression ('Int128' (aka 'struct Int128') and 'Int128')
>       52 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old & val, true,
>          |                                                          ~~~ ^ ~~~
>    host/include/generic/host/atomic128-cas.h.inc:63:12: error: initializing 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka '__int128')
>       63 |     Int128 old = *ptr_align;
>          |            ^     ~~~~~~~~~~
>    host/include/generic/host/atomic128-cas.h.inc:65:62: error: invalid operands to binary expression ('Int128' (aka 'struct Int128') and 'Int128')
>       65 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old | val, true,
>          |                                                          ~~~ ^ ~~~
>    1 warning and 6 errors generated.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

And what of the CONFIG_TCG_INTERPRETER test that already exists in int128.h?

There's got to be more to this than that.


r~

> ---
>   meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index d9293294d8e..692a62e6c18 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2996,7 +2996,7 @@ config_host_data.set('CONFIG_ATOMIC64', cc.links('''
>   
>   # has_int128_type is set to false on Emscripten to avoid errors by libffi
>   # during runtime.
> -has_int128_type = host_os != 'emscripten' and cc.compiles('''
> +has_int128_type = host_os != 'emscripten' and tcg_arch != 'tci' and cc.compiles('''
>     __int128_t a;
>     __uint128_t b;
>     int main(void) { b = a; }''')


Re: [PATCH-for-10.2 2/2] tcg/tci: Disable Int128 support
Posted by Richard Henderson 1 week, 3 days ago
On 12/2/25 14:30, Richard Henderson wrote:
> On 12/2/25 10:46, Philippe Mathieu-Daudé wrote:
>> Disable Int128 on TCI, otherwise build fails:
>>
>>    In file included from ../../tcg/optimize.c:29:
>>    In file included from include/tcg/tcg-op-common.h:12:
>>    In file included from include/exec/helper-proto-common.h:10:
>>    In file included from include/qemu/atomic128.h:62:
>>    In file included from host/include/aarch64/host/atomic128-cas.h.inc:16:
>>    host/include/generic/host/atomic128-cas.h.inc:37:12: error: initializing 
>> 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka 
>> '__int128')
>>       37 |     Int128 old = *ptr_align;
>>          |            ^     ~~~~~~~~~~
>>    host/include/generic/host/atomic128-cas.h.inc:39:52: warning: incompatible pointer 
>> types passing 'Int128 *' (aka 'struct Int128 *') to parameter of type '__int128_t 
>> *' (aka '__int128 *') [-Wincompatible-pointer-types]
>>       39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
>>          |                                                    ^~~~
>>    host/include/generic/host/atomic128-cas.h.inc:39:58: error: passing 'Int128' (aka 
>> 'struct Int128') to parameter of incompatible type '__int128_t' (aka '__int128')
>>       39 |     while (!__atomic_compare_exchange_n(ptr_align, &old, new, true,
>>          |                                                          ^~~
>>    host/include/generic/host/atomic128-cas.h.inc:50:12: error: initializing 
>> 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka 
>> '__int128')
>>       50 |     Int128 old = *ptr_align;
>>          |            ^     ~~~~~~~~~~
>>    host/include/generic/host/atomic128-cas.h.inc:52:62: error: invalid operands to 
>> binary expression ('Int128' (aka 'struct Int128') and 'Int128')
>>       52 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old & val, true,
>>          |                                                          ~~~ ^ ~~~
>>    host/include/generic/host/atomic128-cas.h.inc:63:12: error: initializing 
>> 'Int128' (aka 'struct Int128') with an expression of incompatible type '__int128_t' (aka 
>> '__int128')
>>       63 |     Int128 old = *ptr_align;
>>          |            ^     ~~~~~~~~~~
>>    host/include/generic/host/atomic128-cas.h.inc:65:62: error: invalid operands to 
>> binary expression ('Int128' (aka 'struct Int128') and 'Int128')
>>       65 |     while (!__atomic_compare_exchange_n(ptr_align, &old, old | val, true,
>>          |                                                          ~~~ ^ ~~~
>>    1 warning and 6 errors generated.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> And what of the CONFIG_TCG_INTERPRETER test that already exists in int128.h?
> 
> There's got to be more to this than that.

If you disable Int128 entirely, then we can't use 
host/include/generic/host/atomic128-cas.h.inc at all.  The bug is within that header, were 
we need to use Int128Alias more, as we already do for atomic16_cmpxchg.

I'll post a fix.


r~