[1/1] buildtools: remove absolute paths from pc file

Message ID 20240107154137.4909-1-syalavarthi@marvell.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [1/1] buildtools: remove absolute paths from pc file |

Checks

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

Commit Message

Srikanth Yalavarthi Jan. 7, 2024, 3:41 p.m. UTC
When linking with non-versioned libraries, absolute paths
of the libraries are added to libdpdk.pc. This patch replaces
the absolute path with correct linker flags, -l<libname>.

https://github.com/mesonbuild/meson/issues/7766

Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 buildtools/pkg-config/set-static-linker-flags.py | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Stephen Hemminger Oct. 9, 2024, 6:44 p.m. UTC | #1
On Sun, 7 Jan 2024 07:41:36 -0800
Srikanth Yalavarthi <syalavarthi@marvell.com> wrote:

> When linking with non-versioned libraries, absolute paths
> of the libraries are added to libdpdk.pc. This patch replaces
> the absolute path with correct linker flags, -l<libname>.
> 
> https://github.com/mesonbuild/meson/issues/7766
> 
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---

Bruce did you look at this?
  
Bruce Richardson Oct. 10, 2024, 8:02 a.m. UTC | #2
On Wed, Oct 09, 2024 at 11:44:12AM -0700, Stephen Hemminger wrote:
> On Sun, 7 Jan 2024 07:41:36 -0800
> Srikanth Yalavarthi <syalavarthi@marvell.com> wrote:
> 
> > When linking with non-versioned libraries, absolute paths
> > of the libraries are added to libdpdk.pc. This patch replaces
> > the absolute path with correct linker flags, -l<libname>.
> > 
> > https://github.com/mesonbuild/meson/issues/7766
> > 
> > Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> > ---
> 
> Bruce did you look at this?

No sorry, will take a look at it today.
  
Bruce Richardson Oct. 10, 2024, 1:57 p.m. UTC | #3
On Sun, Jan 07, 2024 at 07:41:36AM -0800, Srikanth Yalavarthi wrote:
> When linking with non-versioned libraries, absolute paths
> of the libraries are added to libdpdk.pc. This patch replaces
> the absolute path with correct linker flags, -l<libname>.
> 
> https://github.com/mesonbuild/meson/issues/7766
> 
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---
>  buildtools/pkg-config/set-static-linker-flags.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/buildtools/pkg-config/set-static-linker-flags.py b/buildtools/pkg-config/set-static-linker-flags.py
> index 2745db34c29..e8804353383 100644
> --- a/buildtools/pkg-config/set-static-linker-flags.py
> +++ b/buildtools/pkg-config/set-static-linker-flags.py
> @@ -9,6 +9,8 @@
>  
>  
>  def fix_ldflag(f):
> +    if (f.startswith('/') and (f.endswith('.so') or f.endswith('.a'))):
> +        return f.split('/', -1)[-1].split('.', -1)[0].replace('lib', '-l', 1)
>      if not f.startswith('-lrte_'):
>          return f
>      return '-l:lib' + f[2:] + '.a'
> -- 
On initial reading this change looks harmless, however, I'm not exactly
clear where it is needed. What libraries are getting added to the PC files
with full paths?
Also, does this only apply to all versions of meson or has it been fixed in
later ones?

Thanks,
/Bruce
  

Patch

diff --git a/buildtools/pkg-config/set-static-linker-flags.py b/buildtools/pkg-config/set-static-linker-flags.py
index 2745db34c29..e8804353383 100644
--- a/buildtools/pkg-config/set-static-linker-flags.py
+++ b/buildtools/pkg-config/set-static-linker-flags.py
@@ -9,6 +9,8 @@ 
 
 
 def fix_ldflag(f):
+    if (f.startswith('/') and (f.endswith('.so') or f.endswith('.a'))):
+        return f.split('/', -1)[-1].split('.', -1)[0].replace('lib', '-l', 1)
     if not f.startswith('-lrte_'):
         return f
     return '-l:lib' + f[2:] + '.a'