On Thu, Feb 22, 2024 at 1:45 PM <pbhagavat...@marvell.com> wrote: > > From: Pavan Nikhilesh <pbhagavat...@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 <pbhagavat...@marvell.com> > --- > config/arm/meson.build | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/config/arm/meson.build b/config/arm/meson.build > index d05d54b564..87ff5039f6 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 > > candidate_mcpu = '' > candidate_march = '' > + fallback_march = '' > > if part_number_config.has_key('mcpu') and > cc.has_argument('-mcpu=' + part_number_config['mcpu']) > @@ -736,16 +738,22 @@ if update_flags > # start checking from this version downwards > check_compiler_support = true > endif > - if (check_compiler_support and > + if (check_compiler_support and candidate_march == '' and > cc.has_argument('-march=' + supported_march)) > candidate_march = supported_march > - # 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
If both fallback_march and march are supported, fallback_march is going to be chosen over march. I think this is what we want instead: Use march if supported, then use fallback_march if supported, then use the other fallback marchs. If the above is indeed what we want, we could just put this after endforeach (in the original version): # at this point, candidate march is either part_number_config['fallback_march'] or some other lower version if (part_number_config.has_key('fallback_march') and candidate_march != part_number_config['march'] and cc.has_argument('-march=' + part_number_config['fallback_march'])) # this overwrites only the lower version with preferred fallback_march, if supported candidate_march = part_number_config['fallback_march'] endif This way we won't even need the fallback_march variable. > 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.25.1 >