[RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg

Anton Johansson via posted 43 patches 2 days, 13 hours ago
[RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg
Posted by Anton Johansson via 2 days, 13 hours ago
Adds a meson option for enabling/disabling helper-to-tcg along with a
CONFIG_* definition.

CONFIG_* will in future commits be used to conditionally include the
helper-to-tcg subproject, and to remove unneeded code/memory when
helper-to-tcg is not in use.

Current meson option is limited to Hexagon, as helper-to-tcg will be
included as a subproject from target/hexagon.  This will change in the
future if multiple frontends adopt helper-to-tcg.

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 meson.build                   | 7 +++++++
 meson_options.txt             | 2 ++
 scripts/meson-buildoptions.sh | 5 +++++
 3 files changed, 14 insertions(+)

diff --git a/meson.build b/meson.build
index e0b880e4e1..657ebe43f6 100644
--- a/meson.build
+++ b/meson.build
@@ -230,6 +230,7 @@ have_ga = get_option('guest_agent') \
            error_message: 'unsupported OS for QEMU guest agent') \
   .allowed()
 have_block = have_system or have_tools
+helper_to_tcg_enabled = get_option('hexagon_helper_to_tcg')
 
 enable_modules = get_option('modules') \
   .require(host_os != 'windows',
@@ -3245,6 +3246,11 @@ foreach target : target_dirs
       'CONFIG_QEMU_RTSIG_MAP': get_option('rtsig_map'),
     }
   endif
+  if helper_to_tcg_enabled
+    config_target += {
+      'CONFIG_HELPER_TO_TCG': 'y',
+    }
+  endif
 
   target_kconfig = []
   foreach sym: accelerators
@@ -4122,6 +4128,7 @@ foreach target : target_dirs
   if host_os == 'linux'
     target_inc += include_directories('linux-headers', is_system: true)
   endif
+
   if target.endswith('-softmmu')
     target_type='system'
     t = target_system_arch[target_base_arch].apply(config_target, strict: false)
diff --git a/meson_options.txt b/meson_options.txt
index 5eeaf3eee5..0730378305 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -374,6 +374,8 @@ option('qemu_ga_version', type: 'string', value: '',
 
 option('hexagon_idef_parser', type : 'boolean', value : true,
        description: 'use idef-parser to automatically generate TCG code for the Hexagon frontend')
+option('hexagon_helper_to_tcg', type : 'boolean', value : true,
+       description: 'use the helper-to-tcg translator to automatically generate TCG code for the Hexagon frontend')
 
 option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1',
        description: 'tweak required x86_64 architecture version beyond compiler default')
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index a8066aab03..19c891a39b 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -13,6 +13,9 @@ meson_options_help() {
   printf "%s\n" '  --datadir=VALUE          Data file directory [share]'
   printf "%s\n" '  --disable-coroutine-pool coroutine freelist (better performance)'
   printf "%s\n" '  --disable-debug-info     Enable debug symbols and other information'
+  printf "%s\n" '  --disable-hexagon-helper-to-tcg'
+  printf "%s\n" '                           use the helper-to-tcg translator to automatically'
+  printf "%s\n" '                           generate TCG code for the Hexagon frontend'
   printf "%s\n" '  --disable-hexagon-idef-parser'
   printf "%s\n" '                           use idef-parser to automatically generate TCG'
   printf "%s\n" '                           code for the Hexagon frontend'
@@ -341,6 +344,8 @@ _meson_option_parse() {
     --disable-guest-agent) printf "%s" -Dguest_agent=disabled ;;
     --enable-guest-agent-msi) printf "%s" -Dguest_agent_msi=enabled ;;
     --disable-guest-agent-msi) printf "%s" -Dguest_agent_msi=disabled ;;
+    --enable-hexagon-helper-to-tcg) printf "%s" -Dhexagon_helper_to_tcg=true ;;
+    --disable-hexagon-helper-to-tcg) printf "%s" -Dhexagon_helper_to_tcg=false ;;
     --enable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=true ;;
     --disable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=false ;;
     --enable-hv-balloon) printf "%s" -Dhv_balloon=enabled ;;
-- 
2.45.2
Re: [RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg
Posted by Richard Henderson 21 hours ago
On 11/20/24 19:49, Anton Johansson wrote:
> Adds a meson option for enabling/disabling helper-to-tcg along with a
> CONFIG_* definition.
> 
> CONFIG_* will in future commits be used to conditionally include the
> helper-to-tcg subproject, and to remove unneeded code/memory when
> helper-to-tcg is not in use.
> 
> Current meson option is limited to Hexagon, as helper-to-tcg will be
> included as a subproject from target/hexagon.  This will change in the
> future if multiple frontends adopt helper-to-tcg.
> 
> Signed-off-by: Anton Johansson <anjo@rev.ng>
> ---
>   meson.build                   | 7 +++++++
>   meson_options.txt             | 2 ++
>   scripts/meson-buildoptions.sh | 5 +++++
>   3 files changed, 14 insertions(+)

Looks ok.  Could probably stand another set of meson eyes.

Acked-by: Richard Henderson <richard.henderson@linaro.org>


r~

> 
> diff --git a/meson.build b/meson.build
> index e0b880e4e1..657ebe43f6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -230,6 +230,7 @@ have_ga = get_option('guest_agent') \
>              error_message: 'unsupported OS for QEMU guest agent') \
>     .allowed()
>   have_block = have_system or have_tools
> +helper_to_tcg_enabled = get_option('hexagon_helper_to_tcg')
>   
>   enable_modules = get_option('modules') \
>     .require(host_os != 'windows',
> @@ -3245,6 +3246,11 @@ foreach target : target_dirs
>         'CONFIG_QEMU_RTSIG_MAP': get_option('rtsig_map'),
>       }
>     endif
> +  if helper_to_tcg_enabled
> +    config_target += {
> +      'CONFIG_HELPER_TO_TCG': 'y',
> +    }
> +  endif
>   
>     target_kconfig = []
>     foreach sym: accelerators
> @@ -4122,6 +4128,7 @@ foreach target : target_dirs
>     if host_os == 'linux'
>       target_inc += include_directories('linux-headers', is_system: true)
>     endif
> +
>     if target.endswith('-softmmu')
>       target_type='system'
>       t = target_system_arch[target_base_arch].apply(config_target, strict: false)
> diff --git a/meson_options.txt b/meson_options.txt
> index 5eeaf3eee5..0730378305 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -374,6 +374,8 @@ option('qemu_ga_version', type: 'string', value: '',
>   
>   option('hexagon_idef_parser', type : 'boolean', value : true,
>          description: 'use idef-parser to automatically generate TCG code for the Hexagon frontend')
> +option('hexagon_helper_to_tcg', type : 'boolean', value : true,
> +       description: 'use the helper-to-tcg translator to automatically generate TCG code for the Hexagon frontend')
>   
>   option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1',
>          description: 'tweak required x86_64 architecture version beyond compiler default')
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index a8066aab03..19c891a39b 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -13,6 +13,9 @@ meson_options_help() {
>     printf "%s\n" '  --datadir=VALUE          Data file directory [share]'
>     printf "%s\n" '  --disable-coroutine-pool coroutine freelist (better performance)'
>     printf "%s\n" '  --disable-debug-info     Enable debug symbols and other information'
> +  printf "%s\n" '  --disable-hexagon-helper-to-tcg'
> +  printf "%s\n" '                           use the helper-to-tcg translator to automatically'
> +  printf "%s\n" '                           generate TCG code for the Hexagon frontend'
>     printf "%s\n" '  --disable-hexagon-idef-parser'
>     printf "%s\n" '                           use idef-parser to automatically generate TCG'
>     printf "%s\n" '                           code for the Hexagon frontend'
> @@ -341,6 +344,8 @@ _meson_option_parse() {
>       --disable-guest-agent) printf "%s" -Dguest_agent=disabled ;;
>       --enable-guest-agent-msi) printf "%s" -Dguest_agent_msi=enabled ;;
>       --disable-guest-agent-msi) printf "%s" -Dguest_agent_msi=disabled ;;
> +    --enable-hexagon-helper-to-tcg) printf "%s" -Dhexagon_helper_to_tcg=true ;;
> +    --disable-hexagon-helper-to-tcg) printf "%s" -Dhexagon_helper_to_tcg=false ;;
>       --enable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=true ;;
>       --disable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=false ;;
>       --enable-hv-balloon) printf "%s" -Dhv_balloon=enabled ;;
Re: [RFC PATCH v1 01/43] Add option to enable/disable helper-to-tcg
Posted by Paolo Bonzini 20 hours ago
On 11/22/24 18:30, Richard Henderson wrote:
> On 11/20/24 19:49, Anton Johansson wrote:
>> Adds a meson option for enabling/disabling helper-to-tcg along with a
>> CONFIG_* definition.
>>
>> CONFIG_* will in future commits be used to conditionally include the
>> helper-to-tcg subproject, and to remove unneeded code/memory when
>> helper-to-tcg is not in use.
>>
>> Current meson option is limited to Hexagon, as helper-to-tcg will be
>> included as a subproject from target/hexagon.  This will change in the
>> future if multiple frontends adopt helper-to-tcg.
>>
>> Signed-off-by: Anton Johansson <anjo@rev.ng>
>> ---
>>   meson.build                   | 7 +++++++
>>   meson_options.txt             | 2 ++
>>   scripts/meson-buildoptions.sh | 5 +++++
>>   3 files changed, 14 insertions(+)
> 
> Looks ok.  Could probably stand another set of meson eyes.
> 
> Acked-by: Richard Henderson <richard.henderson@linaro.org>

/me bows

Since the subproject has a pretty hefty (and specific) set of
dependencies, please make this a "feature" option.  This allows
subprojects/helper-to-tcg to disable itself if it cannot find
a dependency or otherwise invokes error(), without breaking the
build.  The --enable-hexagon-helper-to-tcg flag however *will*
force the subproject to be buildable, just like all other
QEMU feature options.

Something like this:


########################
# Target configuration #
########################

# a bit gross to hardcode hexagon, but acceptable given the name of the option
helper_to_tcg = subproject('helper-to-tcg', get_option('hexagon_helper_to_tcg') \
    .disable_auto_if('hexagon-linux-user' not in target_dirs))


and replace helper_to_tcg_enabled throughout with helper_to_tcg.found().

>> +  if helper_to_tcg_enabled
>> +    config_target += {
>> +      'CONFIG_HELPER_TO_TCG': 'y',
>> +    }
>> +  endif

Here I would add instead add CONFIG_HELPER_TO_TCG (maybe renamed to
TARGET_HELPER_TO_TCG) in configs/targets/) and add before the loop:

ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
if not helper_to_tcg.found()
   # do not define it if it is not usable
   ignored += ['TARGET_HELPER_TO_TCG']
endif

Paolo