On 10/7/2026 12:48 AM, Yonggang Luo wrote:
> On Wed, Oct 7, 2026 at 12:03 PM Pierrick Bouvier
> <[email protected]> wrote:
>>
>> 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.
>
>
>>
>> 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 cae1591cd28..9bcfe84daba 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' }
>
> If TARGET_ARCH_VARIANT or just called (TARGET_NAME_ENUM) is just a
> direct mapping of target_name regardless linux-user/bsd-user/softmmu,
> the logic would
> be simpler. That would need add more enum to SYS_EMU_TARGET, the
> current form is:
> ##
> # @SysEmuTarget:
> # The comprehensive enumeration of QEMU system emulation
> # ("softmmu") targets. Run "./configure --help" in the project
> # root directory, and look for the \*-softmmu targets near the
> # "--target-list" option. The individual target constants are not
> # documented here, for the time being.
> #
> # @rx: since 5.0
> #
> # @avr: since 5.1
> #
> # @loongarch64: since 7.1
> #
> # @hexagon: since 11.0
> #
> # .. note:: The resulting QMP strings can be appended to the
> # "qemu-system-" prefix to produce the corresponding QEMU
> # executable name. This is true even for "qemu-system-x86_64".
> #
> # Since: 3.0
> ##
> { 'enum' : 'SysEmuTarget',
> 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386',
> 'loongarch64', 'm68k', 'microblaze', 'mips', 'mips64',
> 'mips64el', 'mipsel', 'or1k', 'ppc',
> 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
> 'sh4eb', 'sparc', 'sparc64', 'tricore',
> 'x86_64', 'xtensa', 'xtensaeb' ] }
>
>
> The list target names that missing from SysEmuTarget:
>
> Comparing the target-name prefixes of `configs/targets/*.mak` with the
> `SysEmuTarget` enum in `qapi/machine.json`, the following seven names are
> missing. All are Linux-user-only targets.
>
> | Target name | Config |
> |---|---|
> | `aarch64_be` | `configs/targets/aarch64_be-linux-user.mak` |
> | `armeb` | `configs/targets/armeb-linux-user.mak` |
> | `microblazeel` | `configs/targets/microblazeel-linux-user.mak` |
> | `mipsn32` | `configs/targets/mipsn32-linux-user.mak` |
> | `mipsn32el` | `configs/targets/mipsn32el-linux-user.mak` |
> | `ppc64le` | `configs/targets/ppc64le-linux-user.mak` |
> | `sparc32plus` | `configs/targets/sparc32plus-linux-user.mak` |
>
> All `*-softmmu` and `*-bsd-user` target names match enum entries.
>
> This comparison uses names derived from config filenames, not the
> `TARGET_ARCH` values inside those configs.
>
> By doing this I think it would be more consistent.
> If these target names are removed in future, then just remove it from
> SysEmuTarget
> along with. So SysEmuTarget is just a direct mapping of TARGET_NAME. Though
> The comment of SysEmuTarget needs updated, it's not just about softmmu, but
> also
> for linux-user and bsd-user. But the fact is, with the current
> changes. *-user also
> used SysEmuTarget as an enum.
>
>
> And TARGET_ARCH should also be exported by TargetInfo for other usage.
> And it's enums is the subset
> of enum SysEmuTarget
>
I tend to agree, but didn't find a real reason to do this change (yet).
Also, I would be in favor to rename SysEmuTarget since in EmuTarget,
since it would now be decoupled from system emulation only.
@Daniel: Would you be favor to see such a change? I know that
introspection/QAPI is related to system emulation, and I'm not
completely sure adding user targets is the right move at this moment.
>
>
>> + 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
>>
>>
>
>
> --
> 此致
> 礼
> 罗勇刚
> Yours
> sincerely,
> Yonggang Luo