Skip to contentSkip to conversation

small fixes for meson build

PATCH Superseded Bruce Richardson 4 participants 14 messages Apr 18, 2018 – May 8, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover small fixes for meson build

couple of minor fixes for meson build, patch titles are largely self-explanatory.

Bruce Richardson (2):
build: fix kernel compile on cross-build
build: fix check for libbsd in meson

 config/meson.build | 3 ++-
 meson.build        | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/2 build: fix kernel compile on cross-build

When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir value set.

Fixes a52f4574f798 ("igb_uio: build with meson")
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build +5 -1
index cc16595cb..9e3b44931 100644
@@ -26,10 +26,14 @@ subdir('config')
 
 # build libs and drivers
 subdir('lib')
-subdir('kernel')
 subdir('buildtools')
 subdir('drivers')
 
+# build kernel modules if we have a kernel path, or we are not cross compiling
+if get_option('kernel_dir') != '' or not meson.is_cross_build()
+	subdir('kernel')
+endif
+
 # build binaries and installable tools
 subdir('usertools')
 subdir('app')
Signature · 1 line
2.14.3
#5 lore raw

PATCH 2/2 build: fix check for libbsd in meson

In reply to Bruce Richardson

When we check for libbsd we were just checking for the library itself. However, on some distros, e.g. CentOS, libbsd will be found even though it's not usable by DPDK as it's missing the string header. Therefore we should check for both the library and the header file.

Fixes 5364de644a4b ("eal: support strlcpy function")
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index 5815b5602..2179c689c 100644
@@ -43,7 +43,8 @@ if numa_dep.found() and cc.has_header('numaif.h')
 endif
 
 # check for strlcpy
-if host_machine.system() == 'linux' and cc.find_library('bsd', required: false).found()
+if host_machine.system() == 'linux' and cc.find_library('bsd',
+		required: false).found() and cc.has_header('bsd/string.h')
 	dpdk_conf.set('RTE_USE_LIBBSD', 1)
 	add_project_link_arguments('-lbsd', language: 'c')
 	dpdk_extra_ldflags += '-lbsd'
Signature · 1 line
2.14.3
#2 lore raw

Re: [PATCH 1/2] build: fix kernel compile on cross-build

In reply to Bruce Richardson
Quoted 20 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson

When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir value set.

Fixes a52f4574f798 ("igb_uio: build with meson")
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build +0 -0
index cc16595cb..9e3b44931 100644
@@ -26,10 +26,14 @@ subdir('config')
 

meson.build subdir('config') · line 35

Quoted 10 lines
meson.build +4 -1
 # build libs and drivers
 subdir('lib')
-subdir('kernel')
 subdir('buildtools')
 subdir('drivers')
 
+# build kernel modules if we have a kernel path, or we are not cross
+compiling if get_option('kernel_dir') != '' or not meson.is_cross_build()
+	subdir('kernel')
+endif

[Hemant] actually kernel_dir may not be always available on host.
So unless kernel_dir is available - irrespective of host/cross - it shall not try kernel compilation.

Quoted 6 lines
meson.build +1 -1
+
 # build binaries and installable tools
 subdir('usertools')
 subdir('app')
--

2.14.3

#3 lore raw

Re: [PATCH 1/2] build: fix kernel compile on cross-build

Quoted 26 lines · Hemant Agrawal
Quoted 26 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson

When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir value set.

Fixes a52f4574f798 ("igb_uio: build with meson")
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build +0 -1
index cc16595cb..9e3b44931 100644
@@ -26,10 +26,14 @@ subdir('config')
 
 # build libs and drivers
 subdir('lib')
-subdir('kernel')
 subdir('buildtools')
 subdir('drivers')
 
Quoted 9 lines

meson.build subdir('config') · line 35

Quoted 4 lines
meson.build +4 -0
+# build kernel modules if we have a kernel path, or we are not cross
+compiling if get_option('kernel_dir') != '' or not meson.is_cross_build()
+	subdir('kernel')
+endif

[Hemant] actually kernel_dir may not be always available on host.
So unless kernel_dir is available - irrespective of host/cross - it shall not try kernel compilation.

Well, for many native builds the kernel directory can be computed by looking at uname -r, but which won't work for cross-compilation. Given that there is already an option to disable kernel module compilation completely, I think that the default for native builds should be try and build modules for the running kernel.

However, we could certainly add in a check to see if the kernel sources are available, and optionally not build them in that case - i.e. convert the error due to non-existant kernel headers into a warning message. Do you think that might be a good compromise?

/Bruce

#4 lore raw

Re: [PATCH 1/2] build: fix kernel compile on cross-build

Quoted 44 lines
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson

When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir

value set.

Quoted 20 lines
Quoted 20 lines
Fixes a52f4574f798 ("igb_uio: build with meson")
---
 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build index cc16595cb..9e3b44931 renamed from meson.build +0 -0

100644

meson.build +0 -1
@@ -26,10 +26,14 @@ subdir('config')
 
 # build libs and drivers
 subdir('lib')
-subdir('kernel')
 subdir('buildtools')
 subdir('drivers')
 
Quoted 9 lines

meson.build subdir('config') · line 35

Quoted 4 lines
meson.build +4 -0
+# build kernel modules if we have a kernel path, or we are not
+cross compiling if get_option('kernel_dir') != '' or not meson.is_cross_build()
+	subdir('kernel')
+endif

[Hemant] actually kernel_dir may not be always available on host.
So unless kernel_dir is available - irrespective of host/cross - it
shall not try kernel compilation.

Well, for many native builds the kernel directory can be computed by looking at uname -r, but which won't work for cross-compilation. Given that there is already an option to disable kernel module compilation completely, I think that the default for native builds should be try and build modules for the running kernel.

Quoted 4 lines

However, we could certainly add in a check to see if the kernel sources are available, and optionally not build them in that case - i.e. convert the error due to non-existant kernel headers into a warning message. Do you think that might be a good compromise?

[Hemant] Yes. A warning instead of error is good in this case.

Quoted 2 lines

/Bruce

#6 lore raw

v2 cover small improvements to meson build

In reply to Bruce Richardson

A few small improvements and fixes for the meson build system, including improved behaviour for building kmods - especially on cross-compile, a fix for our libbsd detect on CentOS 7, and a small change to ensure compatibility with future meson versions.

Bruce Richardson (3):
build: fix kernel compile on cross-build
build: fix check for libbsd in meson
build: ensure compatibility with future meson versions

 config/meson.build               |  3 ++-
 kernel/linux/igb_uio/meson.build |  6 ------
 kernel/linux/meson.build         | 40 +++++++++++++++++++++++++++++++++++++---
 lib/meson.build                  |  2 +-
 meson.build                      |  6 +++++-
 5 files changed, 45 insertions(+), 12 deletions(-)
Signature · 1 line
2.14.3
#7 lore raw

PATCH v2 1/3 build: fix kernel compile on cross-build

When cross-compiling, if no kernel_dir was specified, then the kernel modules were still being compiled for the build machine. Fix this by only building modules on cross-compile when we have a kernel_dir value set. Print out a message indicating why we are skipping kernel compilation, and in case that the headers for kernel compile are not found, print a warning instead of erroring out.

Fixes a52f4574f798 ("igb_uio: build with meson")
---
 kernel/linux/igb_uio/meson.build |  6 ------
 kernel/linux/meson.build         | 40 +++++++++++++++++++++++++++++++++++++---
 meson.build                      |  6 +++++-
 3 files changed, 42 insertions(+), 10 deletions(-)
kernel/linux/igb_uio/meson.build +0 -6
index 356f4ab32..71ed2e7a8 100644
@@ -1,12 +1,6 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-kernel_dir = get_option('kernel_dir')
-if kernel_dir == ''
-	kernel_version = run_command('uname', '-r').stdout().strip()
-	kernel_dir = '/lib/modules/' + kernel_version + '/build'
-endif
-
 mkfile = custom_target('igb_uio_makefile',
 	output: 'Makefile',
 	command: ['touch', '@OUTPUT@'])
kernel/linux/meson.build +37 -3
index a5b88f0c6..a924c7b6f 100644
@@ -3,6 +3,40 @@
 
 subdirs = ['igb_uio']
 
-foreach d:subdirs
-	subdir(d)
-endforeach
+WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-compiling'
+WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
+
+# if we are cross-compiling we need kernel_dir specified
+# NOTE: warning() function only available from version 0.44 onwards
+if get_option('kernel_dir') == '' and meson.is_cross_build()
+	if meson.version().version_compare('>=0.44')
+		warning(WARN_CROSS_COMPILE)
+	else
+		message('WARNING: ' + WARN_CROSS_COMPILE)
+	endif
+else
+
+	kernel_dir = get_option('kernel_dir')
+	if kernel_dir == ''
+		# use default path for native builds
+		kernel_version = run_command('uname', '-r').stdout().strip()
+		kernel_dir = '/lib/modules/' + kernel_version + '/build'
+	endif
+
+	# test running make in kernel directory, using "make kernelversion"
+	make_returncode = run_command('make', '-sC', kernel_dir,
+			'kernelversion').returncode()
+	if make_returncode != 0
+		if meson.version().version_compare('>=0.44')
+			warning(WARN_NO_HEADERS)
+		else
+			message('WARNING: ' + WARN_NO_HEADERS)
+		endif
+	else # returncode == 0
+
+# DO ACTUAL MODULE BUILDING
+		foreach d:subdirs
+			subdir(d)
+		endforeach
+	endif
+endif
meson.build +5 -1
index cc16595cb..52a8746c5 100644
@@ -26,7 +26,6 @@ subdir('config')
 
 # build libs and drivers
 subdir('lib')
-subdir('kernel')
 subdir('buildtools')
 subdir('drivers')
 
@@ -40,6 +39,11 @@ if get_option('examples') != ''
 	subdir('examples')
 endif
 
+# build kernel modules if enabled
+if get_option('enable_kmods')
+	subdir('kernel')
+endif
+
 # write the build config
 build_cfg = 'rte_build_config.h'
 configure_file(output: build_cfg,
Signature · 1 line
2.14.3
#8 lore raw

PATCH v2 2/3 build: fix check for libbsd in meson

In reply to Bruce Richardson

When we check for libbsd we were just checking for the library itself. However, on some distros, e.g. CentOS, libbsd will be found even though it's not usable by DPDK as it's missing the string header. Therefore we should check for both the library and the header file.

Fixes 5364de644a4b ("eal: support strlcpy function")
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index 5815b5602..2179c689c 100644
@@ -43,7 +43,8 @@ if numa_dep.found() and cc.has_header('numaif.h')
 endif
 
 # check for strlcpy
-if host_machine.system() == 'linux' and cc.find_library('bsd', required: false).found()
+if host_machine.system() == 'linux' and cc.find_library('bsd',
+		required: false).found() and cc.has_header('bsd/string.h')
 	dpdk_conf.set('RTE_USE_LIBBSD', 1)
 	add_project_link_arguments('-lbsd', language: 'c')
 	dpdk_extra_ldflags += '-lbsd'
Signature · 1 line
2.14.3
#11 lore raw

PATCH v2 3/3 build: ensure compatibility with future meson versions

In reply to Bruce Richardson

Meson 0.46 fixed a bug where "extract_all_objects" would not recursively extract objects not compiled from source for a target. To keep backward compatibility, a "recursive" keyword-arg was added to make this optional. The value is "false" by default for now, but will change to "true" in future, so we hard-code it to "false" in our code to ensure future compatiblity.

---
 lib/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/meson.build +1 -1
index 73d6f25c7..ae445153b 100644
@@ -96,7 +96,7 @@ foreach l:libraries
 
 			# then use pre-build objects to build shared lib
 			sources = []
-			objs += static_lib.extract_all_objects()
+			objs += static_lib.extract_all_objects(recursive: false)
 			version_map = '@0@/@1@/rte_@2@_version.map'.format(
 					meson.current_source_dir(), dir_name, name)
 			shared_lib = shared_library(libname,
Signature · 1 line
2.14.3
#9 lore raw

Re: [PATCH v2 2/3] build: fix check for libbsd in meson

In reply to Bruce Richardson
Quoted 7 lines · Bruce Richardson

When we check for libbsd we were just checking for the library itself. However, on some distros, e.g. CentOS, libbsd will be found even though it's not usable by DPDK as it's missing the string header. Therefore we should check for both the library and the header file.

Fixes 5364de644a4b ("eal: support strlcpy function")

Sorry, forgot to add:

Quoted 22 lines
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index 5815b5602..2179c689c 100644
@@ -43,7 +43,8 @@ if numa_dep.found() and cc.has_header('numaif.h')
 endif
 
 # check for strlcpy
-if host_machine.system() == 'linux' and cc.find_library('bsd', required: false).found()
+if host_machine.system() == 'linux' and cc.find_library('bsd',
+		required: false).found() and cc.has_header('bsd/string.h')
 	dpdk_conf.set('RTE_USE_LIBBSD', 1)
 	add_project_link_arguments('-lbsd', language: 'c')
 	dpdk_extra_ldflags += '-lbsd'
Signature · 1 line
2.14.3
#12 lore raw

Re: [PATCH v2 0/3] small improvements to meson build

In reply to Bruce Richardson
Quoted 13 lines · Bruce Richardson

A few small improvements and fixes for the meson build system, including
improved behaviour for building kmods - especially on cross-compile, a fix
for our libbsd detect on CentOS 7, and a small change to ensure compatibility
with future meson versions.

Bruce Richardson (3):
  build: fix kernel compile on cross-build
  build: fix check for libbsd in meson
  build: ensure compatibility with future meson versions

Quoted 7 lines

 config/meson.build               |  3 ++-
 kernel/linux/igb_uio/meson.build |  6 ------
 kernel/linux/meson.build         | 40
+++++++++++++++++++++++++++++++++++++---
 lib/meson.build                  |  2 +-
 meson.build                      |  6 +++++-

 5 files changed, 45 insertions(+), 12 deletions(-)

LGTM!

Signature · 2 lines
Kind regards,
Luca Boccassi
#10 lore raw

Re: [PATCH v2 2/3] build: fix check for libbsd in meson

In reply to Bruce Richardson

Hi,

2018-04-27 16:51 GMT+03:00 Bruce Richardson <[email protected]>:

Quoted 25 lines · Bruce Richardson
Quoted 7 lines

When we check for libbsd we were just checking for the library itself. However, on some distros, e.g. CentOS, libbsd will be found even though it's not usable by DPDK as it's missing the string header. Therefore we should check for both the library and the header file.

Fixes 5364de644a4b ("eal: support strlcpy function")

Sorry, forgot to add:

Quoted 12 lines
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +0 -0
index 5815b5602..2179c689c 100644
@@ -43,7 +43,8 @@ if numa_dep.found() and cc.has_header('numaif.h')
 endif
 
Quoted 12 lines

config/meson.build if numa_dep.found() and cc.has_header('numaif.h') · line 46

Quoted 2 lines
config/meson.build +0 -1
 # check for strlcpy
-if host_machine.system() == 'linux' and cc.find_library('bsd',

required: false).found()

Quoted 8 lines
config/meson.build +2 -1
+if host_machine.system() == 'linux' and cc.find_library('bsd',
+             required: false).found() and cc.has_header('bsd/string.h')
      dpdk_conf.set('RTE_USE_LIBBSD', 1)
      add_project_link_arguments('-lbsd', language: 'c')
      dpdk_extra_ldflags += '-lbsd'
--

2.14.3

Signature · 2 lines
Regards,
Vladimir
#13 lore raw

Re: [PATCH v2 0/3] small improvements to meson build

In reply to Luca Boccassi
Quoted 22 lines · Luca Boccassi
Quoted 13 lines · Bruce Richardson

A few small improvements and fixes for the meson build system, including
improved behaviour for building kmods - especially on cross-compile, a fix
for our libbsd detect on CentOS 7, and a small change to ensure compatibility
with future meson versions.

Bruce Richardson (3):
  build: fix kernel compile on cross-build
  build: fix check for libbsd in meson
  build: ensure compatibility with future meson versions

Quoted 7 lines

 config/meson.build               |  3 ++-
 kernel/linux/igb_uio/meson.build |  6 ------
 kernel/linux/meson.build         | 40
+++++++++++++++++++++++++++++++++++++---
 lib/meson.build                  |  2 +-
 meson.build                      |  6 +++++-

 5 files changed, 45 insertions(+), 12 deletions(-)
Quoted 2 lines

Applied to dpdk-next-build

Bruce