Skip to content

Commit bf66003

Browse files
jlinkestmonjalo
authored andcommitted
build: use platform for generic and native builds
The current meson option 'machine' should only specify the ISA, which is not sufficient for Arm, where setting ISA implies other settings as well (and is used in Arm configuration as such). Use the existing 'platform' meson option to differentiate the type of the build (native/generic) and set ISA accordingly, unless the user chooses to override it with a new option, 'cpu_instruction_set'. The 'machine' option set the ISA in x86 builds and set native/default 'build type' in aarch64 builds. These two new variables, 'platform' and 'cpu_instruction_set', now properly set both ISA and build type for all architectures in a uniform manner. The 'machine' option also doesn't describe very well what it sets. The new option, 'cpu_instruction_set', is much more descriptive. Keep 'machine' for backwards compatibility. Signed-off-by: Juraj Linkeš <[email protected]> Acked-by: Bruce Richardson <[email protected]>
1 parent 5898abe commit bf66003

File tree

6 files changed

+99
-36
lines changed

6 files changed

+99
-36
lines changed

config/arm/meson.build

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,23 @@ if dpdk_conf.get('RTE_ARCH_32')
380380
machine_args += '-mfpu=neon'
381381
else
382382
# aarch64 build
383-
soc = get_option('platform')
384383
soc_config = {}
385384
if not meson.is_cross_build()
386-
if machine == 'generic'
387-
# generic build
388-
if soc != ''
389-
error('Building for a particular platform is unsupported with generic build.')
385+
# for backwards compatibility:
386+
# machine=native is the same behavior as soc=native
387+
# machine=generic/default is the same as soc=generic
388+
# cpu_instruction_set holds the proper value - native, generic or cpu
389+
# the old behavior only distinguished between generic and native build
390+
if machine != 'auto'
391+
if cpu_instruction_set == 'generic'
392+
soc = 'generic'
393+
else
394+
soc = 'native'
390395
endif
391-
implementer_id = 'generic'
392-
part_number = 'generic'
393-
elif soc != ''
394-
soc_config = socs.get(soc, {'not_supported': true})
395396
else
397+
soc = platform
398+
endif
399+
if soc == 'native'
396400
# native build
397401
# The script returns ['Implementer', 'Variant', 'Architecture',
398402
# 'Primary Part number', 'Revision']
@@ -406,6 +410,9 @@ else
406410
else
407411
error('Error when getting Arm Implementer ID and part number.')
408412
endif
413+
else
414+
# SoC build
415+
soc_config = socs.get(soc, {'not_supported': true})
409416
endif
410417
else
411418
# cross build
@@ -437,7 +444,7 @@ else
437444
else
438445
error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
439446
'Please add support for it or use the generic ' +
440-
'(-Dmachine=generic) build.')
447+
'(-Dplatform=generic) build.')
441448
endif
442449

443450
message('Arm implementer: ' + implementer_config['description'])
@@ -452,7 +459,7 @@ else
452459
error('Unsupported part number @0@ of implementer @1@. '
453460
.format(part_number, implementer_id) +
454461
'Please add support for it or use the generic ' +
455-
'(-Dmachine=generic) build.')
462+
'(-Dplatform=generic) build.')
456463
endif
457464

458465
# add/overwrite flags in the proper order

config/meson.build

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,43 +65,68 @@ endif
6565
disable_drivers = ''
6666
enable_drivers = ''
6767

68-
# set the machine type and cflags for it
68+
platform = get_option('platform')
69+
70+
# set the cpu_instruction_set and cflags for it
6971
if meson.is_cross_build()
70-
machine = host_machine.cpu()
72+
cpu_instruction_set = host_machine.cpu()
7173
else
74+
cpu_instruction_set = get_option('cpu_instruction_set')
7275
machine = get_option('machine')
76+
if machine != 'auto'
77+
warning('The "machine" option is deprecated. ' +
78+
'Please use "cpu_instruction_set" instead.')
79+
if cpu_instruction_set != 'auto'
80+
error('Setting both "machine" and ' +
81+
'"cpu_instruction_set" is unsupported.')
82+
endif
83+
cpu_instruction_set = machine
84+
if cpu_instruction_set == 'default'
85+
cpu_instruction_set = 'generic'
86+
endif
87+
endif
88+
endif
89+
90+
if platform == 'native'
91+
if cpu_instruction_set == 'auto'
92+
cpu_instruction_set = 'native'
93+
endif
94+
elif platform == 'generic'
95+
if cpu_instruction_set == 'auto'
96+
cpu_instruction_set = 'generic'
97+
endif
7398
endif
7499

75-
# machine type 'generic' is special, it selects the per arch agreed common
76-
# minimal baseline needed for DPDK. Machine type 'default' is also supported
77-
# with the same meaning for backwards compatibility.
100+
# cpu_instruction_set 'generic' is special, it selects the per arch agreed
101+
# common minimal baseline needed for DPDK. cpu_instruction_set 'default' is
102+
# also supported with the same meaning for backwards compatibility.
78103
# That might not be the most optimized, but the most portable version while
79104
# still being able to support the CPU features required for DPDK.
80105
# This can be bumped up by the DPDK project, but it can never be an
81106
# invariant like 'native'
82-
if machine == 'default' or machine == 'generic'
107+
if cpu_instruction_set == 'generic'
83108
if host_machine.cpu_family().startswith('x86')
84-
# matches the old pre-meson build systems generic machine
85-
machine = 'corei7'
109+
# matches the old pre-meson build systems generic cpu_instruction_set
110+
cpu_instruction_set = 'corei7'
86111
elif host_machine.cpu_family().startswith('arm')
87-
machine = 'armv7-a'
112+
cpu_instruction_set = 'armv7-a'
88113
elif host_machine.cpu_family().startswith('aarch')
89114
# arm64 manages generic config in config/arm/meson.build
90-
machine = 'generic'
115+
cpu_instruction_set = 'generic'
91116
elif host_machine.cpu_family().startswith('ppc')
92-
machine = 'power8'
117+
cpu_instruction_set = 'power8'
93118
endif
94119
endif
95120

96-
dpdk_conf.set('RTE_MACHINE', machine)
121+
dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
97122
machine_args = []
98123

99124
# ppc64 does not support -march= at all, use -mcpu and -mtune for that
100125
if host_machine.cpu_family().startswith('ppc')
101-
machine_args += '-mcpu=' + machine
102-
machine_args += '-mtune=' + machine
126+
machine_args += '-mcpu=' + cpu_instruction_set
127+
machine_args += '-mtune=' + cpu_instruction_set
103128
else
104-
machine_args += '-march=' + machine
129+
machine_args += '-march=' + cpu_instruction_set
105130
endif
106131

107132
toolchain = cc.get_id()

config/ppc/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dpdk_conf.set('RTE_ARCH_PPC_64', 1)
1212
# is used, resulting in a build failure.
1313
power9_supported = cc.has_argument('-mcpu=power9')
1414
if not power9_supported
15-
machine = 'power8'
15+
cpu_instruction_set = 'power8'
1616
machine_args = ['-mcpu=power8', '-mtune=power8']
1717
dpdk_conf.set('RTE_MACHINE','power8')
1818
endif

devtools/test-meson-builds.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ done
223223
# test compilation with minimal x86 instruction set
224224
# Set the install path for libraries to "lib" explicitly to prevent problems
225225
# with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
226-
generic_machine='nehalem'
227-
if ! check_cc_flags "-march=$generic_machine" ; then
228-
generic_machine='corei7'
226+
generic_isa='nehalem'
227+
if ! check_cc_flags "-march=$generic_isa" ; then
228+
generic_isa='corei7'
229229
fi
230230
build build-x86-generic cc skipABI -Dcheck_includes=true \
231-
-Dlibdir=lib -Dmachine=$generic_machine $use_shared
231+
-Dlibdir=lib -Dcpu_instruction_set=$generic_isa $use_shared
232232

233233
# 32-bit with default compiler
234234
if check_cc_flags '-m32' ; then

doc/guides/linux_gsg/build_dpdk.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,36 @@ to a regular "debug" build, you can either:
8989
* run ``meson configure -Dbuildtype=debug`` inside the build folder after the initial meson run.
9090

9191
Other options are specific to the DPDK project but can be adjusted similarly.
92-
To set the "max_lcores" value to 256, for example, you can either:
92+
The "platform" option specifies a set a configuration parameters that will be used.
93+
The valid values are:
94+
95+
* ``-Dplatform=native`` will tailor the configuration to the build machine.
96+
97+
* ``-Dplatform=generic`` will use configuration that works on all machines
98+
of the same architecture as the build machine.
99+
100+
* ``-Dplatform=<SoC>`` will use configuration optimized for a particular SoC.
101+
Consult the "socs" dictionary in ``config/arm/meson.build`` to see which
102+
SoCs are supported.
103+
104+
The instruction set will be set automatically by default according to these rules:
105+
106+
* ``-Dplatform=native`` sets ``cpu_instruction_set`` to ``native``,
107+
which configures ``-march`` (x86_64), ``-mcpu`` (ppc), ``-mtune`` (ppc) to ``native``.
108+
109+
* ``-Dplatform=generic`` sets ``cpu_instruction_set`` to ``generic``,
110+
which configures ``-march`` (x86_64), ``-mcpu`` (ppc), ``-mtune`` (ppc) to
111+
a common minimal baseline needed for DPDK.
112+
113+
To override what instruction set will be used, set the ``cpu_instruction_set``
114+
parameter to the instruction set of your choice (such as ``corei7``, ``power8``, etc.).
115+
116+
``cpu_instruction_set`` is not used in Arm builds, as setting the instruction set
117+
without other parameters leads to inferior builds. The way to tailor Arm builds
118+
is to build for a SoC using ``-Dplatform=<SoC>`` mentioned above.
119+
120+
The values determined by the ``platform`` parameter may be overwritten.
121+
For example, to set the ``max_lcores`` value to 256, you can either:
93122

94123
* pass ``-Dmax_lcores=256`` to meson when configuring the build folder initially
95124

meson_options.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
option('check_includes', type: 'boolean', value: false, description:
44
'build "chkincs" to verify each header file can compile alone')
5+
option('cpu_instruction_set', type: 'string', value: 'auto',
6+
description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
57
option('developer_mode', type: 'feature', description:
68
'turn on additional build checks relevant for DPDK developers')
79
option('disable_drivers', type: 'string', value: '', description:
@@ -28,16 +30,16 @@ option('include_subdir_arch', type: 'string', value: '', description:
2830
'subdirectory where to install arch-dependent headers')
2931
option('kernel_dir', type: 'string', value: '', description:
3032
'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
31-
option('machine', type: 'string', value: 'native', description:
32-
'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
33+
option('machine', type: 'string', value: 'auto', description:
34+
'Alias of cpu_instruction_set.')
3335
option('max_ethports', type: 'integer', value: 32, description:
3436
'maximum number of Ethernet devices')
3537
option('max_lcores', type: 'integer', value: 128, description:
3638
'maximum number of cores/threads supported by EAL')
3739
option('max_numa_nodes', type: 'integer', value: 32, description:
3840
'maximum number of NUMA nodes supported by EAL')
39-
option('platform', type: 'string', value: '', description:
40-
'use configuration for a particular platform (such as a SoC).')
41+
option('platform', type: 'string', value: 'native', description:
42+
'Platform to build, either "native", "generic" or a SoC. Please refer to the Linux build guide for more information.')
4143
option('enable_trace_fp', type: 'boolean', value: false, description:
4244
'enable fast path trace points.')
4345
option('tests', type: 'boolean', value: true, description:

0 commit comments

Comments
 (0)