config/arm: split -march into arch and features
[dpdk.git] / config / arm / meson.build
index 14987c6..9bdf4bc 100644 (file)
@@ -38,7 +38,9 @@ implementer_generic = {
     ],
     'part_number_config': {
         'generic': {
-            'machine_args': ['-march=armv8-a+crc', '-moutline-atomics']
+            'march': 'armv8-a',
+            'march_features': ['crc'],
+            'compiler_options': ['-moutline-atomics']
         },
         'generic_aarch32': {
             'machine_args': ['-march=armv8-a', '-mfpu=neon'],
@@ -53,15 +55,17 @@ implementer_generic = {
 }
 
 part_number_config_arm = {
-    '0xd03': {'machine_args':  ['-mcpu=cortex-a53']},
-    '0xd04': {'machine_args':  ['-mcpu=cortex-a35']},
-    '0xd07': {'machine_args':  ['-mcpu=cortex-a57']},
-    '0xd08': {'machine_args':  ['-mcpu=cortex-a72']},
-    '0xd09': {'machine_args':  ['-mcpu=cortex-a73']},
-    '0xd0a': {'machine_args':  ['-mcpu=cortex-a75']},
-    '0xd0b': {'machine_args':  ['-mcpu=cortex-a76']},
+    '0xd03': {'compiler_options':  ['-mcpu=cortex-a53']},
+    '0xd04': {'compiler_options':  ['-mcpu=cortex-a35']},
+    '0xd07': {'compiler_options':  ['-mcpu=cortex-a57']},
+    '0xd08': {'compiler_options':  ['-mcpu=cortex-a72']},
+    '0xd09': {'compiler_options':  ['-mcpu=cortex-a73']},
+    '0xd0a': {'compiler_options':  ['-mcpu=cortex-a75']},
+    '0xd0b': {'compiler_options':  ['-mcpu=cortex-a76']},
     '0xd0c': {
-        'machine_args':  ['-march=armv8.2-a+crypto', '-mcpu=neoverse-n1'],
+        'march': 'armv8.2-a',
+        'march_features': ['crypto'],
+        'compiler_options':  ['-mcpu=neoverse-n1'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n1"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -71,7 +75,8 @@ part_number_config_arm = {
         ]
     },
     '0xd49': {
-        'machine_args':  ['-march=armv8.5-a+crypto+sve2'],
+        'march': 'armv8.5-a',
+        'march_features': ['crypto', 'sve2'],
         'flags': [
             ['RTE_MACHINE', '"neoverse-n2"'],
             ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -105,19 +110,21 @@ implementer_cavium = {
     ],
     'part_number_config': {
         '0xa1': {
-            'machine_args': ['-mcpu=thunderxt88'],
+            'compiler_options': ['-mcpu=thunderxt88'],
             'flags': flags_part_number_thunderx
         },
         '0xa2': {
-            'machine_args': ['-mcpu=thunderxt81'],
+            'compiler_options': ['-mcpu=thunderxt81'],
             'flags': flags_part_number_thunderx
         },
         '0xa3': {
-            'machine_args': ['-mcpu=thunderxt83'],
+            'compiler_options': ['-mcpu=thunderxt83'],
             'flags': flags_part_number_thunderx
         },
         '0xaf': {
-            'machine_args': ['-march=armv8.1-a+crc+crypto', '-mcpu=thunderx2t99'],
+            'march': 'armv8.1-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options': ['-mcpu=thunderx2t99'],
             'flags': [
                 ['RTE_MACHINE', '"thunderx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -127,7 +134,9 @@ implementer_cavium = {
             ]
         },
         '0xb2': {
-            'machine_args': ['-march=armv8.2-a+crc+crypto+lse', '-mcpu=octeontx2'],
+            'march': 'armv8.2-a',
+            'march_features': ['crc', 'crypto', 'lse'],
+            'compiler_options': ['-mcpu=octeontx2'],
             'flags': [
                 ['RTE_MACHINE', '"octeontx2"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -148,7 +157,11 @@ implementer_ampere = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x0': {'machine_args':  ['-march=armv8-a+crc+crypto', '-mtune=emag']}
+        '0x0': {
+            'march': 'armv8-a',
+            'march_features': ['crc', 'crypto'],
+            'compiler_options':  ['-mtune=emag']
+        }
     }
 }
 
@@ -160,7 +173,9 @@ implementer_hisilicon = {
     ],
     'part_number_config': {
         '0xd01': {
-            'machine_args': ['-march=armv8.2-a+crypto', '-mtune=tsv110'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto'],
+            'compiler_options': ['-mtune=tsv110'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 920"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -169,7 +184,8 @@ implementer_hisilicon = {
             ]
         },
         '0xd02': {
-            'machine_args': ['-march=armv8.2-a+crypto+sve'],
+            'march': 'armv8.2-a',
+            'march_features': ['crypto', 'sve'],
             'flags': [
                 ['RTE_MACHINE', '"Kunpeng 930"'],
                 ['RTE_ARM_FEATURE_ATOMICS', true],
@@ -190,8 +206,14 @@ implementer_qualcomm = {
         ['RTE_MAX_NUMA_NODES', 1]
     ],
     'part_number_config': {
-        '0x800': {'machine_args':  ['-march=armv8-a+crc']},
-        '0xc00': {'machine_args':  ['-march=armv8-a+crc']},
+        '0x800': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        },
+        '0xc00': {
+            'march': 'armv8-a',
+            'march_features': ['crc']
+        }
     }
 }
 
@@ -500,13 +522,65 @@ if update_flags
     # add/overwrite flags in the proper order
     dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags
 
-    # apply supported machine args
     machine_args = [] # Clear previous machine args
-    foreach flag: part_number_config['machine_args']
-        if cc.has_argument(flag)
-            machine_args += flag
+
+    # probe supported archs and their features
+    candidate_march = ''
+    if part_number_config.has_key('march')
+        supported_marchs = ['armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+                            'armv8.2-a', 'armv8.1-a', 'armv8-a']
+        check_compiler_support = false
+        foreach supported_march: supported_marchs
+            if supported_march == part_number_config['march']
+                # start checking from this version downwards
+                check_compiler_support = true
+            endif
+            if (check_compiler_support and
+                cc.has_argument('-march=' + supported_march))
+                candidate_march = supported_march
+                # highest supported march version found
+                break
+            endif
+        endforeach
+        if candidate_march == ''
+            error('No suitable armv8 march version found.')
         endif
-    endforeach
+        if candidate_march != part_number_config['march']
+            warning('Configuration march version is ' +
+                    '@0@, but the compiler supports only @1@.'
+                    .format(part_number_config['march'], candidate_march))
+        endif
+        candidate_march = '-march=' + candidate_march
+
+        march_features = []
+        if part_number_config.has_key('march_features')
+            march_features += part_number_config['march_features']
+        endif
+        if soc_config.has_key('extra_march_features')
+            march_features += soc_config['extra_march_features']
+        endif
+        foreach feature: march_features
+            if cc.has_argument('+'.join([candidate_march, feature]))
+                candidate_march = '+'.join([candidate_march, feature])
+            else
+                warning('The compiler does not support feature @0@'
+                    .format(feature))
+            endif
+        endforeach
+        machine_args += candidate_march
+    endif
+
+    # apply supported compiler options
+    if part_number_config.has_key('compiler_options')
+        foreach flag: part_number_config['compiler_options']
+            if cc.has_argument(flag)
+                machine_args += flag
+            else
+                warning('Configuration compiler option ' +
+                        '@0@ isn\'t supported.'.format(flag))
+            endif
+        endforeach
+    endif
 
     # apply flags
     foreach flag: dpdk_flags