Skip to contentSkip to conversation

tcg: Fix TCI build on macOS

PATCH In review Philippe Mathieu-Daudé 2 participants 6 messages Dec 2, 2025 – Dec 3, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover tcg: Fix TCI build on macOS

We don't test TCG+TCI on macOS host and it is broken. Luckyly the fix is easy.

Philippe Mathieu-Daudé (2):
tcg/tci: Disable -Wundef FFI_GO_CLOSURES warning tcg/tci: Disable Int128 support

 meson.build               | 2 +-
 include/tcg/helper-info.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/2 tcg/tci: Disable -Wundef FFI_GO_CLOSURES warning

Since we build TCI with FFI (commit 22f15579fa1 "tcg: Build ffi data structures for helpers") we get on Darwin:

In file included from ../../tcg/tci.c:22:
In file included from include/tcg/helper-info.h:13:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/ffi/ffi.h:483:5: warning: 'FFI_GO_CLOSURES' is not defined, evaluates to 0 [-Wundef]

    483 | #if FFI_GO_CLOSURES
        |     ^

1 warning generated.

Since this libffi change was committed more than 10 years ago (see
https://github.com/libffi/libffi/commit/e951d64c0852), just define the missing definition on QEMU to silence the warning.

---
 include/tcg/helper-info.h | 3 +++
 1 file changed, 3 insertions(+)
include/tcg/helper-info.h +3 -0
index 909fe73afa3..36bb7f8187f 100644
@@ -10,6 +10,9 @@
 #define TCG_HELPER_INFO_H
 
 #ifdef CONFIG_TCG_INTERPRETER
+#ifndef FFI_GO_CLOSURES
+#define FFI_GO_CLOSURES 0
+#endif
 #include <ffi.h>
 #endif
 #include "tcg-target-reg-bits.h"
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH-for-10.2? 1/2] tcg/tci: Disable -Wundef FFI_GO_CLOSURES warning

Quoted 6 lines · Philippe Mathieu-Daudé

Since we build TCI with FFI (commit 22f15579fa1 "tcg: Build ffi data structures for helpers") we get on Darwin:

In file included from ../../tcg/tci.c:22:
In file included from include/tcg/helper-info.h:13:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/ffi/ffi.h:483:5: warning: 'FFI_GO_CLOSURES' is not defined, evaluates to 0 [-Wundef]

Quoted 7 lines
     483 | #if FFI_GO_CLOSURES
         |     ^

1 warning generated.

Since this libffi change was committed more than 10 years ago (see
https://github.com/libffi/libffi/commit/e951d64c0852), just define the missing definition on QEMU to silence the warning.

See also c23e9a1c from 2023, which fixed that to use an ifdef.

I suppose the inclusion or exclusion of the go interface is neither here nor there, so long as it compiles.

r~

#3 lore raw

PATCH 2/2 tcg/tci: Disable Int128 support

In reply to Philippe Mathieu-Daudé

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.

---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
index d9293294d8e..692a62e6c18 100644
@@ -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; }''')
Signature · 1 line
2.51.0
#4 lore raw

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

Quoted 25 lines · Philippe Mathieu-Daudé

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;
         |            ^     ~~~~~~~~~~
Quoted 6 lines

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.

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~

Quoted 17 lines
---
  meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
index d9293294d8e..692a62e6c18 100644
@@ -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; }''')
#5 lore raw

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

Quoted 31 lines · Richard Henderson
Quoted 30 lines · Philippe Mathieu-Daudé

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.

Quoted 5 lines
Quoted 1 line

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~