From b114af1603db1e955c7efc94370b1d83bbb8f31f Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Fri, 15 Dec 2017 17:12:43 +0000 Subject: [PATCH] build: remove architecture flag as default C flag Any flags added to the project args are automatically added to all builds, both native and cross-compiled. This is not what we want for the -march flag as a valid -march for the cross-compile is not valid for pmdinfogen which is a native-build tool. Instead we store the march flag as a variable, and add it to the default cflags for all libs, drivers, examples, etc. This will allow pmdinfogen to compile successfully in a cross-compilation environment. Signed-off-by: Bruce Richardson Acked-by: Luca Boccassi --- app/test-pmd/meson.build | 2 +- buildtools/pmdinfogen/meson.build | 3 +-- config/meson.build | 8 ++++++-- doc/guides/contributing/coding_style.rst | 2 +- drivers/meson.build | 2 +- drivers/net/i40e/meson.build | 2 +- drivers/net/ixgbe/meson.build | 2 +- examples/meson.build | 2 +- lib/meson.build | 2 +- meson.build | 2 +- 10 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build index a242703458..4614e35060 100644 --- a/app/test-pmd/meson.build +++ b/app/test-pmd/meson.build @@ -45,7 +45,7 @@ endif executable('dpdk-testpmd', sources, - c_args: '-DALLOW_EXPERIMENTAL_API', + c_args: [machine_arg, '-DALLOW_EXPERIMENTAL_API'], link_whole: link_libs, dependencies: dep_objs, install_rpath: join_paths(get_option('prefix'), driver_install_path), diff --git a/buildtools/pmdinfogen/meson.build b/buildtools/pmdinfogen/meson.build index ea373706a4..a219a8e963 100644 --- a/buildtools/pmdinfogen/meson.build +++ b/buildtools/pmdinfogen/meson.build @@ -6,5 +6,4 @@ pmdinfogen_inc += include_directories('../../lib/librte_pci') pmdinfogen = executable('pmdinfogen', 'pmdinfogen.c', include_directories: pmdinfogen_inc, - native: true, - c_args: cflags) + native: true) diff --git a/config/meson.build b/config/meson.build index 4f6511773d..95223042f1 100644 --- a/config/meson.build +++ b/config/meson.build @@ -2,9 +2,13 @@ # Copyright(c) 2017 Intel Corporation # set the machine type and cflags for it -machine = get_option('machine') +if meson.is_cross_build() + machine = host_machine.cpu() +else + machine = get_option('machine') +endif dpdk_conf.set('RTE_MACHINE', machine) -add_project_arguments('-march=@0@'.format(machine), language: 'c') +machine_arg = '-march=' + machine # use pthreads add_project_link_arguments('-pthread', language: 'c') diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst index 3734bf029a..d5fe67fd4a 100644 --- a/doc/guides/contributing/coding_style.rst +++ b/doc/guides/contributing/coding_style.rst @@ -800,7 +800,7 @@ build cflags - **Default Value = []**. + **Default Value = [<-march/-mcpu flags>]**. Used to specify any additional cflags that need to be passed to compile the sources in the library. diff --git a/drivers/meson.build b/drivers/meson.build index f6680ce107..5ee00264e6 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -23,7 +23,7 @@ foreach class:driver_classes allow_experimental_apis = false sources = [] objs = [] - cflags = [] + cflags = [machine_arg] includes = [include_directories(drv_path)] # set up internal deps. Drivers can append/override as necessary deps = std_deps diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build index 42a8a1d47d..504bfdd0c2 100644 --- a/drivers/net/i40e/meson.build +++ b/drivers/net/i40e/meson.build @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -cflags = ['-DPF_DRIVER', +cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF', '-DX722_A0_SUPPORT'] diff --git a/drivers/net/ixgbe/meson.build b/drivers/net/ixgbe/meson.build index 36aaff5d71..60af0baef8 100644 --- a/drivers/net/ixgbe/meson.build +++ b/drivers/net/ixgbe/meson.build @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -cflags = ['-DRTE_LIBRTE_IXGBE_BYPASS'] +cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base') objs = [base_objs] diff --git a/examples/meson.build b/examples/meson.build index b660b4ba1f..cef48fac74 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -10,7 +10,7 @@ foreach example: get_option('examples').split(',') name = example sources = [] allow_experimental_apis = false - cflags = [] + cflags = [machine_arg] ext_deps = [] includes = [include_directories(example)] deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] diff --git a/lib/meson.build b/lib/meson.build index de751626f4..e8302fbb1b 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -33,7 +33,7 @@ foreach l:libraries sources = [] headers = [] includes = [] - cflags = [] + cflags = [machine_arg] objs = [] # other object files to link against, used e.g. for # instruction-set optimized versions of code diff --git a/meson.build b/meson.build index 56a8c64d2a..f572d93e77 100644 --- a/meson.build +++ b/meson.build @@ -65,5 +65,5 @@ pkg.generate(name: meson.project_name(), ['-Wl,-Bdynamic'] + dpdk_extra_ldflags, description: 'The Data Plane Development Kit (DPDK)', subdirs: [get_option('include_subdir_arch'), '.'], - extra_cflags: ['-include', 'rte_config.h', '-march=@0@'.format(machine)] + extra_cflags: ['-include', 'rte_config.h', machine_arg] ) -- 2.20.1