On Tue, Jun 3, 2025 at 3:01 AM Andre Muezerie
<andre...@linux.microsoft.com> wrote:
>
> On Wed, Apr 16, 2025 at 02:44:54PM -0700, Andre Muezerie wrote:
> > DPDK uses GCC attribute "used" through macro __rte_used to indicate
> > that a variable not referenced in the code should be assumed being
> > used and therefore not be optimized away. This technique is used to embed
> > information in the binaries, by having crafted information stored in
> > them.
> >
> > MSVC offers similar functionality, but it differs significantly: MSVC
> > requires a pragma to be used to send a command to the linker telling it
> > explicitly the name of the symbol that should be included (even if not
> > referenced). As a side-effect, variables called out to be included cannot
> > be static, otherwise their symbols are not "seen" by the linker. This
> > restriction requires some DPDK code to be refactored.
> >
> > Macro RTE_INCLUDE is used in this patch to ensure these special variables
> > make it to the final binaries.
> >
> > The elimination of "static" for some of these variables caused name
> > clashes when __COUNTER__ predefined macro was used. As a workaround,
> > predefined macro __LINE__ was used instead. However, when __COUNTER__
> > was used directly from a header file, __LINE__ had to be used from the
> > .c files, otherwise it would also not result in a unique symbol. This
> > required a parameter to be added to some macros so that the __LINE__
> > could be passed from the .c file to the macro defined in the header
> > (which was originally using __COUNTER__).
> >
> > With this patchset commands like the one below provide the same JSON
> > output as would be obtained on Linux.
> >
> > python usertools\dpdk-pmdinfo.py build\app\dpdk-testpmd.exe
> >
> > v4:
> >  - limited the use of __LINE__ to the header files, reducing number of
> >    changes made in previous versions of this patchset.

Open question, since the submission of this series, __rte_used is used
in the new symbol export macros.
It seems those macros are not affected by the problem you described
(and fixed with RTE_INCLUDE).
Is it because the symbols are explicitly listed as exported?


-- 
David Marchand

Reply via email to