[v3,2/3] config/arm: add support for fallback march

Message ID 20240202085031.10237-2-pbhagavatula@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v3,1/3] config/arm: avoid mcpu and march conflicts |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Feb. 2, 2024, 8:50 a.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some ARM CPUs have specific march requirements and
are not compatible with the supported march list.
Add fallback march in case the mcpu and the march
advertised in the part_number_config are not supported
by the compiler.

Example
        mcpu = neoverse-n2
        march = armv9-a
        fallback_march = armv8.5-a

        mcpu, march not supported
        machine_args = ['-march=armv8.5-a']

        mcpu, march, fallback_march not supported
        least march supported = armv8-a

        machine_args = ['-march=armv8-a']

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 config/arm/meson.build | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Wathsala Wathawana Vithanage Feb. 7, 2024, 8:24 p.m. UTC | #1
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Some ARM CPUs have specific march requirements and are not compatible
> with the supported march list.
> Add fallback march in case the mcpu and the march advertised in the
> part_number_config are not supported by the compiler.
> 
> Example
>         mcpu = neoverse-n2
>         march = armv9-a
>         fallback_march = armv8.5-a
> 
>         mcpu, march not supported
>         machine_args = ['-march=armv8.5-a']
> 
>         mcpu, march, fallback_march not supported
>         least march supported = armv8-a
> 
>         machine_args = ['-march=armv8-a']
> 

Similar to "[v3,1/3] config/arm: avoid mcpu and march conflicts" here
also we can avoid selecting march if it's not supported by the compiler.
Ideally, we should exit the build with an error saying march/mcpu is not
supported and suggest further actions (like trying again with 
-Dmarch -Dmcpu or -Dplatform=generic-armv9 as discussed in [v3,1/3])

> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  config/arm/meson.build | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> ba859bd060b5..4e44d1850bae 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -94,6 +94,7 @@ part_number_config_arm = {
>      '0xd49': {
>          'march': 'armv9-a',
>          'march_features': ['sve2'],
> +        'fallback_march': 'armv8.5-a',
>          'mcpu': 'neoverse-n2',
>          'flags': [
>              ['RTE_MACHINE', '"neoverse-n2"'], @@ -708,6 +709,7 @@ if
> update_flags
> 
>      # probe supported archs and their features
>      candidate_march = ''
> +    fallback_march = ''
>      if part_number_config.has_key('march')
>          if part_number_config.get('force_march', false) or candidate_mcpu != ''
>              if cc.has_argument('-march=' +  part_number_config['march']) @@ -
> 728,10 +730,18 @@ if update_flags
>                      # highest supported march version found
>                      break
>                  endif
> +                if (part_number_config.has_key('fallback_march') and
> +                    supported_march == part_number_config['fallback_march'] and
> +                    cc.has_argument('-march=' + supported_march))
> +                    fallback_march = supported_march
> +                endif
>              endforeach
>          endif
> 
>          if candidate_march != part_number_config['march']
> +            if fallback_march != ''
> +                candidate_march = fallback_march
> +            endif
>              warning('Configuration march version is @0@, not supported.'
>                      .format(part_number_config['march']))
>              if candidate_march != ''
> --
> 2.43.0
  

Patch

diff --git a/config/arm/meson.build b/config/arm/meson.build
index ba859bd060b5..4e44d1850bae 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -94,6 +94,7 @@  part_number_config_arm = {
     '0xd49': {
         'march': 'armv9-a',
         'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
         'mcpu': 'neoverse-n2',
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
@@ -708,6 +709,7 @@  if update_flags
 
     # probe supported archs and their features
     candidate_march = ''
+    fallback_march = ''
     if part_number_config.has_key('march')
         if part_number_config.get('force_march', false) or candidate_mcpu != ''
             if cc.has_argument('-march=' +  part_number_config['march'])
@@ -728,10 +730,18 @@  if update_flags
                     # highest supported march version found
                     break
                 endif
+                if (part_number_config.has_key('fallback_march') and
+                    supported_march == part_number_config['fallback_march'] and
+                    cc.has_argument('-march=' + supported_march))
+                    fallback_march = supported_march
+                endif
             endforeach
         endif
 
         if candidate_march != part_number_config['march']
+            if fallback_march != ''
+                candidate_march = fallback_march
+            endif
             warning('Configuration march version is @0@, not supported.'
                     .format(part_number_config['march']))
             if candidate_march != ''