Generate a full SysEmuTarget token separately from TARGET_ARCH, so variant
targets such as mipsel retain their QMP identity while user-mode targets
continue using the base architecture token.

Fixes: e934c624f3 ("target-info: Statically initialize target_arch")
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4640

Signed-off-by: Yonggang Luo <[email protected]>
---
 meson.build        | 9 +++++++++
 target-info-stub.c | 2 +-
 target-info.c      | 8 +-------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index cec12f109f..5c0607bfa5 100644
--- a/meson.build
+++ b/meson.build
@@ -3319,6 +3319,13 @@ foreach target : target_dirs
   endif
 
   config_target += keyval.load('configs/targets' / target + '.mak')
+  if 'TARGET_SYS_EMU' not in config_target
+    if target.endswith('-softmmu')
+      config_target += { 'TARGET_SYS_EMU': config_target['TARGET_NAME'] }
+    else
+      config_target += { 'TARGET_SYS_EMU': config_target['TARGET_ARCH'] }
+    endif
+  endif
 
   target_kconfig = []
   foreach sym: accelerators
@@ -3372,6 +3379,8 @@ foreach target : target_dirs
       # do nothing
     elif ignored.contains(k)
       # do nothing
+    elif k == 'TARGET_SYS_EMU'
+      config_target_data.set(k, v.to_upper())
     elif k == 'TARGET_BASE_ARCH'
       # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
       # not used to select files from sourcesets.
diff --git a/target-info-stub.c b/target-info-stub.c
index 4a8630b5f5..8f5d9fc728 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -26,7 +26,7 @@ QEMU_BUILD_BUG_ON(TARGET_PAGE_BITS < TARGET_PAGE_BITS_MIN);
 
 static const TargetInfo target_info_stub = {
     .target_name = TARGET_NAME,
-    .target_arch = SYS_EMU_TARGET__MAX,
+    .target_arch = glue(SYS_EMU_TARGET_, TARGET_SYS_EMU),
     .long_bits = TARGET_LONG_BITS,
     .cpu_type = CPU_RESOLVING_TYPE,
     .endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE,
diff --git a/target-info.c b/target-info.c
index bd126613b0..012b384036 100644
--- a/target-info.c
+++ b/target-info.c
@@ -24,13 +24,7 @@ unsigned target_long_bits(void)
 
 SysEmuTarget target_arch(void)
 {
-    SysEmuTarget arch = target_info()->target_arch;
-
-    if (arch == SYS_EMU_TARGET__MAX) {
-        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
-                               &error_abort);
-    }
-    return arch;
+    return target_info()->target_arch;
 }
 
 const char *target_cpu_type(void)
-- 
2.55.0.windows.3


Reply via email to