[v2] avoid libfdt checks adding full paths to pkg-config

Message ID 20200902123903.803110-1-christian.ehrhardt@canonical.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v2] avoid libfdt checks adding full paths to pkg-config |

Checks

Context Check Description
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/travis-robot warning Travis build: failed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch warning coding style issues

Commit Message

Christian Ehrhardt Sept. 2, 2020, 12:39 p.m. UTC
  The checks for libfdt try dependency() first which would only work if
a pkg-config would be present but libfdt has none.
Then it probes for the lib path itself via cc.find_library.

But later it adds the result of either probe to ext_deps which ends up
in build and also the resulting pkg-config to contain toolchain versioned
paths in Libs.private like:
  /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libfdt.so
which obviously breaks on toolchain updates.

In general libs used multiple times - ipn3ke + ifpga in this case - are
checked centrally in config/meson.build so move it there and fix the
adding of dependencies to not use the full file path.

The result is libfdt in pkg-config now showing up as:
  Libs.private: -pthread -lm -ldl -lnuma -lfdt -lpcap

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build             | 9 +++++++++
 drivers/net/ipn3ke/meson.build | 6 +-----
 drivers/raw/ifpga/meson.build  | 7 +------
 3 files changed, 11 insertions(+), 11 deletions(-)
  

Comments

Luca Boccassi Sept. 2, 2020, 1:57 p.m. UTC | #1
On Wed, 2020-09-02 at 14:39 +0200, Christian Ehrhardt wrote:
> The checks for libfdt try dependency() first which would only work if
> a pkg-config would be present but libfdt has none.
> Then it probes for the lib path itself via cc.find_library.
> 
> But later it adds the result of either probe to ext_deps which ends up
> in build and also the resulting pkg-config to contain toolchain versioned
> paths in Libs.private like:
>   /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libfdt.so
> which obviously breaks on toolchain updates.
> 
> In general libs used multiple times - ipn3ke + ifpga in this case - are
> checked centrally in config/meson.build so move it there and fix the
> adding of dependencies to not use the full file path.
> 
> The result is libfdt in pkg-config now showing up as:
>   Libs.private: -pthread -lm -ldl -lnuma -lfdt -lpcap
> 
> Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Reviewed-by: Luca Boccassi <bluca@debian.org>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/meson.build             | 9 +++++++++
>  drivers/net/ipn3ke/meson.build | 6 +-----
>  drivers/raw/ifpga/meson.build  | 7 +------
>  3 files changed, 11 insertions(+), 11 deletions(-)

Given this is low-risk and it fixes a build failure that is happening
right now in Debian/Ubuntu, I'll pick it up for 19.11.4 straight away.
  
David Marchand Sept. 2, 2020, 3:05 p.m. UTC | #2
On Wed, Sep 2, 2020 at 2:39 PM Christian Ehrhardt
<christian.ehrhardt@canonical.com> wrote:
>
> The checks for libfdt try dependency() first which would only work if
> a pkg-config would be present but libfdt has none.
> Then it probes for the lib path itself via cc.find_library.
>
> But later it adds the result of either probe to ext_deps which ends up
> in build and also the resulting pkg-config to contain toolchain versioned
> paths in Libs.private like:
>   /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libfdt.so
> which obviously breaks on toolchain updates.
>
> In general libs used multiple times - ipn3ke + ifpga in this case - are
> checked centrally in config/meson.build so move it there and fix the
> adding of dependencies to not use the full file path.
>
> The result is libfdt in pkg-config now showing up as:
>   Libs.private: -pthread -lm -ldl -lnuma -lfdt -lpcap
>
> Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> Reviewed-by: Luca Boccassi <bluca@debian.org>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/meson.build             | 9 +++++++++
>  drivers/net/ipn3ke/meson.build | 6 +-----
>  drivers/raw/ifpga/meson.build  | 7 +------
>  3 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/config/meson.build b/config/meson.build
> index cff8b33dd2..1c8317e750 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -150,6 +150,15 @@ if numa_dep.found() and cc.has_header('numaif.h')
>         dpdk_extra_ldflags += '-lnuma'
>  endif
>
> +has_libfdt = 0
> +fdt_dep = cc.find_library('libfdt', required: false)
> +if fdt_dep.found() and cc.has_header('fdt.h')
> +       dpdk_conf.set10('RTE_HAS_LIBFDT', true)
> +       has_libfdt = 1
> +       add_project_link_arguments('-lfdt', language: 'c')
> +       dpdk_extra_ldflags += '-lfdt'
> +endif
> +
>  # check for libbsd
>  libbsd = dependency('libbsd', required: false)
>  if libbsd.found()
> diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build
> index ec9cb7daf0..83611cfead 100644
> --- a/drivers/net/ipn3ke/meson.build
> +++ b/drivers/net/ipn3ke/meson.build
> @@ -9,11 +9,7 @@
>  #  rte_eth_switch_domain_free()
>  #
>
> -dep = dependency('libfdt', required: false)
> -if not dep.found()
> -       dep = cc.find_library('libfdt', required: false)
> -endif
> -if not dep.found()
> +if not has_libfdt

"not" expects a boolean, this can be seen in Travis and OBS builds for
Debian (at least 10 and Next).

OVS robot travis:
https://travis-ci.com/github/ovsrobot/dpdk/jobs/380310104#L721

My OBS:
[  143s] Compiler for C supports arguments -mavx2: YES (cached)
[  143s] Message: drivers/net/ice: Defining dependency "pmd_ice"
[  143s] Message: drivers/net/igc: Defining dependency "pmd_igc"
[  143s]
[  143s] ../drivers/net/ipn3ke/meson.build:12:7: ERROR: Argument to
"not" is not a boolean.
[  143s] dh_auto_configure: error: cd obj-x86_64-linux-gnu &&
LC_ALL=C.UTF-8 meson .. --wrap-mode=nodownload --buildtype=plain
--prefix=/usr --sysconfdir=/etc --localstatedir=/var
--libdir=lib/x86_64-linux-gnu --libexecdir=lib/x86_64-linux-gnu
--includedir=include/dpdk -Dper_library_versions=false
-Dinclude_subdir_arch=../x86_64-linux-gnu/dpdk -Dmachine=default
-Dkernel_dir=/lib/modules/5.7.0-3-amd64 -Denable_kmods=true returned
exit code 1
[  143s] make[2]: *** [debian/rules:114: override_dh_auto_configure] Error 25
[  143s] make[2]: Leaving directory '/usr/src/packages/BUILD'
[  143s] make[1]: *** [debian/rules:92: build] Error 2
[  143s] make[1]: Leaving directory '/usr/src/packages/BUILD'
[  143s] make: *** [debian/rules:96: binary] Error 2
  
Luca Boccassi Sept. 3, 2020, 9 a.m. UTC | #3
On Wed, 2020-09-02 at 17:05 +0200, David Marchand wrote:
> On Wed, Sep 2, 2020 at 2:39 PM Christian Ehrhardt
> <christian.ehrhardt@canonical.com> wrote:
> > The checks for libfdt try dependency() first which would only work if
> > a pkg-config would be present but libfdt has none.
> > Then it probes for the lib path itself via cc.find_library.
> > 
> > But later it adds the result of either probe to ext_deps which ends up
> > in build and also the resulting pkg-config to contain toolchain versioned
> > paths in Libs.private like:
> >   /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libfdt.so
> > which obviously breaks on toolchain updates.
> > 
> > In general libs used multiple times - ipn3ke + ifpga in this case - are
> > checked centrally in config/meson.build so move it there and fix the
> > adding of dependencies to not use the full file path.
> > 
> > The result is libfdt in pkg-config now showing up as:
> >   Libs.private: -pthread -lm -ldl -lnuma -lfdt -lpcap
> > 
> > Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
> > Reviewed-by: Luca Boccassi <bluca@debian.org>
> > Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >  config/meson.build             | 9 +++++++++
> >  drivers/net/ipn3ke/meson.build | 6 +-----
> >  drivers/raw/ifpga/meson.build  | 7 +------
> >  3 files changed, 11 insertions(+), 11 deletions(-)
> > 
> > diff --git a/config/meson.build b/config/meson.build
> > index cff8b33dd2..1c8317e750 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -150,6 +150,15 @@ if numa_dep.found() and cc.has_header('numaif.h')
> >         dpdk_extra_ldflags += '-lnuma'
> >  endif
> > 
> > +has_libfdt = 0
> > +fdt_dep = cc.find_library('libfdt', required: false)
> > +if fdt_dep.found() and cc.has_header('fdt.h')
> > +       dpdk_conf.set10('RTE_HAS_LIBFDT', true)
> > +       has_libfdt = 1
> > +       add_project_link_arguments('-lfdt', language: 'c')
> > +       dpdk_extra_ldflags += '-lfdt'
> > +endif
> > +
> >  # check for libbsd
> >  libbsd = dependency('libbsd', required: false)
> >  if libbsd.found()
> > diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build
> > index ec9cb7daf0..83611cfead 100644
> > --- a/drivers/net/ipn3ke/meson.build
> > +++ b/drivers/net/ipn3ke/meson.build
> > @@ -9,11 +9,7 @@
> >  #  rte_eth_switch_domain_free()
> >  #
> > 
> > -dep = dependency('libfdt', required: false)
> > -if not dep.found()
> > -       dep = cc.find_library('libfdt', required: false)
> > -endif
> > -if not dep.found()
> > +if not has_libfdt
> 
> "not" expects a boolean, this can be seen in Travis and OBS builds for
> Debian (at least 10 and Next).
> 
> OVS robot travis:
> https://travis-ci.com/github/ovsrobot/dpdk/jobs/380310104#L721
> 
> My OBS:
> [  143s] Compiler for C supports arguments -mavx2: YES (cached)
> [  143s] Message: drivers/net/ice: Defining dependency "pmd_ice"
> [  143s] Message: drivers/net/igc: Defining dependency "pmd_igc"
> [  143s]
> [  143s] ../drivers/net/ipn3ke/meson.build:12:7: ERROR: Argument to
> "not" is not a boolean.
> [  143s] dh_auto_configure: error: cd obj-x86_64-linux-gnu &&
> LC_ALL=C.UTF-8 meson .. --wrap-mode=nodownload --buildtype=plain
> --prefix=/usr --sysconfdir=/etc --localstatedir=/var
> --libdir=lib/x86_64-linux-gnu --libexecdir=lib/x86_64-linux-gnu
> --includedir=include/dpdk -Dper_library_versions=false
> -Dinclude_subdir_arch=../x86_64-linux-gnu/dpdk -Dmachine=default
> -Dkernel_dir=/lib/modules/5.7.0-3-amd64 -Denable_kmods=true returned
> exit code 1
> [  143s] make[2]: *** [debian/rules:114: override_dh_auto_configure] Error 25
> [  143s] make[2]: Leaving directory '/usr/src/packages/BUILD'
> [  143s] make[1]: *** [debian/rules:92: build] Error 2
> [  143s] make[1]: Leaving directory '/usr/src/packages/BUILD'
> [  143s] make: *** [debian/rules:96: binary] Error 2

Yep found the same issue - we should take v1 then
  

Patch

diff --git a/config/meson.build b/config/meson.build
index cff8b33dd2..1c8317e750 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -150,6 +150,15 @@  if numa_dep.found() and cc.has_header('numaif.h')
 	dpdk_extra_ldflags += '-lnuma'
 endif
 
+has_libfdt = 0
+fdt_dep = cc.find_library('libfdt', required: false)
+if fdt_dep.found() and cc.has_header('fdt.h')
+	dpdk_conf.set10('RTE_HAS_LIBFDT', true)
+	has_libfdt = 1
+	add_project_link_arguments('-lfdt', language: 'c')
+	dpdk_extra_ldflags += '-lfdt'
+endif
+
 # check for libbsd
 libbsd = dependency('libbsd', required: false)
 if libbsd.found()
diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build
index ec9cb7daf0..83611cfead 100644
--- a/drivers/net/ipn3ke/meson.build
+++ b/drivers/net/ipn3ke/meson.build
@@ -9,11 +9,7 @@ 
 #  rte_eth_switch_domain_free()
 #
 
-dep = dependency('libfdt', required: false)
-if not dep.found()
-	dep = cc.find_library('libfdt', required: false)
-endif
-if not dep.found()
+if not has_libfdt
 	build = false
 	reason = 'missing dependency, "libfdt"'
 	subdir_done()
diff --git a/drivers/raw/ifpga/meson.build b/drivers/raw/ifpga/meson.build
index 05a1711b5d..8e705ac888 100644
--- a/drivers/raw/ifpga/meson.build
+++ b/drivers/raw/ifpga/meson.build
@@ -1,11 +1,7 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
-dep = dependency('libfdt', required: false)
-if not dep.found()
-	dep = cc.find_library('libfdt', required: false)
-endif
-if not dep.found()
+if not has_libfdt
 	build = false
 	reason = 'missing dependency, "libfdt"'
 	subdir_done()
@@ -16,7 +12,6 @@  objs = [base_objs]
 
 deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
 	'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
-ext_deps += dep
 
 sources = files('ifpga_rawdev.c')