[v4,1/1] build: add libarchive to external deps

Message ID 20231103163853.29576-1-syalavarthi@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v4,1/1] build: add libarchive to external deps |

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Srikanth Yalavarthi Nov. 3, 2023, 4:38 p.m. UTC
  In order to avoid linking with Libs.private, libarchive
is not added to ext_deps during the meson setup stage.

Since libarchive is not added to ext_deps, cross-compilation
or native compilation with libarchive installed in non-standard
location fails with errors related to "cannot find -larchive"
or "archive.h: No such file or directory". In order to fix the
build failures, user is required to define the 'c_args' and
'c_link_args' with '-I<includedir>' and '-L<libdir>'.

This patch adds libarchive to ext_deps and further would not
require setting c_args and c_link_args externally.

Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
Cc: stable@dpdk.org

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
v4:
  - Rebase over latest main
v3:
  - Add to libarchive ext_deps
v2:
  - Update ml/cnxk meson config
v1:
  - Initial patch

 config/meson.build          | 5 -----
 drivers/ml/cnxk/meson.build | 1 +
 lib/eal/meson.build         | 3 +++
 3 files changed, 4 insertions(+), 5 deletions(-)
  

Comments

Bruce Richardson Nov. 3, 2023, 4:50 p.m. UTC | #1
On Fri, Nov 03, 2023 at 09:38:53AM -0700, Srikanth Yalavarthi wrote:
> In order to avoid linking with Libs.private, libarchive
> is not added to ext_deps during the meson setup stage.
> 
> Since libarchive is not added to ext_deps, cross-compilation
> or native compilation with libarchive installed in non-standard
> location fails with errors related to "cannot find -larchive"
> or "archive.h: No such file or directory". In order to fix the
> build failures, user is required to define the 'c_args' and
> 'c_link_args' with '-I<includedir>' and '-L<libdir>'.
> 
> This patch adds libarchive to ext_deps and further would not
> require setting c_args and c_link_args externally.
> 
> Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>

I think this is the cleanest solution to the problem you were having.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

One minor comment below. Patch is ok without taking it on board if you
like.

> ---
> v4:
>   - Rebase over latest main
> v3:
>   - Add to libarchive ext_deps
> v2:
>   - Update ml/cnxk meson config
> v1:
>   - Initial patch
> 
>  config/meson.build          | 5 -----
>  drivers/ml/cnxk/meson.build | 1 +
>  lib/eal/meson.build         | 3 +++
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/config/meson.build b/config/meson.build
> index 0968351740..250833d0a4 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -241,11 +241,6 @@ dpdk_conf.set('RTE_BACKTRACE', cc.has_header('execinfo.h') or is_windows)
>  libarchive = dependency('libarchive', required: false, method: 'pkg-config')
>  if libarchive.found()
>      dpdk_conf.set('RTE_HAS_LIBARCHIVE', 1)
> -    # Push libarchive link dependency at the project level to support
> -    # statically linking dpdk apps. Details at:
> -    # https://inbox.dpdk.org/dev/20210605004024.660267a1@sovereign/
> -    add_project_link_arguments('-larchive', language: 'c')
> -    dpdk_extra_ldflags += '-larchive'
>  endif
>  
>  # check for libbsd
> diff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build
> index 0680a0faa5..921dc7e89b 100644
> --- a/drivers/ml/cnxk/meson.build
> +++ b/drivers/ml/cnxk/meson.build
> @@ -67,6 +67,7 @@ sources += files(
>          'mvtvm_ml_model.c',
>  )
>  
> +ext_deps += libarchive

minor nit - I don't think this is necessary. If libarchive is found, then
DPDK eal will be linked against it, and so all other drivers should simply
have that as a transitive dependency.

Same probably applies to jansson.

>  ext_deps += jansson_dep
>  ext_deps += dlpack_dep
>  ext_deps += dmlc_dep
> diff --git a/lib/eal/meson.build b/lib/eal/meson.build
> index 9942104386..e1d6c4cf17 100644
> --- a/lib/eal/meson.build
> +++ b/lib/eal/meson.build
> @@ -21,6 +21,9 @@ endif
>  if dpdk_conf.has('RTE_USE_LIBBSD')
>      ext_deps += libbsd
>  endif
> +if dpdk_conf.has('RTE_HAS_LIBARCHIVE')
> +    ext_deps += libarchive
> +endif
>  if cc.has_function('getentropy', prefix : '#include <unistd.h>')
>      cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
>  endif
> -- 
> 2.42.0
>
  
Srikanth Yalavarthi Nov. 6, 2023, 4:27 a.m. UTC | #2
> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: 03 November 2023 22:21
> To: Srikanth Yalavarthi <syalavarthi@marvell.com>
> Cc: David Marchand <david.marchand@redhat.com>; Aaron Conole
> <aconole@redhat.com>; Igor Russkikh <irusskikh@marvell.com>;
> dev@dpdk.org; Shivah Shankar Shankar Narayan Rao
> <sshankarnara@marvell.com>; Anup Prabhu <aprabhu@marvell.com>;
> Prince Takkar <ptakkar@marvell.com>; stable@dpdk.org
> Subject: [EXT] Re: [PATCH v4 1/1] build: add libarchive to external deps
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Fri, Nov 03, 2023 at 09:38:53AM -0700, Srikanth Yalavarthi wrote:
> > In order to avoid linking with Libs.private, libarchive is not added
> > to ext_deps during the meson setup stage.
> >
> > Since libarchive is not added to ext_deps, cross-compilation or native
> > compilation with libarchive installed in non-standard location fails
> > with errors related to "cannot find -larchive"
> > or "archive.h: No such file or directory". In order to fix the build
> > failures, user is required to define the 'c_args' and 'c_link_args'
> > with '-I<includedir>' and '-L<libdir>'.
> >
> > This patch adds libarchive to ext_deps and further would not require
> > setting c_args and c_link_args externally.
> >
> > Fixes: 40edb9c0d36b ("eal: handle compressed firmware")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> 
> I think this is the cleanest solution to the problem you were having.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> One minor comment below. Patch is ok without taking it on board if you like.
> 
> > ---
> > v4:
> >   - Rebase over latest main
> > v3:
> >   - Add to libarchive ext_deps
> > v2:
> >   - Update ml/cnxk meson config
> > v1:
> >   - Initial patch
> >
> >  config/meson.build          | 5 -----
> >  drivers/ml/cnxk/meson.build | 1 +
> >  lib/eal/meson.build         | 3 +++
> >  3 files changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/config/meson.build b/config/meson.build index
> > 0968351740..250833d0a4 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -241,11 +241,6 @@ dpdk_conf.set('RTE_BACKTRACE',
> > cc.has_header('execinfo.h') or is_windows)  libarchive =
> > dependency('libarchive', required: false, method: 'pkg-config')  if
> libarchive.found()
> >      dpdk_conf.set('RTE_HAS_LIBARCHIVE', 1)
> > -    # Push libarchive link dependency at the project level to support
> > -    # statically linking dpdk apps. Details at:
> > -    # https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__inbox.dpdk.org_dev_20210605004024.660267a1-
> 40sovereign_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=SNPqUkGl0n_M
> s1iJa_6wD6LBwX8efL_NOyXvAX-iCMI&m=6Lg7j9wRNcl4gjqh1r9DHzydY-
> ufK1K63u-
> HpinJ3wSa4B3z1AUzWiaAsg3C5Cwp&s=PFchwx1MTzUrXGTLrJiy1bWDf4M7Y
> cSM8t3BNbGxLUg&e=
> > -    add_project_link_arguments('-larchive', language: 'c')
> > -    dpdk_extra_ldflags += '-larchive'
> >  endif
> >
> >  # check for libbsd
> > diff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build
> > index 0680a0faa5..921dc7e89b 100644
> > --- a/drivers/ml/cnxk/meson.build
> > +++ b/drivers/ml/cnxk/meson.build
> > @@ -67,6 +67,7 @@ sources += files(
> >          'mvtvm_ml_model.c',
> >  )
> >
> > +ext_deps += libarchive
> 
> minor nit - I don't think this is necessary. If libarchive is found, then DPDK eal
> will be linked against it, and so all other drivers should simply have that as a
> transitive dependency.

Agreed, this would not be necessary for libarchive. Removed in v5.
> 
> Same probably applies to jansson.

Jansson is added to ext_deps by lib/metrics. However, 'lib/metrics' is optional and can be disabled through -Ddisable_libs'
I think it would be good to add jansson_dep to ext_deps here to handle the case when 'lib/metrics' is disabled.

Also, I am working on change that would remove Jansson as a dependency for ml/cnxk. We will submit a separate patch for this.

> 
> >  ext_deps += jansson_dep
> >  ext_deps += dlpack_dep
> >  ext_deps += dmlc_dep
> > diff --git a/lib/eal/meson.build b/lib/eal/meson.build index
> > 9942104386..e1d6c4cf17 100644
> > --- a/lib/eal/meson.build
> > +++ b/lib/eal/meson.build
> > @@ -21,6 +21,9 @@ endif
> >  if dpdk_conf.has('RTE_USE_LIBBSD')
> >      ext_deps += libbsd
> >  endif
> > +if dpdk_conf.has('RTE_HAS_LIBARCHIVE')
> > +    ext_deps += libarchive
> > +endif
> >  if cc.has_function('getentropy', prefix : '#include <unistd.h>')
> >      cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
> >  endif
> > --
> > 2.42.0
> >
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 0968351740..250833d0a4 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -241,11 +241,6 @@  dpdk_conf.set('RTE_BACKTRACE', cc.has_header('execinfo.h') or is_windows)
 libarchive = dependency('libarchive', required: false, method: 'pkg-config')
 if libarchive.found()
     dpdk_conf.set('RTE_HAS_LIBARCHIVE', 1)
-    # Push libarchive link dependency at the project level to support
-    # statically linking dpdk apps. Details at:
-    # https://inbox.dpdk.org/dev/20210605004024.660267a1@sovereign/
-    add_project_link_arguments('-larchive', language: 'c')
-    dpdk_extra_ldflags += '-larchive'
 endif
 
 # check for libbsd
diff --git a/drivers/ml/cnxk/meson.build b/drivers/ml/cnxk/meson.build
index 0680a0faa5..921dc7e89b 100644
--- a/drivers/ml/cnxk/meson.build
+++ b/drivers/ml/cnxk/meson.build
@@ -67,6 +67,7 @@  sources += files(
         'mvtvm_ml_model.c',
 )
 
+ext_deps += libarchive
 ext_deps += jansson_dep
 ext_deps += dlpack_dep
 ext_deps += dmlc_dep
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 9942104386..e1d6c4cf17 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -21,6 +21,9 @@  endif
 if dpdk_conf.has('RTE_USE_LIBBSD')
     ext_deps += libbsd
 endif
+if dpdk_conf.has('RTE_HAS_LIBARCHIVE')
+    ext_deps += libarchive
+endif
 if cc.has_function('getentropy', prefix : '#include <unistd.h>')
     cflags += '-DRTE_LIBEAL_USE_GETENTROPY'
 endif