Enable cross-compilation of DPDK with meson
Subsystems (3)
cover Enable cross-compilation of DPDK with meson
While meson has built-in support for cross-compilation, there can be things inside the meson.build files which cause problems in a cross-compile environment. This patchset fixes a number of issues found when doing test builds for arm architecture.
NOTE: this patchset only contains the fixes made to existing code. The additional files needed for building for an arm target will be sent out as an RFC patch separately, to be picked up by those more familiar with arm architecture and hopefully turned into a production-ready patchset. The resulting arm build was not test run on any platform.
Bruce Richardson (2):
build: remove architecture flag as default C flag net/pcap: fix cross compilation
app/test-pmd/meson.build | 1 + buildtools/pmdinfogen/meson.build | 3 +-- config/meson.build | 8 ++++++-- drivers/meson.build | 2 +- drivers/net/i40e/meson.build | 2 +- drivers/net/ixgbe/meson.build | 2 +- drivers/net/pcap/meson.build | 21 +++++++++++++++------ examples/meson.build | 2 +- lib/meson.build | 2 +- meson.build | 2 +- 10 files changed, 29 insertions(+), 16 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/2 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.
--- app/test-pmd/meson.build | 1 + buildtools/pmdinfogen/meson.build | 3 +-- config/meson.build | 8 ++++++-- 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 +- 9 files changed, 14 insertions(+), 10 deletions(-)
app/test-pmd/meson.build +1 -0
@@ -73,6 +73,7 @@ endif executable('dpdk-testpmd', sources, + c_args: machine_arg, link_whole: link_libs, dependencies: dep_objs, install_rpath: join_paths(get_option('prefix'), driver_install_path),
buildtools/pmdinfogen/meson.build +1 -2
@@ -34,5 +34,4 @@ pmdinfogen_inc += include_directories('../../lib/librte_pci') pmdinfogen = executable('pmdinfogen', 'pmdinfogen.c', include_directories: pmdinfogen_inc, - native: true, - c_args: cflags) + native: true)
config/meson.build +6 -2
@@ -30,9 +30,13 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # 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')
drivers/meson.build +1 -1
@@ -50,7 +50,7 @@ foreach class:driver_classes version = 1 sources = [] objs = [] - cflags = [] + cflags = [machine_arg] includes = [include_directories(drv_path)] # set up internal deps. Drivers can append/override as necessary deps = std_deps
drivers/net/i40e/meson.build +1 -1
@@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -cflags = ['-DPF_DRIVER', +cflags += ['-DPF_DRIVER', '-DVF_DRIVER', '-DINTEGRATED_VF', '-DX722_A0_SUPPORT']
drivers/net/ixgbe/meson.build +1 -1
@@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -cflags = ['-DRTE_LIBRTE_IXGBE_BYPASS'] +cflags += ['-DRTE_LIBRTE_IXGBE_BYPASS'] subdir('base') objs = [base_objs]
examples/meson.build +1 -1
@@ -37,7 +37,7 @@ endif foreach example: get_option('examples').split(',') name = example sources = [] - cflags = [] + cflags = [machine_arg] ext_deps = [] includes = [include_directories(example)] deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
lib/meson.build +1 -1
@@ -59,7 +59,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
meson.build +1 -1
@@ -93,5 +93,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] )
Signature · 1 line
2.14.3
PATCH 2/2 net/pcap: fix cross compilation
In reply to Bruce RichardsonThe detection of pcap as a dependency involves invoking pcap-config to get parameters - something not possible in a cross-compilation environment. Therefore we need to just look for the presence of the library in a cross-compilation environment and assume if the library is present we can compile and link against it.
--- drivers/net/pcap/meson.build | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/net/pcap/meson.build +15 -6
@@ -29,13 +29,22 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -pcap_dep = dependency('pcap', required: false) -if pcap_dep.found() == true - ext_deps += pcap_dep -elif find_program('pcap-config', required: false).found() == true - ext_deps += cc.find_library('pcap') +if meson.is_cross_build() + pcap_dep = cc.find_library('pcap', required: false) + if pcap_dep.found() + ext_deps += pcap_dep + else + build = false + endif else - build = false + pcap_dep = dependency('pcap', required: false) + if pcap_dep.found() == true + ext_deps += pcap_dep + elif find_program('pcap-config', required: false).found() == true + ext_deps += cc.find_library('pcap') + else + build = false + endif endif sources = files('rte_eth_pcap.c') pkgconfig_extra_libs += '-lpcap'
Signature · 1 line
2.14.3
Quoted 31 lines · Bruce Richardson
While meson has built-in support for cross-compilation, there can be things
inside the meson.build files which cause problems in a cross-compile environment. This patchset fixes a number of issues found when doing test
builds for arm architecture.NOTE: this patchset only contains the fixes made to existing code. The
additional files needed for building for an arm target will be sent out as
an RFC patch separately, to be picked up by those more familiar with arm
architecture and hopefully turned into a production-ready patchset. The
resulting arm build was not test run on any platform.Bruce Richardson (2):
build: remove architecture flag as default C flag net/pcap: fix cross compilationapp/test-pmd/meson.build | 1 + buildtools/pmdinfogen/meson.build | 3 +-- config/meson.build | 8 ++++++-- drivers/meson.build | 2 +- drivers/net/i40e/meson.build | 2 +- drivers/net/ixgbe/meson.build | 2 +- drivers/net/pcap/meson.build | 21 +++++++++++++++------ examples/meson.build | 2 +- lib/meson.build | 2 +- meson.build | 2 +-
Quoted 1 line
10 files changed, 29 insertions(+), 16 deletions(-)
Looks good to me, thanks.
Signature · 2 lines
Kind regards, Luca Boccassi
Quoted 34 lines · Luca Boccassi
Quoted 31 lines · Bruce Richardson
While meson has built-in support for cross-compilation, there can be things
inside the meson.build files which cause problems in a cross-compile environment. This patchset fixes a number of issues found when doing test
builds for arm architecture.NOTE: this patchset only contains the fixes made to existing code. The
additional files needed for building for an arm target will be sent out as
an RFC patch separately, to be picked up by those more familiar with arm
architecture and hopefully turned into a production-ready patchset. The
resulting arm build was not test run on any platform.Bruce Richardson (2):
build: remove architecture flag as default C flag net/pcap: fix cross compilationapp/test-pmd/meson.build | 1 + buildtools/pmdinfogen/meson.build | 3 +-- config/meson.build | 8 ++++++-- drivers/meson.build | 2 +- drivers/net/i40e/meson.build | 2 +- drivers/net/ixgbe/meson.build | 2 +- drivers/net/pcap/meson.build | 21 +++++++++++++++------ examples/meson.build | 2 +- lib/meson.build | 2 +- meson.build | 2 +-
Quoted 1 line
10 files changed, 29 insertions(+), 16 deletions(-)
Quoted 2 lines
Acked-by Luca Boccassi <[email protected]>
Applied to dpdk-next-build