eal: fix function versioning with LTO
PATCH 1/1 eal: fix function versioning with LTO
When using function versioning and building with Link Time Optimization, the compiler does not see the __asm__ annotation of symbols and therefore thinks there are two versions of the same symbol.
The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Bugzilla ID: 1949
--- lib/eal/common/eal_export.h | 46 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-)
lib/eal/common/eal_export.h +34 -12
@@ -30,39 +30,61 @@* new functionality, behavior, etc. When that occurs, it is desirable to * allow for backwards compatibility for a time with older binaries that are * dynamically linked to the dpdk. +* +* RTE_VERSION_SYMBOL +* Create a symbol version table entry binding symbol <name>@DPDK_<ver> to the internal +* function name <name>_v<ver>. +* +* RTE_VERSION_EXPERIMENTAL_SYMBOL similar to RTE_VERSION_SYMBOL but for experimental API symbols. +* This is mainly used for keeping compatibility for symbols that get promoted to stable ABI. +* +* RTE_DEFAULT_SYMBOL +* Create a symbol version entry instructing the linker to bind references to +* symbol <name> to the internal symbol <name>_v<ver>. */ #ifdef RTE_BUILD_SHARED_LIB -/* -* Create a symbol version table entry binding symbol <name>@DPDK_<ver> to the internal -* function name <name>_v<ver>. -*/ +/* Prefer the compiler method of versioning which uses attributes */ +#if __has_attribute (symver) + +#define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@DPDK_" RTE_STR(ver)))) \ + type name ## _v ## ver args; \ + type name ## _v ## ver args + +#define RTE_VERSION_EXPERIMENTAL_SYMBOL (type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@EXPERIMENTAL"))) \ + type name ## _exp args; \ + type name ## _exp args + +#define RTE_DEFAULT_SYMBOL (ver, type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@@DPDK_" RTE_STR(ver)))) \ + type name ## _v ## ver args; \ + type name ## _v ## ver args +#else /* !__has_attribute(symver) */ + +/* Use asm tag to create symbol table entry */ #define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_v" RTE_STR(ver) ", " RTE_STR(name) "@DPDK_" RTE_STR(ver)); \ __rte_used type name ## _v ## ver args; \ type name ## _v ## ver args -/* -* Similar to RTE_VERSION_SYMBOL but for experimental API symbols. -* This is mainly used for keeping compatibility for symbols that get promoted to stable ABI. -*/ #define RTE_VERSION_EXPERIMENTAL_SYMBOL (type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_exp, " RTE_STR(name) "@EXPERIMENTAL") \ __rte_used type name ## _exp args; \ type name ## _exp args -/* -* Create a symbol version entry instructing the linker to bind references to -* symbol <name> to the internal symbol <name>_v<ver>. -*/ #define RTE_DEFAULT_SYMBOL (ver, type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_v" RTE_STR(ver) ", " RTE_STR(name) "@@DPDK_" RTE_STR(ver)); \ __rte_used type name ## _v ## ver args; \ type name ## _v ## ver args +#endif /* __has_attribute(symver) */ +#else /* !RTE_BUILD_SHARED_LIB */ +/* static library does not have versioned symbols */ #define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ type name ## _v ## ver args; \ type name ## _v ## ver args
Signature · 1 line
2.53.0
Hello,
Quoted 11 lines · Stephen Hemminger
When using function versioning and building with Link Time Optimization, the compiler does not see the
__asm__annotation of symbols and therefore thinks there are two versions of the same symbol.The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Bugzilla ID: 1949
Fixes e30e194c4d06 ("eal: rework function versioning macros")
We never used the symver stuff, so it seems unlikely the issue was introduced with this rework.
The fact that clang does not support this attribute is a concern.
Quoted 1 line
Why do we need to backport?
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>
I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
Signature · 1 line
David Marchand
Quoted 29 lines · On Wed, 3 Jun 2026 12:01:48 +0200 David Marchand <[email protected]>…
Hello,
Quoted 11 lines · Stephen Hemminger
When using function versioning and building with Link Time Optimization, the compiler does not see the
__asm__annotation of symbols and therefore thinks there are two versions of the same symbol.The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Bugzilla ID: 1949
Fixes e30e194c4d06 ("eal: rework function versioning macros")We never used the symver stuff, so it seems unlikely the issue was introduced with this rework.
The fact that clang does not support this attribute is a concern.
Quoted 1 line
Why do we need to backport?
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
Quoted 7 lines
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
I get no warnings from current main with GCC 15
I was doing test build of net-next with this patch:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
The LTO build is done by:
$ meson setup build-lto -Db_lto=true
The result was:
cc -o lib/librte_ethdev.so.26.2 lib/librte_ethdev.so.26.2.p/ethdev_ethdev_driver.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_private.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_profile.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_trace_points.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_class_eth.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_cman.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_flow.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_mtr.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_tm.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_common.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8079.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8472.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8636.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_linux_ethtool.c.o -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,librte_ethdev.so.26 -Wl,--no-as-needed -Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/' lib/librte_eal.so.26.2 lib/librte_kvargs.so.26.2 lib/librte_log.so.26.2 lib/librte_telemetry.so.26.2 lib/librte_argparse.so.26.2 lib/librte_net.so.26.2 lib/librte_mbuf.so.26.2 lib/librte_mempool.so.26.2 lib/librte_ring.so.26.2 lib/librte_meter.so.26.2 -Wl,--version-script=/home/shemminger/DPDK/lto/build-lto/lib/ethdev_exports.map /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libarchive.so -Wl,--end-group /tmp/cc3RQyqL.s: Assembler messages:
/tmp
Fed the result into Claude, and it said "yeah, I see the same problem on other projects, the answer is ...". With a little searching found an example in Gentoo https://github.com/InBetweenNames/gentooLTO/pull/458
With this change symbol versioning with LTO works on both GCC >= 10 and Clang. Clang LTO doesn't have the attribute, but it also doesn't have the same LTO issue.
Quoted 13 lines · On Wed, 3 Jun 2026 12:01:48 +0200 David Marchand <[email protected]>…
Hello,
Quoted 9 lines · Stephen Hemminger
When using function versioning and building with Link Time Optimization, the compiler does not see the
__asm__annotation of symbols and therefore thinks there are two versions of the same symbol.The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Quoted 7 lines
Quoted 2 lines
Bugzilla ID: 1949
Fixes e30e194c4d06 ("eal: rework function versioning macros")We never used the symver stuff, so it seems unlikely the issue was introduced with this rework.
The fact that clang does not support this attribute is a concern.
Clang doesn't have this problem. It works as is.
Quoted 3 lines
Quoted 1 line
Why do we need to backport?
Well LTO has worked for a long time, it is not experimental just not commonly done since it takes so long to build.
We were doing it years ago at MSFT.
Quoted 11 lines
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
I use Debian testing and GCC 15 but shows up on older versions as well I get no warnings building main
$ git am ~/Downloads/v2-ethdev-add-buffer-size-parameter-to-rte_eth_dev_get_name_by_port.patch $ meson setup build-lto -Db_lto=true $ ninja -C build-lto ninja: Entering directory `build-lto' [620/3781] Linking target lib/librte_ethdev.so.26.2 FAILED: [code=1] lib/librte_ethdev.so.26.2 cc -o lib/librte_ethdev.so.26.2 lib/librte_ethdev.so.26.2.p/ethdev_ethdev_driver.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_private.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_profile.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_trace_points.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_class_eth.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_cman.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_flow.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_mtr.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_tm.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_common.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8079.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8472.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8636.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_linux_ethtool.c.o -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,librte_ethdev.so.26 -Wl,--no-as-needed -Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/' lib/librte_eal.so.26.2 lib/librte_kvargs.so.26.2 lib/librte_log.so.26.2 lib/librte_telemetry.so.26.2 lib/librte_argparse.so.26.2 lib/librte_net.so.26.2 lib/librte_mbuf.so.26.2 lib/librte_mempool.so.26.2 lib/librte_ring.so.26.2 lib/librte_meter.so.26.2 -Wl,--version-script=/home/shemminger/DPDK/lto/build-lto/lib/ethdev_exports.map /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libarchive.so -Wl,--end-group /tmp/cc3RQyqL.s: Assembler messages: /tmp/cc3RQyqL.s: Error: invalid attempt to declare external version name as default in symbol `rte_eth_dev_get_name_by_port@@DPDK_27' make: *** [/tmp/ccVzgiZ2.mk:2: /tmp/ccTlGfA9.ltrans0.ltrans.o] Error 1 make: *** Waiting for unfinished jobs.... lto-wrapper: fatal error: make returned 2 exit status compilation terminated.
Quoted 20 lines · Stephen Hemminger
Quoted 16 lines · On Wed, 3 Jun 2026 12:01:48 +0200 David Marchand <[email protected]>…
Hello,
Quoted 11 lines · Stephen Hemminger
When using function versioning and building with Link Time Optimization, the compiler does not see the
__asm__annotation of symbols and therefore thinks there are two versions of the same symbol.The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Bugzilla ID: 1949
Fixes e30e194c4d06 ("eal: rework function versioning macros")
Quoted 6 lines
Quoted 4 lines
We never used the symver stuff, so it seems unlikely the issue was introduced with this rework.
The fact that clang does not support this attribute is a concern.
Clang doesn't have this problem. It works as is.
The Fixes: tag is wrong regardless.
The issue is probably present since introduction of the versioning macros, or introduction of LTO in DPDK (not sure which came first).
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Why do we need to backport?
Well LTO has worked for a long time, it is not experimental just not commonly done since it takes so long to build.
We were doing it years ago at MSFT.
Well, sorry, but every time I enable LTO, I end up with some warnings somewhere. I don't think I am doing stuff really exotic though.
Looking at bugzilla, we had various fixes for LTO over the years. We still have one open bz btw: https://bugs.dpdk.org/show_bug.cgi?id=1709
Hence my feeling this feature is not something used by many people around. And without a CI, we will keep on having to fix bugs/issues.
Quoted 5 lines
Quoted 5 lines
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Just to be clear, we don't need fixing the macros in LTS: every time we prepare a LTS rc0, we drop any kind of symbol compat.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Stephen Hemminger <[email protected]>I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
I use Debian testing and GCC 15 but shows up on older versions as well I get no warnings building main
Building from scratch, I do avoid the warnings I hit yesterday.
The fix looks correct, my problem is with the form.
Fixes: tags accuracy is important.
And I prefer we stick to "It is not broken, don't fix it".
Thanks.
Quoted 15 lines
$ git am ~/Downloads/v2-ethdev-add-buffer-size-parameter-to-rte_eth_dev_get_name_by_port.patch $ meson setup build-lto -Db_lto=true $ ninja -C build-lto ninja: Entering directory `build-lto' [620/3781] Linking target lib/librte_ethdev.so.26.2 FAILED: [code=1] lib/librte_ethdev.so.26.2 cc -o lib/librte_ethdev.so.26.2 lib/librte_ethdev.so.26.2.p/ethdev_ethdev_driver.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_private.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_profile.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_trace_points.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_class_eth.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_cman.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_ethdev_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_flow.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_mtr.c.o lib/librte_ethdev.so.26.2.p/ethdev_rte_tm.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_telemetry.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_common.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8079.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8472.c.o lib/librte_ethdev.so.26.2.p/ethdev_sff_8636.c.o lib/librte_ethdev.so.26.2.p/ethdev_ethdev_linux_ethtool.c.o -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,librte_ethdev.so.26 -Wl,--no-as-needed -Wl,--undefined-version -pthread -Wl,--start-group -lm -ldl -lnuma -lfdt '-Wl,-rpath,$ORIGIN/' lib/librte_eal.so.26.2 lib/librte_kvargs.so.26.2 lib/librte_log.so.26.2 lib/librte_telemetry.so.26.2 lib/librte_argparse.so.26.2 lib/librte_net.so.26.2 lib/librte_mbuf.so.26.2 lib/librte_mempool.so.26.2 lib/librte_ring.so.26.2 lib/librte_meter.so.26.2 -Wl,--version-script=/home/shemminger/DPDK/lto/build-lto/lib/ethdev_exports.map /usr/lib/x86_64-linux-gnu/libbsd.so /usr/lib/x86_64-linux-gnu/libarchive.so -Wl,--end-group /tmp/cc3RQyqL.s: Assembler messages: /tmp/cc3RQyqL.s: Error: invalid attempt to declare external version name as default in symbol `rte_eth_dev_get_name_by_port@@DPDK_27' make: *** [/tmp/ccVzgiZ2.mk:2: /tmp/ccTlGfA9.ltrans0.ltrans.o] Error 1 make: *** Waiting for unfinished jobs.... lto-wrapper: fatal error: make returned 2 exit status compilation terminated.
Signature · 1 line
David Marchand
Quoted 25 lines · On Thu, 4 Jun 2026 09:50:25 +0200 David Marchand <[email protected]>…
Quoted 23 lines · Stephen Hemminger
Quoted 19 lines · On Wed, 3 Jun 2026 12:01:48 +0200 David Marchand <[email protected]>…
Hello,
Quoted 11 lines · Stephen Hemminger
When using function versioning and building with Link Time Optimization, the compiler does not see the
__asm__annotation of symbols and therefore thinks there are two versions of the same symbol.The fix is to use compiler symver attribute on the function which was added in GCC 10. Keep the older method for backward compatibility with older compilers.
Bugzilla ID: 1949
Fixes e30e194c4d06 ("eal: rework function versioning macros")We never used the symver stuff, so it seems unlikely the issue was introduced with this rework.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
The fact that clang does not support this attribute is a concern.
Clang doesn't have this problem. It works as is.
The Fixes: tag is wrong regardless.
The issue is probably present since introduction of the versioning macros, or introduction of LTO in DPDK (not sure which came first).
Right the Fixes is wrong, will resend without
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Why do we need to backport?
Quoted 7 lines
Quoted 4 lines
Well LTO has worked for a long time, it is not experimental just not commonly done since it takes so long to build.
We were doing it years ago at MSFT.
Well, sorry, but every time I enable LTO, I end up with some warnings somewhere. I don't think I am doing stuff really exotic though.
Using LTO has always been extra effort. It is worth it for largish legacy code because the compiler can crunch things down.
Quoted 3 lines
Looking at bugzilla, we had various fixes for LTO over the years. We still have one open bz btw: https://bugs.dpdk.org/show_bug.cgi?id=1709
That bug was fixed a while back. It required addition of hints (__rte_assume)
Quoted 5 lines
Hence my feeling this feature is not something used by many people around. And without a CI, we will keep on having to fix bugs/issues.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Just to be clear, we don't need fixing the macros in LTS: every time we prepare a LTS rc0, we drop any kind of symbol compat.
Agree, this is not LTS related
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Stephen Hemminger <[email protected]>I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
Quoted 8 lines
Quoted 2 lines
I use Debian testing and GCC 15 but shows up on older versions as well I get no warnings building main
Building from scratch, I do avoid the warnings I hit yesterday.
The fix looks correct, my problem is with the form.
Fixes: tags accuracy is important.
And I prefer we stick to "It is not broken, don't fix it".
Could argue it is a GCC bug, and applying their desired workaround :-)
Quoted 5 lines · Stephen Hemminger
Quoted 3 lines
Looking at bugzilla, we had various fixes for LTO over the years. We still have one open bz btw: https://bugs.dpdk.org/show_bug.cgi?id=1709
That bug was fixed a while back. It required addition of hints (
__rte_assume)
I have trouble identifying the changes.
Please close the 1709 bugzilla with a mention of those changes.
Quoted 19 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
LTO is kind of experimental, so it seems good enough to reply "not expected to work in older LTS" if someone reported an issue.
And in practice, no LTS release call the versioning macros, since a LTS drops all compatibility.
Just to be clear, we don't need fixing the macros in LTS: every time we prepare a LTS rc0, we drop any kind of symbol compat.
Agree, this is not LTS related
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Stephen Hemminger <[email protected]>I would like to reproduce, but I can't build main with LTO. What patches did you apply locally to avoid warnings on the hash library?
I use Debian testing and GCC 15 but shows up on older versions as well I get no warnings building main
Quoted 7 lines
Quoted 5 lines
Building from scratch, I do avoid the warnings I hit yesterday.
The fix looks correct, my problem is with the form.
Fixes: tags accuracy is important.
And I prefer we stick to "It is not broken, don't fix it".Could argue it is a GCC bug, and applying their desired workaround :-)
Indeed, but the end results is the same for me :-)
Can you send a v2?
Thanks.
Signature · 1 line
David Marchand
PATCH v2 1/1 eal: fix function versioning with LTO
In reply to Stephen HemmingerWhen using function versioning and building with LTO, GCC gets confused by the symbol versioning using __asm__. There are no uses of function versioning in upstream repo. This was found when adding additional parameter to rte_eth_dev_get_name_by_port.
Assembler messages:
Error: invalid attempt to declare external version name as default in symbol `rte_eth_dev_get_name_by_port@@DPDK_27'
The workaround GCC 10 introduced was an additional function attribute; clang doesn't have or need this attribute. No need to backport this to LTS since there is no function versioning in those releases.
---
v2 - reword commit message
lib/eal/common/eal_export.h | 46 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-)
lib/eal/common/eal_export.h +34 -12
@@ -30,39 +30,61 @@* new functionality, behavior, etc. When that occurs, it is desirable to * allow for backwards compatibility for a time with older binaries that are * dynamically linked to the dpdk. +* +* RTE_VERSION_SYMBOL +* Create a symbol version table entry binding symbol <name>@DPDK_<ver> to the internal +* function name <name>_v<ver>. +* +* RTE_VERSION_EXPERIMENTAL_SYMBOL similar to RTE_VERSION_SYMBOL but for experimental API symbols. +* This is mainly used for keeping compatibility for symbols that get promoted to stable ABI. +* +* RTE_DEFAULT_SYMBOL +* Create a symbol version entry instructing the linker to bind references to +* symbol <name> to the internal symbol <name>_v<ver>. */ #ifdef RTE_BUILD_SHARED_LIB -/* -* Create a symbol version table entry binding symbol <name>@DPDK_<ver> to the internal -* function name <name>_v<ver>. -*/ +/* Prefer the compiler method of versioning which uses attributes */ +#if __has_attribute (symver) + +#define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@DPDK_" RTE_STR(ver)))) \ + type name ## _v ## ver args; \ + type name ## _v ## ver args + +#define RTE_VERSION_EXPERIMENTAL_SYMBOL (type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@EXPERIMENTAL"))) \ + type name ## _exp args; \ + type name ## _exp args + +#define RTE_DEFAULT_SYMBOL (ver, type, name, args) VERSIONING_WARN \ + __attribute__((__symver__(RTE_STR(name) "@@DPDK_" RTE_STR(ver)))) \ + type name ## _v ## ver args; \ + type name ## _v ## ver args +#else /* !__has_attribute(symver) */ + +/* Use asm tag to create symbol table entry */ #define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_v" RTE_STR(ver) ", " RTE_STR(name) "@DPDK_" RTE_STR(ver)); \ __rte_used type name ## _v ## ver args; \ type name ## _v ## ver args -/* -* Similar to RTE_VERSION_SYMBOL but for experimental API symbols. -* This is mainly used for keeping compatibility for symbols that get promoted to stable ABI. -*/ #define RTE_VERSION_EXPERIMENTAL_SYMBOL (type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_exp, " RTE_STR(name) "@EXPERIMENTAL") \ __rte_used type name ## _exp args; \ type name ## _exp args -/* -* Create a symbol version entry instructing the linker to bind references to -* symbol <name> to the internal symbol <name>_v<ver>. -*/ #define RTE_DEFAULT_SYMBOL (ver, type, name, args) VERSIONING_WARN \ __asm__(".symver " RTE_STR(name) "_v" RTE_STR(ver) ", " RTE_STR(name) "@@DPDK_" RTE_STR(ver)); \ __rte_used type name ## _v ## ver args; \ type name ## _v ## ver args +#endif /* __has_attribute(symver) */ +#else /* !RTE_BUILD_SHARED_LIB */ +/* static library does not have versioned symbols */ #define RTE_VERSION_SYMBOL (ver, type, name, args) VERSIONING_WARN \ type name ## _v ## ver args; \ type name ## _v ## ver args
Signature · 1 line
2.53.0
Quoted 7 lines · Stephen Hemminger
When using function versioning and building with LTO, GCC gets confused by the symbol versioning using
__asm__. There are no uses of function versioning in upstream repo. This was found when adding additional parameter torte_eth_dev_get_name_by_port.
Quoted 8 lines
Assembler messages:
Error: invalid attempt to declare external version name as default in symbol `rte_eth_dev_get_name_by_port@@DPDK_27'The workaround GCC 10 introduced was an additional function attribute; clang doesn't have or need this attribute. No need to backport this to LTS since there is no function versioning in those releases.
Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand