build: avoid non supported -march on ppc with meson
[dpdk.git] / config / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017 Intel Corporation
3
4 # set the machine type and cflags for it
5 if meson.is_cross_build()
6         machine = host_machine.cpu()
7 else
8         machine = get_option('machine')
9 endif
10 dpdk_conf.set('RTE_MACHINE', machine)
11 machine_args = []
12
13 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
14 if host_machine.cpu_family().startswith('ppc')
15         machine_args += '-mcpu=' + machine
16         machine_args += '-mtune=' + machine
17 else
18         machine_args += '-march=' + machine
19 endif
20
21 toolchain = cc.get_id()
22 dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
23 dpdk_conf.set('RTE_TOOLCHAIN_' + toolchain.to_upper(), 1)
24
25 add_project_link_arguments('-Wl,--no-as-needed', language: 'c')
26 dpdk_extra_ldflags += '-Wl,--no-as-needed'
27
28 # use pthreads
29 add_project_link_arguments('-pthread', language: 'c')
30 dpdk_extra_ldflags += '-pthread'
31
32 # some libs depend on maths lib
33 add_project_link_arguments('-lm', language: 'c')
34 dpdk_extra_ldflags += '-lm'
35
36 # for linux link against dl, for bsd execinfo
37 if host_machine.system() == 'linux'
38         link_lib = 'dl'
39 else
40         link_lib = 'execinfo'
41 endif
42 add_project_link_arguments('-l' + link_lib, language: 'c')
43 dpdk_extra_ldflags += '-l' + link_lib
44
45 # check for libraries used in multiple places in DPDK
46 has_libnuma = 0
47 numa_dep = cc.find_library('numa', required: false)
48 if numa_dep.found() and cc.has_header('numaif.h')
49         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
50         has_libnuma = 1
51         add_project_link_arguments('-lnuma', language: 'c')
52         dpdk_extra_ldflags += '-lnuma'
53 endif
54
55 # check for strlcpy
56 if host_machine.system() == 'linux' and cc.find_library('bsd',
57                 required: false).found() and cc.has_header('bsd/string.h')
58         dpdk_conf.set('RTE_USE_LIBBSD', 1)
59         add_project_link_arguments('-lbsd', language: 'c')
60         dpdk_extra_ldflags += '-lbsd'
61 endif
62
63 # add -include rte_config to cflags
64 add_project_arguments('-include', 'rte_config.h', language: 'c')
65
66 # enable extra warnings and disable any unwanted warnings
67 warning_flags = [
68         '-Wsign-compare',
69         '-Wcast-qual',
70         '-Wno-address-of-packed-member'
71 ]
72 if cc.sizeof('void *') == 4
73 # for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
74         warning_flags += '-Wno-pointer-to-int-cast'
75 endif
76 foreach arg: warning_flags
77         if cc.has_argument(arg)
78                 add_project_arguments(arg, language: 'c')
79         endif
80 endforeach
81
82 # set other values pulled from the build options
83 dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
84 dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
85 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
86 dpdk_conf.set('RTE_EAL_ALLOW_INV_SOCKET_ID', get_option('allow_invalid_socket_id'))
87 # values which have defaults which may be overridden
88 dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
89 dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
90 dpdk_conf.set('RTE_LIBRTE_DPAA2_USE_PHYS_IOVA', true)
91
92 compile_time_cpuflags = []
93 if host_machine.cpu_family().startswith('x86')
94         arch_subdir = 'x86'
95 elif host_machine.cpu_family().startswith('arm') or host_machine.cpu_family().startswith('aarch')
96         arch_subdir = 'arm'
97 elif host_machine.cpu_family().startswith('ppc')
98         arch_subdir = 'ppc_64'
99 endif
100 subdir(arch_subdir)
101 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
102
103 # set the install path for the drivers
104 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
105
106 install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))
107
108 # enable VFIO only if it is linux OS
109 dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux')