For now, TARGET_ARCH only contains 32 vs 64 bit arch. The variants,
based on endianness, are accessible through TARGET_NAME. However,
TARGET_NAME is a string, and thus can't be concatenated to generate code
and retrieve matching SYS_EMU_TARGET enum entry.
Thus, export this information in TARGET_ARCH_VARIANT as an unquoted
identifier.

There is one more subtlety, user binaries have extra targets that are
not present in SYS_EMU_TARGET, like armeb.
Thus, for user binaries, simply export TARGET_ARCH.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Suggested-by: Yonggang Luo <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
---
 meson.build | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 828100de816..48da6cf3e6b 100644
--- a/meson.build
+++ b/meson.build
@@ -3288,7 +3288,14 @@ default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
 actual_target_dirs = []
 fdt_required = []
 foreach target : target_dirs
-  config_target = { 'TARGET_NAME': target.split('-')[0] }
+  target_name = target.split('-')[0]
+  config_target = { 'TARGET_NAME': target_name }
+  if target.endswith('linux-user')
+    config_target += { 'TARGET_ARCH_VARIANT': 'TARGET_ARCH' }
+  else
+    config_target += { 'TARGET_ARCH_VARIANT': target_name.to_upper() }
+  endif
+
   if target.endswith('linux-user')
     if host_os != 'linux'
       if default_targets
@@ -3372,7 +3379,7 @@ foreach target : target_dirs
       # do nothing
     elif ignored.contains(k)
       # do nothing
-    elif k == 'TARGET_ARCH'
+    elif k == 'TARGET_ARCH' or k == 'TARGET_ARCH_VARIANT'
       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
-- 
2.43.0


Reply via email to