On Thu, Aug 03, 2023 at 09:15:11AM +0000, Abhineet Pandey wrote: > I’m consuming dpdk via spdk. > I was trying to use pkg-config for a Makefile that I’m writing, > Executing: > > PKG_CONFIG_PATH=dpdk/build/lib/pkgconfig pkg-config --libs --static > libdpdk > Output: > -Wl,--whole-archive -Wl,--no-whole-archive -Wl,--as-needed -pthread > -L/home/nutanix/exact_spdk/spdk/dpdk/build/lib -l:librte_bus_pci.a > -l:librte_bus_vdev.a -l:librte_mempool_ring.a -l:librte_vhost.a > -l:librte_security.a -l:librte_reorder.a -l:librte_power.a > -l:librte_cryptodev.a -l:librte_compressdev.a -l:librte_timer.a > -l:librte_hash.a -l:librte_cmdline.a -l:librte_pci.a -l:librte_ethdev.a > -l:librte_meter.a -l:librte_net.a -l:librte_mbuf.a -l:librte_mempool.a > -l:librte_rcu.a -l:librte_ring.a -l:librte_eal.a -l:librte_telemetry.a > -l:librte_kvargs.a -lrte_vhost -lrte_security -lrte_reorder -lrte_power > -lrte_cryptodev -lrte_compressdev -lrte_timer -lrte_hash -lrte_cmdline > -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool > -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lm -ldl > -lnuma > At a closer look, you’ll see -l:librte_bus_pci.a -l:librte_bus_vdev.a > -l:librte_mempool_ring.a, but you won’t find corresponding > -lrte_bus_pci, -lrte_bus_vdev, -lrte_mempool_ring. This showed up in my > use case as rte_mempool_ring has some functions which execute on > startup via __attribute__((constructor)), and they did not execute thus > causing issues.
I think there are two separate issues you are flagging here. 1. Absense of -lrte_bus_pci and similar flags 2. Missing constructor runs. For the former, the behaviour is exactly as expected. You have specified static linkage on the pkg-config commandline, so pkg-config is listing out the libraries to link against only in static form. With -l:librte_bus_pci.a, where is no need for -lrte_bus_pci since the pci bus library is already linked in. For the missing constructors, the issue is separate. That implies that when the static libs are linked, the constructors are not getting included. Normally, this is done by specifying the --whole-archive flag to the linker, but in your case above, that is immediately followed by --no-whole-archive which counteracts it! I suspect you may have a bug in your pkg-config. By any chance are you using pkg-config 0.27? There is known issue with it not linking static libs correctly, see note in [1] /Bruce [1] https://doc.dpdk.org/guides-23.07/linux_gsg/sys_reqs.html#compilation-of-the-dpdk