[v2] kernel/linux: fix kernel dir for meson

Message ID 20191203052917.19820-1-xiaolong.ye@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] kernel/linux: fix kernel dir for meson |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Xiaolong Ye Dec. 3, 2019, 5:29 a.m. UTC
  kernel_dir option in meson build is equivalent to RTE_KERNELDIR in make
system, for cross-compilation case, users would specify it as local
kernel src dir like

/<user local dir>/target-arm_glibc/linux-arm/linux-4.19.81/

Current meson build would fail to compile kernel module if user specify
kernel_dir as above, this patch fixes this issue.

Fixes: 317832f97c16 ("kernel/linux: fix modules install path")
Cc: stable@dpdk.org
Cc: iryzhov@nfware.com

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---

V2 changes:

1. handle both normal and cross-compilation cases

 kernel/linux/igb_uio/meson.build |  4 ++--
 kernel/linux/kni/meson.build     |  4 ++--
 kernel/linux/meson.build         | 11 +++++++++--
 meson_options.txt                |  2 +-
 4 files changed, 14 insertions(+), 7 deletions(-)
  

Comments

Bruce Richardson Dec. 3, 2019, 10:11 a.m. UTC | #1
On Tue, Dec 03, 2019 at 01:29:17PM +0800, Xiaolong Ye wrote:
> kernel_dir option in meson build is equivalent to RTE_KERNELDIR in make
> system, for cross-compilation case, users would specify it as local
> kernel src dir like
> 
> /<user local dir>/target-arm_glibc/linux-arm/linux-4.19.81/
> 
> Current meson build would fail to compile kernel module if user specify
> kernel_dir as above, this patch fixes this issue.
> 
> Fixes: 317832f97c16 ("kernel/linux: fix modules install path")
> Cc: stable@dpdk.org
> Cc: iryzhov@nfware.com
> 
> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
> ---
> 
> V2 changes:
> 
> 1. handle both normal and cross-compilation cases
> 
We need to handle both, but they need to be handled without breaking the
currently working case where we pass in /lib/modules/$(uname -r)/ as the
kerneldir path.

/Bruce
  
Xiaolong Ye Dec. 3, 2019, 12:33 p.m. UTC | #2
On 12/03, Bruce Richardson wrote:
>On Tue, Dec 03, 2019 at 01:29:17PM +0800, Xiaolong Ye wrote:
>> kernel_dir option in meson build is equivalent to RTE_KERNELDIR in make
>> system, for cross-compilation case, users would specify it as local
>> kernel src dir like
>> 
>> /<user local dir>/target-arm_glibc/linux-arm/linux-4.19.81/
>> 
>> Current meson build would fail to compile kernel module if user specify
>> kernel_dir as above, this patch fixes this issue.
>> 
>> Fixes: 317832f97c16 ("kernel/linux: fix modules install path")
>> Cc: stable@dpdk.org
>> Cc: iryzhov@nfware.com
>> 
>> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
>> ---
>> 
>> V2 changes:
>> 
>> 1. handle both normal and cross-compilation cases
>> 
>We need to handle both, but they need to be handled without breaking the
>currently working case where we pass in /lib/modules/$(uname -r)/ as the
>kerneldir path.

So you mean we should allow user to specify both /lib/modules/$(uname -r) and
/lib/modules/$(uname -r)/build as kernel_dir for normal case?

Thanks,
Xiaolong

>
>/Bruce
  
Bruce Richardson Dec. 3, 2019, 1:58 p.m. UTC | #3
On Tue, Dec 03, 2019 at 08:33:22PM +0800, Ye Xiaolong wrote:
> On 12/03, Bruce Richardson wrote:
> >On Tue, Dec 03, 2019 at 01:29:17PM +0800, Xiaolong Ye wrote:
> >> kernel_dir option in meson build is equivalent to RTE_KERNELDIR in make
> >> system, for cross-compilation case, users would specify it as local
> >> kernel src dir like
> >> 
> >> /<user local dir>/target-arm_glibc/linux-arm/linux-4.19.81/
> >> 
> >> Current meson build would fail to compile kernel module if user specify
> >> kernel_dir as above, this patch fixes this issue.
> >> 
> >> Fixes: 317832f97c16 ("kernel/linux: fix modules install path")
> >> Cc: stable@dpdk.org
> >> Cc: iryzhov@nfware.com
> >> 
> >> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
> >> ---
> >> 
> >> V2 changes:
> >> 
> >> 1. handle both normal and cross-compilation cases
> >> 
> >We need to handle both, but they need to be handled without breaking the
> >currently working case where we pass in /lib/modules/$(uname -r)/ as the
> >kerneldir path.
> 
> So you mean we should allow user to specify both /lib/modules/$(uname -r) and
> /lib/modules/$(uname -r)/build as kernel_dir for normal case?
> 
That is up to you, but we need to still allow the former case so as to
avoid breaking backward compatibility for existing build setups. Therefore
I suggest supporting both is recommended.

/Bruce
  
Xiaolong Ye Dec. 3, 2019, 3:01 p.m. UTC | #4
On 12/03, Bruce Richardson wrote:
>On Tue, Dec 03, 2019 at 08:33:22PM +0800, Ye Xiaolong wrote:
>> On 12/03, Bruce Richardson wrote:
>> >On Tue, Dec 03, 2019 at 01:29:17PM +0800, Xiaolong Ye wrote:
>> >> kernel_dir option in meson build is equivalent to RTE_KERNELDIR in make
>> >> system, for cross-compilation case, users would specify it as local
>> >> kernel src dir like
>> >> 
>> >> /<user local dir>/target-arm_glibc/linux-arm/linux-4.19.81/
>> >> 
>> >> Current meson build would fail to compile kernel module if user specify
>> >> kernel_dir as above, this patch fixes this issue.
>> >> 
>> >> Fixes: 317832f97c16 ("kernel/linux: fix modules install path")
>> >> Cc: stable@dpdk.org
>> >> Cc: iryzhov@nfware.com
>> >> 
>> >> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
>> >> ---
>> >> 
>> >> V2 changes:
>> >> 
>> >> 1. handle both normal and cross-compilation cases
>> >> 
>> >We need to handle both, but they need to be handled without breaking the
>> >currently working case where we pass in /lib/modules/$(uname -r)/ as the
>> >kerneldir path.
>> 
>> So you mean we should allow user to specify both /lib/modules/$(uname -r) and
>> /lib/modules/$(uname -r)/build as kernel_dir for normal case?
>> 
>That is up to you, but we need to still allow the former case so as to
>avoid breaking backward compatibility for existing build setups. Therefore
>I suggest supporting both is recommended.

Make sense, I'll try a new version.

Thanks,
Xiaolong
>
>/Bruce
  

Patch

diff --git a/kernel/linux/igb_uio/meson.build b/kernel/linux/igb_uio/meson.build
index fac404f07..63990372e 100644
--- a/kernel/linux/igb_uio/meson.build
+++ b/kernel/linux/igb_uio/meson.build
@@ -8,7 +8,7 @@  mkfile = custom_target('igb_uio_makefile',
 custom_target('igb_uio',
 	input: ['igb_uio.c', 'Kbuild'],
 	output: 'igb_uio.ko',
-	command: ['make', '-C', kernel_dir + '/build',
+	command: ['make', '-C', kernel_dir,
 		'M=' + meson.current_build_dir(),
 		'src=' + meson.current_source_dir(),
 		'EXTRA_CFLAGS=-I' + meson.current_source_dir() +
@@ -16,5 +16,5 @@  custom_target('igb_uio',
 		'modules'],
 	depends: mkfile,
 	install: true,
-	install_dir: kernel_dir + '/extra/dpdk',
+	install_dir: install_base + '/extra/dpdk',
 	build_by_default: get_option('enable_kmods'))
diff --git a/kernel/linux/kni/meson.build b/kernel/linux/kni/meson.build
index 955eec949..04c817e8a 100644
--- a/kernel/linux/kni/meson.build
+++ b/kernel/linux/kni/meson.build
@@ -13,7 +13,7 @@  kni_sources = files(
 custom_target('rte_kni',
 	input: kni_sources,
 	output: 'rte_kni.ko',
-	command: ['make', '-j4', '-C', kernel_dir + '/build',
+	command: ['make', '-j4', '-C', kernel_dir,
 		'M=' + meson.current_build_dir(),
 		'src=' + meson.current_source_dir(),
 		'MODULE_CFLAGS=-include ' + meson.source_root() + '/config/rte_config.h' +
@@ -25,5 +25,5 @@  custom_target('rte_kni',
 	depends: kni_mkfile,
 	console: true,
 	install: true,
-	install_dir: kernel_dir + '/extra/dpdk',
+	install_dir: install_base + '/extra/dpdk',
 	build_by_default: get_option('enable_kmods'))
diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index 1796cc686..db50f79fe 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -13,17 +13,24 @@  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
+	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 + '/build',
+make_returncode = run_command('make', '-sC', kernel_dir,
 		'kernelversion').returncode()
 if make_returncode != 0
 	warning('Cannot compile kernel modules as requested - are kernel headers installed?')
 	subdir_done()
 endif
 
+if kernel_dir.endswith('build')
+	install_base = kernel_dir.split('build')[0]
+else
+	install_base = kernel_dir
+endif
+
+
 # DO ACTUAL MODULE BUILDING
 foreach d:subdirs
 	subdir(d)
diff --git a/meson_options.txt b/meson_options.txt
index bc369d06c..7eba3b720 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,7 +17,7 @@  option('ibverbs_link', type: 'combo', choices : ['shared', 'dlopen'], value: 'sh
 option('include_subdir_arch', type: 'string', value: '',
 	description: 'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '',
-	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir/build. Modules will be installed in $DEST_DIR/$kernel_dir/extra/dpdk.')
+	description: 'Path to the kernel for building kernel modules. Modules will be installed in $DEST_DIR/$kernel_dir/extra/dpdk.')
 option('lib_musdk_dir', type: 'string', value: '',
 	description: 'path to the MUSDK library installation directory')
 option('machine', type: 'string', value: 'native',