mbox series

[0/5] use portable macro for weak linking

Message ID 1735009552-31906-1-git-send-email-andremue@linux.microsoft.com (mailing list archive)
Headers
Series use portable macro for weak linking |

Message

Andre Muezerie Dec. 24, 2024, 3:05 a.m. UTC
MSVC uses pragmas to indicate weak linking, so the old __rte_weak
attribute needs to made into a macro so that the same syntax can
be used for MSVC and other compilers like gcc.

Andre Muezerie (5):
  lib/eal: add portable macro for weak linking
  app/test-compress-perf: use portable macro for weak linking
  drivers/bus: use portable macro for weak linking
  drivers/common: use portable macro for weak linking
  drivers/net: use portable macro for weak linking

 app/test-compress-perf/main.c            | 36 ++++++++++++------------
 drivers/bus/auxiliary/auxiliary_common.c |  8 +++---
 drivers/common/nitrox/nitrox_device.c    | 16 +++++------
 drivers/common/qat/qat_qp.c              |  4 +--
 drivers/net/enic/enic_main.c             |  4 +--
 drivers/net/fm10k/fm10k_ethdev.c         | 32 ++++++++++-----------
 drivers/net/hns3/hns3_rxtx.c             | 28 +++++++++---------
 drivers/net/nfp/nfdk/nfp_nfdk_vec_stub.c |  4 +--
 drivers/net/nfp/nfp_rxtx_vec_stub.c      |  8 +++---
 drivers/net/virtio/virtio_rxtx.c         |  8 +++---
 drivers/net/virtio/virtio_rxtx_simple.c  |  4 +--
 lib/eal/include/rte_common.h             | 14 ++++++++-
 12 files changed, 89 insertions(+), 77 deletions(-)

--
2.47.0.vfs.0.3
  

Comments

David Marchand Feb. 7, 2025, 8:47 a.m. UTC | #1
On Tue, Dec 24, 2024 at 4:06 AM Andre Muezerie
<andremue@linux.microsoft.com> wrote:
>
> MSVC uses pragmas to indicate weak linking, so the old __rte_weak
> attribute needs to made into a macro so that the same syntax can
> be used for MSVC and other compilers like gcc.
>
> Andre Muezerie (5):
>   lib/eal: add portable macro for weak linking
>   app/test-compress-perf: use portable macro for weak linking
>   drivers/bus: use portable macro for weak linking
>   drivers/common: use portable macro for weak linking
>   drivers/net: use portable macro for weak linking

I am not a fan of the weak linking stuff in the first place.
Reading the code with __rte_weak, I always wonder which symbol is used when...
I prefer explicit linking and no duplicate symbols end up in the binaries.

I posted a RFC, can you have a look?
https://inbox.dpdk.org/dev/20250207083252.3131588-1-david.marchand@redhat.com/
  
Andre Muezerie Feb. 7, 2025, 2:37 p.m. UTC | #2
On Fri, Feb 07, 2025 at 09:47:19AM +0100, David Marchand wrote:
> On Tue, Dec 24, 2024 at 4:06 AM Andre Muezerie
> <andremue@linux.microsoft.com> wrote:
> >
> > MSVC uses pragmas to indicate weak linking, so the old __rte_weak
> > attribute needs to made into a macro so that the same syntax can
> > be used for MSVC and other compilers like gcc.
> >
> > Andre Muezerie (5):
> >   lib/eal: add portable macro for weak linking
> >   app/test-compress-perf: use portable macro for weak linking
> >   drivers/bus: use portable macro for weak linking
> >   drivers/common: use portable macro for weak linking
> >   drivers/net: use portable macro for weak linking
> 
> I am not a fan of the weak linking stuff in the first place.
> Reading the code with __rte_weak, I always wonder which symbol is used when...
> I prefer explicit linking and no duplicate symbols end up in the binaries.
> 
> I posted a RFC, can you have a look?
> https://inbox.dpdk.org/dev/20250207083252.3131588-1-david.marchand@redhat.com/
> 
> 
> -- 
> David Marchand

I also had the same questions about which symbols were being used the first time I looked at the code.
Therefore, I think your proposal makes the code easier to understand and is a better approach.
--
Andre Muezerie