xref: /f-stack/dpdk/config/meson.build (revision 819aafb6)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2017 Intel Corporation
3
4# driver .so files often depend upon the bus drivers for their connect bus,
5# e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
6# to be in the library path, so symlink the drivers from the main lib directory.
7meson.add_install_script('../buildtools/symlink-drivers-solibs.sh',
8		get_option('libdir'),
9		pmd_subdir_opt)
10
11# set the machine type and cflags for it
12if meson.is_cross_build()
13	machine = host_machine.cpu()
14else
15	machine = get_option('machine')
16endif
17
18# machine type 'default' is special, it defaults to the per arch agreed common
19# minimal baseline needed for DPDK.
20# That might not be the most optimized, but the most portable version while
21# still being able to support the CPU features required for DPDK.
22# This can be bumped up by the DPDK project, but it can never be an
23# invariant like 'native'
24if machine == 'default'
25	if host_machine.cpu_family().startswith('x86')
26		# matches the old pre-meson build systems default
27		machine = 'corei7'
28	elif host_machine.cpu_family().startswith('arm')
29		machine = 'armv7-a'
30	elif host_machine.cpu_family().startswith('aarch')
31		# arm64 manages defaults in config/arm/meson.build
32		machine = 'default'
33	elif host_machine.cpu_family().startswith('ppc')
34		machine = 'power8'
35	endif
36endif
37
38dpdk_conf.set('RTE_MACHINE', machine)
39machine_args = []
40
41# ppc64 does not support -march= at all, use -mcpu and -mtune for that
42if host_machine.cpu_family().startswith('ppc')
43	machine_args += '-mcpu=' + machine
44	machine_args += '-mtune=' + machine
45else
46	machine_args += '-march=' + machine
47endif
48
49toolchain = cc.get_id()
50dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
51dpdk_conf.set('RTE_TOOLCHAIN_' + toolchain.to_upper(), 1)
52
53dpdk_conf.set('RTE_ARCH_64', cc.sizeof('void *') == 8)
54
55add_project_link_arguments('-Wl,--no-as-needed', language: 'c')
56dpdk_extra_ldflags += '-Wl,--no-as-needed'
57
58# use pthreads
59add_project_link_arguments('-pthread', language: 'c')
60dpdk_extra_ldflags += '-pthread'
61
62# some libs depend on maths lib
63add_project_link_arguments('-lm', language: 'c')
64dpdk_extra_ldflags += '-lm'
65
66# for linux link against dl, for bsd execinfo
67if host_machine.system() == 'linux'
68	link_lib = 'dl'
69else
70	link_lib = 'execinfo'
71endif
72add_project_link_arguments('-l' + link_lib, language: 'c')
73dpdk_extra_ldflags += '-l' + link_lib
74
75# check for libraries used in multiple places in DPDK
76has_libnuma = 0
77numa_dep = cc.find_library('numa', required: false)
78if numa_dep.found() and cc.has_header('numaif.h')
79	dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
80	has_libnuma = 1
81	add_project_link_arguments('-lnuma', language: 'c')
82	dpdk_extra_ldflags += '-lnuma'
83endif
84
85# check for strlcpy
86if host_machine.system() == 'linux' and cc.find_library('bsd',
87		required: false).found() and cc.has_header('bsd/string.h')
88	dpdk_conf.set('RTE_USE_LIBBSD', 1)
89	add_project_link_arguments('-lbsd', language: 'c')
90	dpdk_extra_ldflags += '-lbsd'
91endif
92
93# add -include rte_config to cflags
94add_project_arguments('-include', 'rte_config.h', language: 'c')
95
96# enable extra warnings and disable any unwanted warnings
97warning_flags = [
98	'-Wsign-compare',
99	'-Wcast-qual',
100	'-Wno-address-of-packed-member'
101]
102if not dpdk_conf.get('RTE_ARCH_64')
103# for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
104	warning_flags += '-Wno-pointer-to-int-cast'
105endif
106foreach arg: warning_flags
107	if cc.has_argument(arg)
108		add_project_arguments(arg, language: 'c')
109	endif
110endforeach
111
112# set other values pulled from the build options
113dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
114dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
115dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
116dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', get_option('allow_invalid_socket_id'))
117# values which have defaults which may be overridden
118dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
119dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
120dpdk_conf.set('RTE_LIBRTE_DPAA2_USE_PHYS_IOVA', true)
121
122
123compile_time_cpuflags = []
124if host_machine.cpu_family().startswith('x86')
125	arch_subdir = 'x86'
126elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
127	arch_subdir = 'arm'
128elif host_machine.cpu_family().startswith('ppc')
129	arch_subdir = 'ppc_64'
130endif
131subdir(arch_subdir)
132dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
133
134# set the install path for the drivers
135dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
136
137install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))
138
139# enable VFIO only if it is linux OS
140dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux')
141
142# specify -D_GNU_SOURCE unconditionally
143add_project_arguments('-D_GNU_SOURCE', language: 'c')
144
145# specify -D__BSD_VISIBLE for FreeBSD
146if host_machine.system() == 'freebsd'
147	add_project_arguments('-D__BSD_VISIBLE', language: 'c')
148endif
149