patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 19.11] buildtools: get static mlx dependencies for meson
@ 2020-06-10 14:02 Thomas Monjalon
  2020-06-10 14:40 ` Luca Boccassi
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Monjalon @ 2020-06-10 14:02 UTC (permalink / raw)
  To: stable
  Cc: bluca, Bruce Richardson, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko

[ upstream commit 2cca60310a0bca86483e3b62a1143a50f7484069 ]

The shell script options-ibverbs-static.sh was used with make
in forcing static linkage of ibverbs libraries.

When choosing to link with a static dependency in meson,
the generated .pc file will not force such static linkage.
The solution will rely on using this script in meson.

If linking with libraries installed in a non-standard path,
an option -L is provided via EXTRA_LDFLAGS in case of using make.
With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
When statically linking an application, the .pc file must save the
-L path so the application link will work without any extra option.
That's why --libs-only-l is replaced with --libs which includes -L.
Options which are neither -l or -L are filtered out because not needed
and can cause compilation issues with the legacy system using make.

The other change in this script is to drop the first occurrences of the
main library file (libiverbs.a). Only the last occurrence is kept.
It fixes some undefined references when linking a static application
using libdpdk.pc.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---

The patches
	net/mlx: add static ibverbs linkage with meson
and
	net/mlx: workaround static linkage with meson
were backported in 19.11 without this patch,
so static ibverbs linkage with meson is broken (libs not found).

---
 buildtools/options-ibverbs-static.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
index 0f285a343b..0740a711ff 100755
--- a/buildtools/options-ibverbs-static.sh
+++ b/buildtools/options-ibverbs-static.sh
@@ -9,6 +9,13 @@
 #
 # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
 
-pkg-config --libs-only-l --static libibverbs |
+lib='libibverbs'
+deps='pthread|nl'
+
+pkg-config --libs --static $lib |
 	tr '[:space:]' '\n' |
-	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
+	sed -n '/^-[Ll]/p' |   # extra link options may break with make
+	tac |
+	awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
+	tac
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH 19.11] buildtools: get static mlx dependencies for meson
  2020-06-10 14:02 [dpdk-stable] [PATCH 19.11] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-06-10 14:40 ` Luca Boccassi
  0 siblings, 0 replies; 2+ messages in thread
From: Luca Boccassi @ 2020-06-10 14:40 UTC (permalink / raw)
  To: Thomas Monjalon, stable
  Cc: Bruce Richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Wed, 2020-06-10 at 16:02 +0200, Thomas Monjalon wrote:
> [ upstream commit 2cca60310a0bca86483e3b62a1143a50f7484069 ]
> 
> The shell script options-ibverbs-static.sh was used with make
> in forcing static linkage of ibverbs libraries.
> 
> When choosing to link with a static dependency in meson,
> the generated .pc file will not force such static linkage.
> The solution will rely on using this script in meson.
> 
> If linking with libraries installed in a non-standard path,
> an option -L is provided via EXTRA_LDFLAGS in case of using make.
> With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
> When statically linking an application, the .pc file must save the
> -L path so the application link will work without any extra option.
> That's why --libs-only-l is replaced with --libs which includes -L.
> Options which are neither -l or -L are filtered out because not needed
> and can cause compilation issues with the legacy system using make.
> 
> The other change in this script is to drop the first occurrences of the
> main library file (libiverbs.a). Only the last occurrence is kept.
> It fixes some undefined references when linking a static application
> using libdpdk.pc.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> 
> The patches
> 	net/mlx: add static ibverbs linkage with meson
> and
> 	net/mlx: workaround static linkage with meson
> were backported in 19.11 without this patch,
> so static ibverbs linkage with meson is broken (libs not found).
> 
> ---
>  buildtools/options-ibverbs-static.sh | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
> index 0f285a343b..0740a711ff 100755
> --- a/buildtools/options-ibverbs-static.sh
> +++ b/buildtools/options-ibverbs-static.sh
> @@ -9,6 +9,13 @@
>  #
>  # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
>  
> -pkg-config --libs-only-l --static libibverbs |
> +lib='libibverbs'
> +deps='pthread|nl'
> +
> +pkg-config --libs --static $lib |
>  	tr '[:space:]' '\n' |
> -	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
> +	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
> +	sed -n '/^-[Ll]/p' |   # extra link options may break with make
> +	tac |
> +	awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
> +	tac

Thanks, applied and pushed.

-- 
Kind regards,
Luca Boccassi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-10 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 14:02 [dpdk-stable] [PATCH 19.11] buildtools: get static mlx dependencies for meson Thomas Monjalon
2020-06-10 14:40 ` Luca Boccassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).