DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf
@ 2026-10-15 10:09 Robin Jarry
  2026-10-15 10:09 ` [PATCH dpdk 1/2] meson: rename static drivers list Robin Jarry
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 10:09 UTC (permalink / raw)
  To: dev

When building against dynamic libraries using pkg-config, linking fails
because symbols exposed by drivers are not found:

	/usr/bin/x86_64-linux-gnu-ld.bfd: ....o:(.data.rel.ro+0x148):
		undefined reference to `rte_pci_dump'

That symbol is in librte_bus_pci.so which is *not* listed in the libs
section of the pkg-config file.

This series is about fixing this.

Robin Jarry (2):
  meson: rename static drivers list
  meson: add drivers to dynamic libraries

 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 2 +-
 buildtools/subproject/meson.build | 2 +-
 drivers/meson.build               | 5 ++++-
 examples/meson.build              | 2 +-
 meson.build                       | 2 +-
 6 files changed, 9 insertions(+), 6 deletions(-)

-- 
2.56.0


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

* [PATCH dpdk 1/2] meson: rename static drivers list
  2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
@ 2026-10-15 10:09 ` Robin Jarry
  2026-10-15 10:36   ` Bruce Richardson
  2026-10-15 10:09 ` [PATCH dpdk 2/2] meson: add drivers to dynamic libraries Robin Jarry
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 10:09 UTC (permalink / raw)
  To: dev, Bruce Richardson

This list contains a list of *static* driver libraries. Reflect that in
its name.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 2 +-
 buildtools/subproject/meson.build | 2 +-
 drivers/meson.build               | 2 +-
 examples/meson.build              | 2 +-
 meson.build                       | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 451568847132..f4c3f5a5ccd5 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -107,7 +107,7 @@ foreach app:apps
     dpdk_apps_enabled += app
     link_libs = []
     if get_option('default_library') == 'static'
-        link_libs = dpdk_static_libraries + dpdk_drivers
+        link_libs = dpdk_static_libraries + dpdk_static_drivers
     endif
 
     exec = executable('dpdk-' + name,
diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index a0a265ad92c7..14ea3097c461 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -49,7 +49,7 @@ Note that CFLAGS might contain an -march flag higher than typical baseline.
 This is required for a number of static inline functions in the public headers.''',
         requires: ['libdpdk-libs'],
         libraries_private: ['-Wl,--whole-archive'] +
-            dpdk_drivers + dpdk_static_libraries +
+            dpdk_static_drivers + dpdk_static_libraries +
             ['-Wl,--no-whole-archive'] + platform_flags
 )
 
diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build
index 8ae081e1698a..57022f07be7c 100644
--- a/buildtools/subproject/meson.build
+++ b/buildtools/subproject/meson.build
@@ -13,7 +13,7 @@ if get_option('default_library') == 'static'
             compile_args: subproject_cflags,
             # static library deps in DPDK build don't include "link_with" parameters,
             # so explicitly link-in both libs and drivers
-            link_whole: dpdk_static_libraries + dpdk_drivers,
+            link_whole: dpdk_static_libraries + dpdk_static_drivers,
             link_args: dpdk_extra_ldflags)
 else
     dpdk_dep = declare_dependency(
diff --git a/drivers/meson.build b/drivers/meson.build
index 102a8262e588..7146f036c4c9 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -404,7 +404,7 @@ foreach subpath:subdirs
                 include_directories: includes,
                 dependencies: static_deps)
 
-        dpdk_drivers += static_lib
+        dpdk_static_drivers += static_lib
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
diff --git a/examples/meson.build b/examples/meson.build
index 544ec5eadd82..4c142a010d48 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -3,7 +3,7 @@
 
 link_whole_libs = []
 if get_option('default_library') == 'static'
-    link_whole_libs = dpdk_static_libraries + dpdk_drivers
+    link_whole_libs = dpdk_static_libraries + dpdk_static_drivers
 endif
 
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
diff --git a/meson.build b/meson.build
index 6b8cfa8b2e90..554ba33e9c66 100644
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,7 @@ dpdk_headers = []
 dpdk_indirect_headers = []
 dpdk_drivers_headers = []
 dpdk_driver_classes = []
-dpdk_drivers = []
+dpdk_static_drivers = []
 dpdk_extra_ldflags = []
 dpdk_libs_deprecated = []
 dpdk_apps_disabled = []
-- 
2.56.0


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

* [PATCH dpdk 2/2] meson: add drivers to dynamic libraries
  2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
  2026-10-15 10:09 ` [PATCH dpdk 1/2] meson: rename static drivers list Robin Jarry
@ 2026-10-15 10:09 ` Robin Jarry
  2026-10-15 10:40   ` Bruce Richardson
  2026-10-15 10:41 ` [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Bruce Richardson
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 10:09 UTC (permalink / raw)
  To: dev

dpdk_shared_lib_deps only collects library dependencies, so DPDK built
as a meson subproject with shared libraries never links against
drivers that install public headers (e.g. bus/pci, bus/vdev). Add
these drivers to dpdk_shared_lib_deps as well, mirroring what is
already done for libraries in lib/meson.build.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 drivers/meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/meson.build b/drivers/meson.build
index 7146f036c4c9..37b152979109 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -405,6 +405,9 @@ foreach subpath:subdirs
                 dependencies: static_deps)
 
         dpdk_static_drivers += static_lib
+        if headers.length() > 0
+            dpdk_shared_lib_deps += shared_dep
+        endif
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
-- 
2.56.0


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

* Re: [PATCH dpdk 1/2] meson: rename static drivers list
  2026-10-15 10:09 ` [PATCH dpdk 1/2] meson: rename static drivers list Robin Jarry
@ 2026-10-15 10:36   ` Bruce Richardson
  0 siblings, 0 replies; 17+ messages in thread
From: Bruce Richardson @ 2026-10-15 10:36 UTC (permalink / raw)
  To: Robin Jarry; +Cc: dev

On Thu, Oct 15, 2026 at 12:09:23PM +0200, Robin Jarry wrote:
> This list contains a list of *static* driver libraries. Reflect that in
> its name.
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---
>  app/meson.build                   | 2 +-
>  buildtools/pkg-config/meson.build | 2 +-
>  buildtools/subproject/meson.build | 2 +-
>  drivers/meson.build               | 2 +-
>  examples/meson.build              | 2 +-
>  meson.build                       | 2 +-
>  6 files changed, 6 insertions(+), 6 deletions(-)
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

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

* Re: [PATCH dpdk 2/2] meson: add drivers to dynamic libraries
  2026-10-15 10:09 ` [PATCH dpdk 2/2] meson: add drivers to dynamic libraries Robin Jarry
@ 2026-10-15 10:40   ` Bruce Richardson
  0 siblings, 0 replies; 17+ messages in thread
From: Bruce Richardson @ 2026-10-15 10:40 UTC (permalink / raw)
  To: Robin Jarry; +Cc: dev

On Thu, Oct 15, 2026 at 12:09:24PM +0200, Robin Jarry wrote:
> dpdk_shared_lib_deps only collects library dependencies, so DPDK built
> as a meson subproject with shared libraries never links against
> drivers that install public headers (e.g. bus/pci, bus/vdev). Add
> these drivers to dpdk_shared_lib_deps as well, mirroring what is
> already done for libraries in lib/meson.build.
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> ---
>  drivers/meson.build | 3 +++
>  1 file changed, 3 insertions(+)
> 

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


> diff --git a/drivers/meson.build b/drivers/meson.build
> index 7146f036c4c9..37b152979109 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -405,6 +405,9 @@ foreach subpath:subdirs
>                  dependencies: static_deps)
>  
>          dpdk_static_drivers += static_lib
> +        if headers.length() > 0
> +            dpdk_shared_lib_deps += shared_dep
> +        endif
>  
>          set_variable('shared_@0@'.format(lib_name), shared_dep)
>          set_variable('static_@0@'.format(lib_name), static_dep)
> -- 
> 2.56.0
> 

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

* Re: [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf
  2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
  2026-10-15 10:09 ` [PATCH dpdk 1/2] meson: rename static drivers list Robin Jarry
  2026-10-15 10:09 ` [PATCH dpdk 2/2] meson: add drivers to dynamic libraries Robin Jarry
@ 2026-10-15 10:41 ` Bruce Richardson
  2026-10-15 11:27   ` Robin Jarry
  2026-10-15 11:26 ` [PATCH dpdk v2 " Robin Jarry
  2026-10-16 15:38 ` [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
  4 siblings, 1 reply; 17+ messages in thread
From: Bruce Richardson @ 2026-10-15 10:41 UTC (permalink / raw)
  To: Robin Jarry; +Cc: dev

On Thu, Oct 15, 2026 at 12:09:22PM +0200, Robin Jarry wrote:
> When building against dynamic libraries using pkg-config, linking fails
> because symbols exposed by drivers are not found:
> 
> 	/usr/bin/x86_64-linux-gnu-ld.bfd: ....o:(.data.rel.ro+0x148):
> 		undefined reference to `rte_pci_dump'
> 
> That symbol is in librte_bus_pci.so which is *not* listed in the libs
> section of the pkg-config file.
> 
> This series is about fixing this.
> 
While the changes in the two patches are ok, I don't see how they affect
pkg-config. The first patch just renames a variable for clarity, and the
second only affects applications linking using a meson subproject rather
than a .pc file.

/Bruce

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

* [PATCH dpdk v2 0/2] Fix dynamic link of driver symbols with pkgconf
  2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
                   ` (2 preceding siblings ...)
  2026-10-15 10:41 ` [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Bruce Richardson
@ 2026-10-15 11:26 ` Robin Jarry
  2026-10-15 11:26   ` [PATCH dpdk v2 1/2] meson: rename static drivers list Robin Jarry
  2026-10-15 11:26   ` [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries Robin Jarry
  2026-10-16 15:38 ` [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
  4 siblings, 2 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 11:26 UTC (permalink / raw)
  To: dev

When building against dynamic libraries using pkg-config, linking fails
because symbols exposed by drivers are not found:

	/usr/bin/x86_64-linux-gnu-ld.bfd: ....o:(.data.rel.ro+0x148):
		undefined reference to `rte_pci_dump'

That symbol is in librte_bus_pci.so which is *not* listed in the libs
section of the pkg-config file.

This series is about fixing this.

v2: Added missing update to dpdk_libraries for pkg-config

Robin Jarry (2):
  meson: rename static drivers list
  meson: add drivers to dynamic libraries

 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 2 +-
 buildtools/subproject/meson.build | 2 +-
 drivers/meson.build               | 6 +++++-
 examples/meson.build              | 2 +-
 meson.build                       | 2 +-
 6 files changed, 10 insertions(+), 6 deletions(-)

-- 
2.56.0


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

* [PATCH dpdk v2 1/2] meson: rename static drivers list
  2026-10-15 11:26 ` [PATCH dpdk v2 " Robin Jarry
@ 2026-10-15 11:26   ` Robin Jarry
  2026-10-15 11:26   ` [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries Robin Jarry
  1 sibling, 0 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 11:26 UTC (permalink / raw)
  To: dev, Bruce Richardson

This list contains a list of *static* driver libraries. Reflect that in
its name.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 2 +-
 buildtools/subproject/meson.build | 2 +-
 drivers/meson.build               | 2 +-
 examples/meson.build              | 2 +-
 meson.build                       | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 451568847132..f4c3f5a5ccd5 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -107,7 +107,7 @@ foreach app:apps
     dpdk_apps_enabled += app
     link_libs = []
     if get_option('default_library') == 'static'
-        link_libs = dpdk_static_libraries + dpdk_drivers
+        link_libs = dpdk_static_libraries + dpdk_static_drivers
     endif
 
     exec = executable('dpdk-' + name,
diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index a0a265ad92c7..14ea3097c461 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -49,7 +49,7 @@ Note that CFLAGS might contain an -march flag higher than typical baseline.
 This is required for a number of static inline functions in the public headers.''',
         requires: ['libdpdk-libs'],
         libraries_private: ['-Wl,--whole-archive'] +
-            dpdk_drivers + dpdk_static_libraries +
+            dpdk_static_drivers + dpdk_static_libraries +
             ['-Wl,--no-whole-archive'] + platform_flags
 )
 
diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build
index 8ae081e1698a..57022f07be7c 100644
--- a/buildtools/subproject/meson.build
+++ b/buildtools/subproject/meson.build
@@ -13,7 +13,7 @@ if get_option('default_library') == 'static'
             compile_args: subproject_cflags,
             # static library deps in DPDK build don't include "link_with" parameters,
             # so explicitly link-in both libs and drivers
-            link_whole: dpdk_static_libraries + dpdk_drivers,
+            link_whole: dpdk_static_libraries + dpdk_static_drivers,
             link_args: dpdk_extra_ldflags)
 else
     dpdk_dep = declare_dependency(
diff --git a/drivers/meson.build b/drivers/meson.build
index 102a8262e588..7146f036c4c9 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -404,7 +404,7 @@ foreach subpath:subdirs
                 include_directories: includes,
                 dependencies: static_deps)
 
-        dpdk_drivers += static_lib
+        dpdk_static_drivers += static_lib
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
diff --git a/examples/meson.build b/examples/meson.build
index 544ec5eadd82..4c142a010d48 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -3,7 +3,7 @@
 
 link_whole_libs = []
 if get_option('default_library') == 'static'
-    link_whole_libs = dpdk_static_libraries + dpdk_drivers
+    link_whole_libs = dpdk_static_libraries + dpdk_static_drivers
 endif
 
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
diff --git a/meson.build b/meson.build
index 6b8cfa8b2e90..554ba33e9c66 100644
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,7 @@ dpdk_headers = []
 dpdk_indirect_headers = []
 dpdk_drivers_headers = []
 dpdk_driver_classes = []
-dpdk_drivers = []
+dpdk_static_drivers = []
 dpdk_extra_ldflags = []
 dpdk_libs_deprecated = []
 dpdk_apps_disabled = []
-- 
2.56.0


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

* [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries
  2026-10-15 11:26 ` [PATCH dpdk v2 " Robin Jarry
  2026-10-15 11:26   ` [PATCH dpdk v2 1/2] meson: rename static drivers list Robin Jarry
@ 2026-10-15 11:26   ` Robin Jarry
  2026-10-15 11:52     ` Bruce Richardson
  1 sibling, 1 reply; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 11:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

dpdk_shared_lib_deps only collects library dependencies, so DPDK built
as a meson subproject with shared libraries never links against
drivers that install public headers (e.g. bus/pci, bus/vdev). Add
these drivers to dpdk_shared_lib_deps as well, mirroring what is
already done for libraries in lib/meson.build.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---

Notes:
    v2: added driver shared libs to the list for pkg-config

 drivers/meson.build | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/meson.build b/drivers/meson.build
index 7146f036c4c9..0e8e69798bdf 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -405,6 +405,10 @@ foreach subpath:subdirs
                 dependencies: static_deps)
 
         dpdk_static_drivers += static_lib
+        if headers.length() > 0
+            dpdk_libraries += shared_lib
+            dpdk_shared_lib_deps += shared_dep
+        endif
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
-- 
2.56.0


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

* Re: [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf
  2026-10-15 10:41 ` [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Bruce Richardson
@ 2026-10-15 11:27   ` Robin Jarry
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 11:27 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

Bruce Richardson, Oct 15, 2026 at 12:41:
> While the changes in the two patches are ok, I don't see how they affect
> pkg-config. The first patch just renames a variable for clarity, and the
> second only affects applications linking using a meson subproject rather
> than a .pc file.

Indeed, I had forgotten about updating the correct variable. v2 should
be good.


-- 
Robin

# To order, call toll-free.


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

* Re: [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries
  2026-10-15 11:26   ` [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries Robin Jarry
@ 2026-10-15 11:52     ` Bruce Richardson
  2026-10-15 12:06       ` Robin Jarry
  0 siblings, 1 reply; 17+ messages in thread
From: Bruce Richardson @ 2026-10-15 11:52 UTC (permalink / raw)
  To: Robin Jarry; +Cc: dev

On Thu, Oct 15, 2026 at 01:26:10PM +0200, Robin Jarry wrote:
> dpdk_shared_lib_deps only collects library dependencies, so DPDK built
> as a meson subproject with shared libraries never links against
> drivers that install public headers (e.g. bus/pci, bus/vdev). Add
> these drivers to dpdk_shared_lib_deps as well, mirroring what is
> already done for libraries in lib/meson.build.
> 
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> 
> Notes:
>     v2: added driver shared libs to the list for pkg-config
> 
>  drivers/meson.build | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/meson.build b/drivers/meson.build
> index 7146f036c4c9..0e8e69798bdf 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -405,6 +405,10 @@ foreach subpath:subdirs
>                  dependencies: static_deps)
>  
>          dpdk_static_drivers += static_lib
> +        if headers.length() > 0
> +            dpdk_libraries += shared_lib
> +            dpdk_shared_lib_deps += shared_dep
> +        endif
>  
I think this changes significantly how out pkg-config files are working, vs
our original intention, so I think it actually needs more discussion.

As originally designed, when dynamically linking against DPDK the pkg-config
--libs libdpdk call was only meant to list out the libraries, with drivers
being dynamically loaded at runtime. Since drivers were never meant to have
a public API that was generally used, I believe the idea was that anyone
using driver-specific APIs was required themselves to pass the driver
explicitly to the linker. Otherwise everyone who does not use that driver
could end up (depending on their linker flags) with a dependency on that
unused driver. This change modifies that assumption and, while it makes it
easier for those using driver-specific APIs, it does change how things have
worked up till now.

On my system using a default build, this adds 33 drivers to the list of
libraries to link against when using pkg-config --libs.

/Bruce

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

* Re: [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries
  2026-10-15 11:52     ` Bruce Richardson
@ 2026-10-15 12:06       ` Robin Jarry
  2026-10-15 12:18         ` Bruce Richardson
  0 siblings, 1 reply; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 12:06 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

Bruce Richardson, Oct 15, 2026 at 13:52:
> I think this changes significantly how out pkg-config files are working, vs
> our original intention, so I think it actually needs more discussion.
>
> As originally designed, when dynamically linking against DPDK the pkg-config
> --libs libdpdk call was only meant to list out the libraries, with drivers
> being dynamically loaded at runtime. Since drivers were never meant to have
> a public API that was generally used, I believe the idea was that anyone
> using driver-specific APIs was required themselves to pass the driver
> explicitly to the linker. Otherwise everyone who does not use that driver
> could end up (depending on their linker flags) with a dependency on that
> unused driver. This change modifies that assumption and, while it makes it
> easier for those using driver-specific APIs, it does change how things have
> worked up till now.
>
> On my system using a default build, this adds 33 drivers to the list of
> libraries to link against when using pkg-config --libs.

But since these libraries are preceded by -Wl,--as-needed, only ones
that expose symbols that your binary uses will be linked. I don't think
it would change anything in the final result.

Also, this aligns with what the static build is doing: list all drivers
as well albeit with -Wl,--whole-archive and *without* -Wl,--as-needed.

What do you think?

-- 
Robin

# Do not try this at home.


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

* Re: [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries
  2026-10-15 12:06       ` Robin Jarry
@ 2026-10-15 12:18         ` Bruce Richardson
  2026-10-15 14:47           ` Robin Jarry
  0 siblings, 1 reply; 17+ messages in thread
From: Bruce Richardson @ 2026-10-15 12:18 UTC (permalink / raw)
  To: Robin Jarry; +Cc: dev

On Thu, Oct 15, 2026 at 02:06:00PM +0200, Robin Jarry wrote:
> Bruce Richardson, Oct 15, 2026 at 13:52:
> > I think this changes significantly how out pkg-config files are working, vs
> > our original intention, so I think it actually needs more discussion.
> > 
> > As originally designed, when dynamically linking against DPDK the pkg-config
> > --libs libdpdk call was only meant to list out the libraries, with drivers
> > being dynamically loaded at runtime. Since drivers were never meant to have
> > a public API that was generally used, I believe the idea was that anyone
> > using driver-specific APIs was required themselves to pass the driver
> > explicitly to the linker. Otherwise everyone who does not use that driver
> > could end up (depending on their linker flags) with a dependency on that
> > unused driver. This change modifies that assumption and, while it makes it
> > easier for those using driver-specific APIs, it does change how things have
> > worked up till now.
> > 
> > On my system using a default build, this adds 33 drivers to the list of
> > libraries to link against when using pkg-config --libs.
> 
> But since these libraries are preceded by -Wl,--as-needed, only ones
> that expose symbols that your binary uses will be linked. I don't think
> it would change anything in the final result.
> 
> Also, this aligns with what the static build is doing: list all drivers
> as well albeit with -Wl,--whole-archive and *without* -Wl,--as-needed.
> 
Yes, static builds link in everything, and that was always the design since
static builds don't load drivers at runtime, everything has to be linked
into the final object.

Personally, I don't that strongly object to the change because - as you
point out - the as-needed flag should prevent overlinking. If we do this,
I'd suggest making both drivers and libs full lists, rather than
distinguishing between drivers with public headers and those without,
because that should allow us to simplify our package config files. Right
now we have this strange split into two .pc files, as that was the only way
I could find to get correct behaviour for both static and shared builds,
where static included everything and shared was libs only. [IIRC, the
complication was that, when you pass --static to pkg-config, the extra link
args from the pc file get listed *after* the normal libs, while they need to get
listed *before* in order to satisfy the dependencies drivers have on the
libs]

/Bruce

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

* Re: [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries
  2026-10-15 12:18         ` Bruce Richardson
@ 2026-10-15 14:47           ` Robin Jarry
  0 siblings, 0 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-15 14:47 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

Bruce Richardson, Oct 15, 2026 at 14:18:
> Yes, static builds link in everything, and that was always the design since
> static builds don't load drivers at runtime, everything has to be linked
> into the final object.
>
> Personally, I don't that strongly object to the change because - as you
> point out - the as-needed flag should prevent overlinking. If we do this,
> I'd suggest making both drivers and libs full lists, rather than
> distinguishing between drivers with public headers and those without,
> because that should allow us to simplify our package config files. Right
> now we have this strange split into two .pc files, as that was the only way
> I could find to get correct behaviour for both static and shared builds,
> where static included everything and shared was libs only. [IIRC, the
> complication was that, when you pass --static to pkg-config, the extra link
> args from the pc file get listed *after* the normal libs, while they need to get
> listed *before* in order to satisfy the dependencies drivers have on the
> libs]

Thanks. I will see what I can do.


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

* [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf
  2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
                   ` (3 preceding siblings ...)
  2026-10-15 11:26 ` [PATCH dpdk v2 " Robin Jarry
@ 2026-10-16 15:38 ` Robin Jarry
  2026-10-16 15:38   ` [PATCH dpdk v3 1/2] meson: rename static drivers list Robin Jarry
  2026-10-16 15:38   ` [PATCH dpdk v3 2/2] meson: add all drivers to dynamic libraries Robin Jarry
  4 siblings, 2 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-16 15:38 UTC (permalink / raw)
  To: dev

When building against dynamic libraries using pkg-config, linking fails
because symbols exposed by drivers are not found:

	/usr/bin/x86_64-linux-gnu-ld.bfd: ....o:(.data.rel.ro+0x148):
		undefined reference to `rte_pci_dump'

That symbol is in librte_bus_pci.so which is *not* listed in the libs
section of the pkg-config file.

This series is about fixing this.

v3:

- Added all shared driver libs to pkg-config, regardless if they have
  a public API. -Wl,--as-needed prevents overlinking at build time.
- Simplified to a single .pc file now that all libraries are listed in
  the correct order.

v2: Added missing update to dpdk_libraries for pkg-config

Robin Jarry (2):
  meson: rename static drivers list
  meson: add all drivers to dynamic libraries

 app/meson.build                   |  2 +-
 buildtools/pkg-config/meson.build | 65 ++++++++++++++++---------------
 buildtools/subproject/meson.build |  2 +-
 drivers/meson.build               |  4 +-
 examples/meson.build              |  2 +-
 meson.build                       |  3 +-
 6 files changed, 42 insertions(+), 36 deletions(-)

-- 
2.56.0


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

* [PATCH dpdk v3 1/2] meson: rename static drivers list
  2026-10-16 15:38 ` [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
@ 2026-10-16 15:38   ` Robin Jarry
  2026-10-16 15:38   ` [PATCH dpdk v3 2/2] meson: add all drivers to dynamic libraries Robin Jarry
  1 sibling, 0 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-16 15:38 UTC (permalink / raw)
  To: dev, Bruce Richardson

This list contains a list of *static* driver libraries. Reflect that in
its name.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build                   | 2 +-
 buildtools/pkg-config/meson.build | 2 +-
 buildtools/subproject/meson.build | 2 +-
 drivers/meson.build               | 2 +-
 examples/meson.build              | 2 +-
 meson.build                       | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 24fadc19631e..ad2d29d1d7a5 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -108,7 +108,7 @@ foreach app:apps
     dpdk_apps_enabled += app
     link_libs = []
     if get_option('default_library') == 'static'
-        link_libs = dpdk_static_libraries + dpdk_drivers
+        link_libs = dpdk_static_libraries + dpdk_static_drivers
     endif
 
     exec = executable('dpdk-' + name,
diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index a0a265ad92c7..14ea3097c461 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -49,7 +49,7 @@ Note that CFLAGS might contain an -march flag higher than typical baseline.
 This is required for a number of static inline functions in the public headers.''',
         requires: ['libdpdk-libs'],
         libraries_private: ['-Wl,--whole-archive'] +
-            dpdk_drivers + dpdk_static_libraries +
+            dpdk_static_drivers + dpdk_static_libraries +
             ['-Wl,--no-whole-archive'] + platform_flags
 )
 
diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build
index 8ae081e1698a..57022f07be7c 100644
--- a/buildtools/subproject/meson.build
+++ b/buildtools/subproject/meson.build
@@ -13,7 +13,7 @@ if get_option('default_library') == 'static'
             compile_args: subproject_cflags,
             # static library deps in DPDK build don't include "link_with" parameters,
             # so explicitly link-in both libs and drivers
-            link_whole: dpdk_static_libraries + dpdk_drivers,
+            link_whole: dpdk_static_libraries + dpdk_static_drivers,
             link_args: dpdk_extra_ldflags)
 else
     dpdk_dep = declare_dependency(
diff --git a/drivers/meson.build b/drivers/meson.build
index 102a8262e588..7146f036c4c9 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -404,7 +404,7 @@ foreach subpath:subdirs
                 include_directories: includes,
                 dependencies: static_deps)
 
-        dpdk_drivers += static_lib
+        dpdk_static_drivers += static_lib
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
diff --git a/examples/meson.build b/examples/meson.build
index 544ec5eadd82..4c142a010d48 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -3,7 +3,7 @@
 
 link_whole_libs = []
 if get_option('default_library') == 'static'
-    link_whole_libs = dpdk_static_libraries + dpdk_drivers
+    link_whole_libs = dpdk_static_libraries + dpdk_static_drivers
 endif
 
 # list of all example apps. Keep 1-3 per line, in alphabetical order.
diff --git a/meson.build b/meson.build
index 6b8cfa8b2e90..554ba33e9c66 100644
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,7 @@ dpdk_headers = []
 dpdk_indirect_headers = []
 dpdk_drivers_headers = []
 dpdk_driver_classes = []
-dpdk_drivers = []
+dpdk_static_drivers = []
 dpdk_extra_ldflags = []
 dpdk_libs_deprecated = []
 dpdk_apps_disabled = []
-- 
2.56.0


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

* [PATCH dpdk v3 2/2] meson: add all drivers to dynamic libraries
  2026-10-16 15:38 ` [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
  2026-10-16 15:38   ` [PATCH dpdk v3 1/2] meson: rename static drivers list Robin Jarry
@ 2026-10-16 15:38   ` Robin Jarry
  1 sibling, 0 replies; 17+ messages in thread
From: Robin Jarry @ 2026-10-16 15:38 UTC (permalink / raw)
  To: dev, Bruce Richardson

dpdk_shared_lib_deps only collects library dependencies, so DPDK built
as a meson subproject with shared libraries never links against the
drivers, even those that install public headers (e.g. bus/pci,
bus/vdev). Add all drivers to dpdk_shared_lib_deps as well, mirroring
what is already done for libraries in lib/meson.build.

Listing every driver (not only the ones with public headers) lets the
pkg-config files be simplified. The two .pc files existed only to get
the link order right: drivers must come before the libraries they
depend on, but pkg-config emits Libs.private after Libs, so the
libraries had to live in a separate file pulled in through Requires.
With the drivers and libraries both present in a single Libs.private
block, a second file is no longer needed and libdpdk-libs.pc can be
folded back into libdpdk.pc. The --as-needed flag keeps shared builds
from overlinking.

Listing the drivers in the shared Libs field is safe with respect to
the constructor functions that drivers use to register themselves,
which must run exactly once. Thanks to --as-needed, a driver whose
symbols are not referenced by the application is dropped from the
binary NEEDED list, so its constructor does not run at startup and EAL
loads the driver once at runtime with dlopen() as before. If the
application does reference a driver symbol, the driver stays in NEEDED
and its constructor runs at startup, but EAL's later dlopen() of the
same file is deduplicated by the dynamic loader (same soname and inode,
since the plugin directory holds symlinks to the installed libraries)
and does not run the constructor again. The constructor runs exactly
once in both cases.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---

Notes:
    v3:
    
    - Added all shared driver libs to pkg-config, regardless if they have
      a public API. -Wl,--as-needed prevents overlinking.
    - Simplified to a single .pc file now that all libraries are listed in
      the correct order.
    
    v2: added driver shared libs to the list for pkg-config

 buildtools/pkg-config/meson.build | 63 ++++++++++++++++---------------
 drivers/meson.build               |  2 +
 meson.build                       |  1 +
 3 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 14ea3097c461..e1198762d354 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -7,35 +7,36 @@ if is_freebsd
     pkg_extra_cflags += ['-D__BSD_VISIBLE']
 endif
 
-# When calling pkg-config --static --libs, pkg-config will always output the
-# regular libs first, and then the extra libs from Libs.private field,
-# since the assumption is that those are additional dependencies for building
-# statically that the .a files depend upon. The output order of .pc fields is:
+# The output order of the .pc file fields used by pkg-config is:
 #   Libs   Libs.private   Requires   Requires.private
-# The fields Requires* are for package names.
-# The flags of the DPDK libraries must be defined in Libs* fields.
-# However, the DPDK drivers are linked only in static builds (Libs.private),
-# and those need to come *before* the regular libraries (Libs field).
-# This requirement is satisfied by moving the regular libs in a separate file
-# included in the field Requires (after Libs.private).
-# Another requirement is to allow linking dependencies as shared libraries,
-# while linking static DPDK libraries and drivers. It is satisfied by
-# listing the static files in Libs.private with the explicit syntax -l:libfoo.a.
-# As a consequence, the regular DPDK libraries are already listed as static
-# in the field Libs.private. The second occurences of DPDK libraries,
-# included from Requires and used for shared library linkage case,
-# are skipped in the case of static linkage thanks to the flag --as-needed.
-
-
-pkg.generate(name: 'dpdk-libs',
-        filebase: 'libdpdk-libs',
-        description: '''Internal-only DPDK pkgconfig file. Not for direct use.
-Use libdpdk.pc instead of this file to query DPDK compile/link arguments''',
-        version: meson.project_version(),
-        subdirs: [get_option('include_subdir_arch'), '.'],
-        extra_cflags: pkg_extra_cflags,
-        libraries: ['-Wl,--as-needed'] + dpdk_libraries,
-        libraries_private: dpdk_extra_ldflags)
+# The Requires* fields are for package names, while the flags of the DPDK
+# libraries and drivers must be defined in the Libs* fields.
+#
+# For shared linking, only the Libs field is used, and it lists the DPDK
+# libraries and drivers, all with the --as-needed flag to avoid overlinking
+# against components that the application does not actually use.
+#
+# Listing the drivers here is safe even though they are normally loaded at
+# runtime with dlopen(). DPDK drivers register themselves through constructor
+# functions that must run exactly once. Thanks to --as-needed, a driver whose
+# symbols are not referenced by the application is dropped from the binary's
+# NEEDED list entirely, so its constructor does not run at startup and EAL
+# loads it once at runtime as usual. If the application does reference a driver
+# symbol, the driver stays in NEEDED and its constructor runs at startup; EAL's
+# later dlopen() of the same file is deduplicated by the dynamic loader (same
+# soname and inode, the plugin directory holds symlinks to the installed
+# libraries) and does not run the constructor a second time. Either way, the
+# constructor runs exactly once.
+#
+# For static linking, pkg-config appends the Libs.private field after Libs.
+# The DPDK drivers must be linked before the libraries they depend upon, so
+# both the drivers and the libraries are listed in Libs.private, wrapped in
+# --whole-archive so that drivers register themselves at load time. The
+# static files are listed with the explicit -l:libfoo.a syntax so that DPDK
+# itself is linked statically while its external dependencies may still be
+# linked as shared libraries. The DPDK libraries from the Libs field appear a
+# second time before Libs.private, but those occurrences are skipped thanks to
+# the --as-needed flag.
 
 platform_flags = []
 if not is_windows
@@ -47,10 +48,12 @@ pkg.generate(name: 'DPDK', # main DPDK pkgconfig file
         description: '''The Data Plane Development Kit (DPDK).
 Note that CFLAGS might contain an -march flag higher than typical baseline.
 This is required for a number of static inline functions in the public headers.''',
-        requires: ['libdpdk-libs'],
+        subdirs: [get_option('include_subdir_arch'), '.'],
+        extra_cflags: pkg_extra_cflags,
+        libraries: ['-Wl,--as-needed'] + dpdk_libraries + dpdk_shared_drivers,
         libraries_private: ['-Wl,--whole-archive'] +
             dpdk_static_drivers + dpdk_static_libraries +
-            ['-Wl,--no-whole-archive'] + platform_flags
+            ['-Wl,--no-whole-archive'] + dpdk_extra_ldflags + platform_flags
 )
 
 # For static linking with dependencies as shared libraries,
diff --git a/drivers/meson.build b/drivers/meson.build
index 7146f036c4c9..86458166a226 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -405,6 +405,8 @@ foreach subpath:subdirs
                 dependencies: static_deps)
 
         dpdk_static_drivers += static_lib
+        dpdk_shared_drivers += shared_lib
+        dpdk_shared_lib_deps += shared_dep
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
diff --git a/meson.build b/meson.build
index 554ba33e9c66..ce4a4217549d 100644
--- a/meson.build
+++ b/meson.build
@@ -45,6 +45,7 @@ dpdk_indirect_headers = []
 dpdk_drivers_headers = []
 dpdk_driver_classes = []
 dpdk_static_drivers = []
+dpdk_shared_drivers = []
 dpdk_extra_ldflags = []
 dpdk_libs_deprecated = []
 dpdk_apps_disabled = []
-- 
2.56.0


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

end of thread, other threads:[~2026-10-16 15:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 10:09 [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
2026-10-15 10:09 ` [PATCH dpdk 1/2] meson: rename static drivers list Robin Jarry
2026-10-15 10:36   ` Bruce Richardson
2026-10-15 10:09 ` [PATCH dpdk 2/2] meson: add drivers to dynamic libraries Robin Jarry
2026-10-15 10:40   ` Bruce Richardson
2026-10-15 10:41 ` [PATCH dpdk 0/2] Fix dynamic link of driver symbols with pkgconf Bruce Richardson
2026-10-15 11:27   ` Robin Jarry
2026-10-15 11:26 ` [PATCH dpdk v2 " Robin Jarry
2026-10-15 11:26   ` [PATCH dpdk v2 1/2] meson: rename static drivers list Robin Jarry
2026-10-15 11:26   ` [PATCH dpdk v2 2/2] meson: add drivers to dynamic libraries Robin Jarry
2026-10-15 11:52     ` Bruce Richardson
2026-10-15 12:06       ` Robin Jarry
2026-10-15 12:18         ` Bruce Richardson
2026-10-15 14:47           ` Robin Jarry
2026-10-16 15:38 ` [PATCH dpdk v3 0/2] Fix dynamic link of driver symbols with pkgconf Robin Jarry
2026-10-16 15:38   ` [PATCH dpdk v3 1/2] meson: rename static drivers list Robin Jarry
2026-10-16 15:38   ` [PATCH dpdk v3 2/2] meson: add all drivers to dynamic libraries Robin Jarry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox