This reverts commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
Fixes: e934c624f3 ("target-info: Statically initialize target_arch")
Signed-off-by: Yonggang Luo <[email protected]>
---
target-info-stub.c | 2 +-
target-info.c | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/target-info-stub.c b/target-info-stub.c
index d121b8c017..4a8630b5f5 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 = glue(SYS_EMU_TARGET_, TARGET_ARCH),
+ .target_arch = SYS_EMU_TARGET__MAX,
.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 012b384036..bd126613b0 100644
--- a/target-info.c
+++ b/target-info.c
@@ -24,7 +24,13 @@ unsigned target_long_bits(void)
SysEmuTarget target_arch(void)
{
- return target_info()->target_arch;
+ 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;
}
const char *target_cpu_type(void)
--
2.55.0.windows.3