From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6E7F4A0567; Tue, 9 Mar 2021 17:26:39 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED4344069D; Tue, 9 Mar 2021 17:26:38 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id DDFF84068A for ; Tue, 9 Mar 2021 17:26:37 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d23so3621177plq.2 for ; Tue, 09 Mar 2021 08:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=vKLyu7fg1dVw7obIVjtK+jPZ6zqpq0vBArnU79z6CDU=; b=LdXkzx8okltFeQXIhF7fMkDquX1lTsMnJnlJszFTH94W1CFDq/K6q+Qqi92sMncH3/ wVzrCazD/HCWNMSaDP4bM1bfZps2XNV/R0WZtRSToPiO1bmMQAPR33ohblgzCSc6DHcX LaYuDk9IkEgaMRQbmngfQChMeFwYz6JKwp1nmlvsIBLsE/hbUpgbeoA3DBv8r1S5StIr uquoAjn9evogzzrEZtF3k4gkLX26ijgbFuEVABQZZ9qdWK3sLenUG9wm1rombIkW1ASD pm+PCwcdrYhMDi88E8P+vS2gHUrES52SsHDZaO3Sd3aNjkFR0M5Eh+EJeaTt+4tQRMk4 3q8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=vKLyu7fg1dVw7obIVjtK+jPZ6zqpq0vBArnU79z6CDU=; b=Pp466Z1qbi3yl4SVLKY1WWcMnTO0/KcFTHLFKojG2n9RnSkqWywLUrn6WWUYaWSV6R I41/B4Uqi/aoDP3NTWromB2Lm6Qjpac9/WdFdU8TCV7XaeNLWu7A0gCOwpJUYiGB2ook sFLgYEV4oCzrYN/mGTgbhgF0LZ2VfSPcEKExvmANohSj87HHOcelsBUUQft2mXJQ+wtV 1TiuWY2GIB0iY6h/13LgeDtbgTX3fjo1tH8WqNb8/heH+6KjEo2uslN9LVx9zkPSS9V5 pa0MCXxINynoRq3WZiAQ/bMReFAFhysWzf87V+HfasSWA1h+CsgXZnaZjR7t1m9/ZpbS RHFw== X-Gm-Message-State: AOAM532GbC8bVh4WDBpvWSF/QCnuOrbdYcaOlxUgERzAMehZG1xppg5y 7x+4MmshB4kcAj7hK+VsP8MHrg== X-Google-Smtp-Source: ABdhPJxHQilKkATOfO+Hul1zsD7N/tFUK8pT/cKRzV2kJhAzW7d8DXMrQsvlFLECGfeLHHV6L5k1bQ== X-Received: by 2002:a17:902:f686:b029:e5:de44:af60 with SMTP id l6-20020a170902f686b02900e5de44af60mr4575290plg.64.1615307197011; Tue, 09 Mar 2021 08:26:37 -0800 (PST) Received: from ?IPv6:2600:1700:6b0:fde0:7512:6a17:46b0:7909? ([2600:1700:6b0:fde0:7512:6a17:46b0:7909]) by smtp.gmail.com with ESMTPSA id r10sm14259305pfq.216.2021.03.09.08.26.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Mar 2021 08:26:36 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) From: Andrew Boyer In-Reply-To: <96470a26077149d19cfa94d23d07a4ea@pantheon.tech> Date: Tue, 9 Mar 2021 11:26:33 -0500 Cc: "bruce.richardson@intel.com" , "thomas@monjalon.net" , "Ruifeng.Wang@arm.com" , "Honnappa.Nagarahalli@arm.com" , "jerinjacobk@gmail.com" , "hemant.agrawal@nxp.com" , "ferruh.yigit@intel.com" , "dev@dpdk.org" Content-Transfer-Encoding: quoted-printable Message-Id: <42F9D053-C16A-4F85-BB64-B9047B4C699C@pensando.io> References: <1612860425-27646-1-git-send-email-juraj.linkes@pantheon.tech> <1613048386-655-1-git-send-email-juraj.linkes@pantheon.tech> <96470a26077149d19cfa94d23d07a4ea@pantheon.tech> To: =?utf-8?Q?Juraj_Linke=C5=A1?= X-Mailer: Apple Mail (2.3654.60.0.2.21) Subject: Re: [dpdk-dev] [PATCH v6] build: kni cross-compilation support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" No, I am sorry, I have not tested it. I was able to remove rte_kni from = our requirements so this is no longer a blocker for us. -Andrew > On Mar 9, 2021, at 3:47 AM, Juraj Linke=C5=A1 = wrote: >=20 > Hi Folks, >=20 > Does anyone have any comments? Is the patch ready? If so, please send = acks or reviewed-by, thanks. >=20 > Andrew, did you get a chance to test the patch? >=20 > Juraj >=20 >> -----Original Message----- >> From: Juraj Linke=C5=A1 >> Sent: Thursday, February 11, 2021 2:00 PM >> To: bruce.richardson@intel.com; thomas@monjalon.net; >> Ruifeng.Wang@arm.com; Honnappa.Nagarahalli@arm.com; >> jerinjacobk@gmail.com; hemant.agrawal@nxp.com; = ferruh.yigit@intel.com; >> aboyer@pensando.io >> Cc: dev@dpdk.org; Juraj Linke=C5=A1 >> Subject: [PATCH v6] build: kni cross-compilation support >>=20 >> The kni linux module is using a custom target for building, which = doesn't take >> into account any cross compilation arguments. The arguments in = question are >> ARCH, CROSS_COMPILE (for gcc, clang) and CC, LD (for clang). Get = those from >> the cross file and pass them to the custom target. >>=20 >> The user supplied path may not contain the 'build' directory, such as = when using >> cross-compiled headers, so only append that in the default case (when = no path is >> supplied in native builds) and use the unmodified path from the user = otherwise. >> Also modify the install path accordingly. >>=20 >> Signed-off-by: Juraj Linke=C5=A1 >> Reviewed-by: Bruce Richardson >> --- >> kernel/linux/kni/meson.build | 8 ++-- >> kernel/linux/meson.build | 90 = ++++++++++++++++++++++++++++++------ >> meson_options.txt | 2 +- >> 3 files changed, 82 insertions(+), 18 deletions(-) >>=20 >> diff --git a/kernel/linux/kni/meson.build = b/kernel/linux/kni/meson.build index >> 07e0c9dae7..46b71c7418 100644 >> --- a/kernel/linux/kni/meson.build >> +++ b/kernel/linux/kni/meson.build >> @@ -13,7 +13,7 @@ kni_sources =3D files( >> custom_target('rte_kni', >> input: kni_sources, >> output: 'rte_kni.ko', >> - command: ['make', '-j4', '-C', kernel_dir + '/build', >> + command: ['make', '-j4', '-C', kernel_build_dir, >> 'M=3D' + meson.current_build_dir(), >> 'src=3D' + meson.current_source_dir(), >> 'MODULE_CFLAGS=3D-include ' + meson.source_root() + >> '/config/rte_config.h' + @@ -21,8 +21,8 @@ custom_target('rte_kni', >> ' -I' + meson.source_root() + '/lib/librte_kni' + >> ' -I' + meson.build_root() + >> ' -I' + meson.current_source_dir(), >> - 'modules'], >> + 'modules'] + cross_args, >> depends: kni_mkfile, >> - install: true, >> - install_dir: kernel_dir + '/extra/dpdk', >> + install: install, >> + install_dir: kernel_install_dir, >> build_by_default: get_option('enable_kmods')) diff --git >> a/kernel/linux/meson.build b/kernel/linux/meson.build index >> 5c864a4653..7b15e0fd44 100644 >> --- a/kernel/linux/meson.build >> +++ b/kernel/linux/meson.build >> @@ -3,25 +3,89 @@ >>=20 >> subdirs =3D ['kni'] >>=20 >> -# if we are cross-compiling we need kernel_dir specified -if >> get_option('kernel_dir') =3D=3D '' and meson.is_cross_build() >> - error('Need "kernel_dir" option for kmod compilation when cross- >> compiling') >> -endif >> +kernel_build_dir =3D get_option('kernel_dir') kernel_install_dir =3D = '' >> +install =3D not meson.is_cross_build() >> +cross_args =3D [] >>=20 >> -kernel_dir =3D get_option('kernel_dir') >> -if kernel_dir =3D=3D '' >> - # use default path for native builds >> +if not meson.is_cross_build() >> + # native build >> kernel_version =3D run_command('uname', '-r').stdout().strip() >> - kernel_dir =3D '/lib/modules/' + kernel_version >> + kernel_install_dir =3D '/lib/modules/' + kernel_version + = '/extra/dpdk' >> + if kernel_build_dir =3D=3D '' >> + # use default path for native builds >> + kernel_build_dir =3D '/lib/modules/' + kernel_version + = '/build' >> + endif >> + >> + # test running make in kernel directory, using "make = kernelversion" >> + make_returncode =3D run_command('make', '-sC', kernel_build_dir, >> + 'kernelversion').returncode() >> + if make_returncode !=3D 0 >> + # backwards compatibility: >> + # the headers could still be in the 'build' subdir >> + if not kernel_build_dir.endswith('build') and not >> kernel_build_dir.endswith('build/') >> + kernel_build_dir =3D = join_paths(kernel_build_dir, 'build') >> + make_returncode =3D run_command('make', '-sC', >> kernel_build_dir, >> + 'kernelversion').returncode() >> + endif >> + endif >> + >> + if make_returncode !=3D 0 >> + error('Cannot compile kernel modules as requested - are = kernel >> headers installed?') >> + endif >> + >> + # DO ACTUAL MODULE BUILDING >> + foreach d:subdirs >> + subdir(d) >> + endforeach >> + >> + subdir_done() >> endif >>=20 >> -# test running make in kernel directory, using "make kernelversion" >> -make_returncode =3D run_command('make', '-sC', kernel_dir + = '/build', >> - 'kernelversion').returncode() >> -if make_returncode !=3D 0 >> - error('Cannot compile kernel modules as requested - are kernel = headers >> installed?') >> +# cross build >> +# if we are cross-compiling we need kernel_build_dir specified if >> +kernel_build_dir =3D=3D '' >> + error('Need "kernel_dir" option for kmod compilation when >> +cross-compiling') endif cross_compiler =3D find_program('c').path() = if >> +cross_compiler.endswith('gcc') >> + cross_prefix =3D run_command([py3, '-c', 'print("' + = cross_compiler + >> +'"[:-3])']).stdout().strip() elif cross_compiler.endswith('clang') >> + cross_prefix =3D '' >> + found_target =3D false >> + # search for '-target' and use the arg that follows >> + # (i.e. the value of '-target') as cross_prefix >> + foreach cross_c_arg : meson.get_cross_property('c_args') >> + if found_target and cross_prefix =3D=3D '' >> + cross_prefix =3D cross_c_arg >> + endif >> + if cross_c_arg =3D=3D '-target' >> + found_target =3D true >> + endif >> + endforeach >> + if cross_prefix =3D=3D '' >> + error('Didn\'t find -target and its value in' + >> + ' c_args in input cross-file.') >> + endif >> + linker =3D 'lld' >> + foreach cross_c_link_arg : = meson.get_cross_property('c_link_args') >> + if cross_c_link_arg.startswith('-fuse-ld') >> + linker =3D cross_c_link_arg.split('=3D')[1] >> + endif >> + endforeach >> + cross_args +=3D ['CC=3D@0@'.format(cross_compiler), >> +'LD=3Dld.@0@'.format(linker)] else >> + error('Unsupported cross compiler: @0@'.format(cross_compiler)) >> endif >>=20 >> +cross_arch =3D host_machine.cpu_family() >> +if host_machine.cpu_family() =3D=3D 'aarch64' >> + cross_arch =3D 'arm64' >> +endif >> + >> +cross_args +=3D ['ARCH=3D@0@'.format(cross_arch), >> + 'CROSS_COMPILE=3D@0@'.format(cross_prefix)] >> + >> # DO ACTUAL MODULE BUILDING >> foreach d:subdirs >> subdir(d) >> diff --git a/meson_options.txt b/meson_options.txt index >> 6eff62e47d..3b8c5d316d 100644 >> --- a/meson_options.txt >> +++ b/meson_options.txt >> @@ -19,7 +19,7 @@ option('ibverbs_link', type: 'combo', choices : = ['static', >> 'shared', 'dlopen'], 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. = Headers >> +must be in $kernel_dir or $kernel_dir/build. Modules will be = installed >> +in /lib/modules.') >> option('machine', type: 'string', value: 'native', >> description: 'set the target machine type') = option('max_ethports', type: >> 'integer', value: 32, >> -- >> 2.20.1 >=20