<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-IN" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hi Bruce,
<br>
Thanks for taking a look at this.<br>
<br>
Talking about the issues you pointed,<br>
</span><span style="font-size:11.0pt">1. Absense of -lrte_bus_pci and similar flags<br>
Even if I don’t give –static flag, I don’t see -lrte_bus_pci (and  -lrte_bus_vdev, -lrte_mempool_ring).<br>
</span><span style="font-size:11.0pt;mso-fareast-language:EN-US">Attaching output,<br>
PKG_CONFIG_PATH=dpdk/build/lib/pkgconfig pkg-config --libs libdpdk<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">-Wl,--as-needed -L/home/nutanix/spdk/dpdk/build/lib -lrte_vhost -lrte_security -lrte_reorder -lrte_dmadev -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<br>
Not sure if this is expected. <br>
<br>
2</span><span style="font-size:11.0pt">. Missing constructor runs.<br>
</span><span style="font-size:11.0pt;mso-fareast-language:EN-US">Got your point. I’m using pkg-config  0.27.1. Will check how to avoid the automatic No Whole Archive thing. Still not sure about point 1 though.<br>
<br>
Regards,<br>
Abhineet<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Bruce Richardson <bruce.richardson@intel.com><br>
<b>Date: </b>Thursday, 3 August 2023 at 3:46 PM<br>
<b>To: </b>Abhineet Pandey <abhineet.pandey@nutanix.com><br>
<b>Cc: </b>dev@dpdk.org <dev@dpdk.org><br>
<b>Subject: </b>Re: [Question/Issue] pkgconfig does not include dpdk/drivers libs<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">On Thu, Aug 03, 2023 at 09:15:11AM +0000, Abhineet Pandey wrote:<br>
>    I’m consuming dpdk via spdk.<br>
>    I was trying to use pkg-config for a Makefile that I’m writing,<br>
>    Executing:<br>
> <br>
>    PKG_CONFIG_PATH=dpdk/build/lib/pkgconfig pkg-config --libs --static<br>
>    libdpdk<br>
>    Output:<br>
>    -Wl,--whole-archive -Wl,--no-whole-archive -Wl,--as-needed -pthread<br>
>    -L/home/nutanix/exact_spdk/spdk/dpdk/build/lib -l:librte_bus_pci.a<br>
>    -l:librte_bus_vdev.a -l:librte_mempool_ring.a -l:librte_vhost.a<br>
>    -l:librte_security.a -l:librte_reorder.a -l:librte_power.a<br>
>    -l:librte_cryptodev.a -l:librte_compressdev.a -l:librte_timer.a<br>
>    -l:librte_hash.a -l:librte_cmdline.a -l:librte_pci.a -l:librte_ethdev.a<br>
>    -l:librte_meter.a -l:librte_net.a -l:librte_mbuf.a -l:librte_mempool.a<br>
>    -l:librte_rcu.a -l:librte_ring.a -l:librte_eal.a -l:librte_telemetry.a<br>
>    -l:librte_kvargs.a -lrte_vhost -lrte_security -lrte_reorder -lrte_power<br>
>    -lrte_cryptodev -lrte_compressdev -lrte_timer -lrte_hash -lrte_cmdline<br>
>    -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool<br>
>    -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lm -ldl<br>
>    -lnuma<br>
>    At a closer look, you’ll see -l:librte_bus_pci.a -l:librte_bus_vdev.a<br>
>    -l:librte_mempool_ring.a, but you won’t find corresponding<br>
>    -lrte_bus_pci, -lrte_bus_vdev, -lrte_mempool_ring. This showed up in my<br>
>    use case as rte_mempool_ring has some functions which execute on<br>
>    startup via __attribute__((constructor)), and they did not execute thus<br>
>    causing issues.<br>
<br>
I think there are two separate issues you are flagging here.<br>
1. Absense of -lrte_bus_pci and similar flags<br>
2. Missing constructor runs.<br>
<br>
For the former, the behaviour is exactly as expected. You have specified<br>
static linkage on the pkg-config commandline, so pkg-config is listing out<br>
the libraries to link against only in static form. With<br>
-l:librte_bus_pci.a, where is no need for -lrte_bus_pci since the pci bus<br>
library is already linked in.<br>
<br>
For the missing constructors, the issue is separate. That implies that when<br>
the static libs are linked, the constructors are not getting included.<br>
Normally, this is done by specifying the --whole-archive flag to the<br>
linker, but in your case above, that is immediately followed by<br>
--no-whole-archive which counteracts it! I suspect you may have a bug in<br>
your pkg-config. By any chance are you using pkg-config 0.27? There is<br>
known issue with it not linking static libs correctly, see note in [1]<br>
<br>
/Bruce<br>
<br>
[1] <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__doc.dpdk.org_guides-2D23.07_linux-5Fgsg_sys-5Freqs.html-23compilation-2Dof-2Dthe-2Ddpdk&d=DwIDaQ&c=s883GpUCOChKOHiocYtGcg&r=UaVZAw32qzYwqV0iyjkICkaNhB8peZhhEJSs22LHVbI&m=NHXDGIxEa3NlLGmshhz7un6SMT4NlACKBYA39xVBj3VGki9GCytR-HAHnQi0cM4S&s=OSlZ0EizFQ8Xa1HkrPrAywHi_kuZHJHhTe48KKtL-AA&e=">
https://urldefense.proofpoint.com/v2/url?u=https-3A__doc.dpdk.org_guides-2D23.07_linux-5Fgsg_sys-5Freqs.html-23compilation-2Dof-2Dthe-2Ddpdk&d=DwIDaQ&c=s883GpUCOChKOHiocYtGcg&r=UaVZAw32qzYwqV0iyjkICkaNhB8peZhhEJSs22LHVbI&m=NHXDGIxEa3NlLGmshhz7un6SMT4NlACKBYA39xVBj3VGki9GCytR-HAHnQi0cM4S&s=OSlZ0EizFQ8Xa1HkrPrAywHi_kuZHJHhTe48KKtL-AA&e=</a>
<o:p></o:p></span></p>
</div>
</div>
</body>
</html>