* [PATCH] mbuf: enable to be compiled with MSVC @ 2025-02-10 21:51 Andre Muezerie 2025-02-10 22:34 ` Stephen Hemminger ` (2 more replies) 0 siblings, 3 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-10 21:51 UTC (permalink / raw) Cc: dev, Andre Muezerie Now that the issues preventing this lib from be compiled with MSVC are fixed it can be included in the compilation. The "net" library will automatically get compiled as well as it has a dependency on "mbuf" which will now get fulfilled. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/mbuf/meson.build b/lib/mbuf/meson.build index 2cee9057a5..0435c5e628 100644 --- a/lib/mbuf/meson.build +++ b/lib/mbuf/meson.build @@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if is_ms_compiler - build = false - reason = 'not supported building with Visual Studio Toolset' - subdir_done() -endif - sources = files( 'rte_mbuf.c', 'rte_mbuf_ptype.c', -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mbuf: enable to be compiled with MSVC 2025-02-10 21:51 [PATCH] mbuf: enable to be compiled with MSVC Andre Muezerie @ 2025-02-10 22:34 ` Stephen Hemminger 2025-02-11 2:19 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie 2 siblings, 1 reply; 18+ messages in thread From: Stephen Hemminger @ 2025-02-10 22:34 UTC (permalink / raw) To: Andre Muezerie; +Cc: dev On Mon, 10 Feb 2025 13:51:05 -0800 Andre Muezerie <andremue@linux.microsoft.com> wrote: > Now that the issues preventing this lib from be compiled with MSVC > are fixed it can be included in the compilation. > > The "net" library will automatically get compiled as well as it > has a dependency on "mbuf" which will now get fulfilled. > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- Getting close to building test-pmd on Windows? Acked-by: Stephen Hemminger <stephen@networkplumber.org> ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mbuf: enable to be compiled with MSVC 2025-02-10 22:34 ` Stephen Hemminger @ 2025-02-11 2:19 ` Andre Muezerie 2025-02-12 14:23 ` Thomas Monjalon 0 siblings, 1 reply; 18+ messages in thread From: Andre Muezerie @ 2025-02-11 2:19 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev On Mon, Feb 10, 2025 at 02:34:29PM -0800, Stephen Hemminger wrote: > On Mon, 10 Feb 2025 13:51:05 -0800 > Andre Muezerie <andremue@linux.microsoft.com> wrote: > > > Now that the issues preventing this lib from be compiled with MSVC > > are fixed it can be included in the compilation. > > > > The "net" library will automatically get compiled as well as it > > has a dependency on "mbuf" which will now get fulfilled. > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > --- > > Getting close to building test-pmd on Windows? > > Acked-by: Stephen Hemminger <stephen@networkplumber.org> We are getting closer, yes :-) ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mbuf: enable to be compiled with MSVC 2025-02-11 2:19 ` Andre Muezerie @ 2025-02-12 14:23 ` Thomas Monjalon 2025-02-12 16:24 ` Thomas Monjalon 0 siblings, 1 reply; 18+ messages in thread From: Thomas Monjalon @ 2025-02-12 14:23 UTC (permalink / raw) To: Andre Muezerie; +Cc: Stephen Hemminger, dev 11/02/2025 03:19, Andre Muezerie: > On Mon, Feb 10, 2025 at 02:34:29PM -0800, Stephen Hemminger wrote: > > On Mon, 10 Feb 2025 13:51:05 -0800 > > Andre Muezerie <andremue@linux.microsoft.com> wrote: > > > > > Now that the issues preventing this lib from be compiled with MSVC > > > are fixed it can be included in the compilation. > > > > > > The "net" library will automatically get compiled as well as it > > > has a dependency on "mbuf" which will now get fulfilled. > > > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > > --- > > > > Getting close to building test-pmd on Windows? > > > > Acked-by: Stephen Hemminger <stephen@networkplumber.org> > > We are getting closer, yes :-) Good news Applied, thanks. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] mbuf: enable to be compiled with MSVC 2025-02-12 14:23 ` Thomas Monjalon @ 2025-02-12 16:24 ` Thomas Monjalon 0 siblings, 0 replies; 18+ messages in thread From: Thomas Monjalon @ 2025-02-12 16:24 UTC (permalink / raw) To: Andre Muezerie; +Cc: Stephen Hemminger, dev Mer 12 févr 2025, à 15:23, Thomas Monjalon a écrit : > 11/02/2025 03:19, Andre Muezerie: >> On Mon, Feb 10, 2025 at 02:34:29PM -0800, Stephen Hemminger wrote: >> > On Mon, 10 Feb 2025 13:51:05 -0800 >> > Andre Muezerie <andremue@linux.microsoft.com> wrote: >> > >> > > Now that the issues preventing this lib from be compiled with MSVC >> > > are fixed it can be included in the compilation. >> > > >> > > The "net" library will automatically get compiled as well as it >> > > has a dependency on "mbuf" which will now get fulfilled. >> > > >> > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> >> > > --- >> > >> > Getting close to building test-pmd on Windows? >> > >> > Acked-by: Stephen Hemminger <stephen@networkplumber.org> >> >> We are getting closer, yes :-) > > Good news > > Applied, thanks. The patch has been removed from main because Andre reported a compilation issue. ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 0/5] mbuf: enable to be compiled with MSVC 2025-02-10 21:51 [PATCH] mbuf: enable to be compiled with MSVC Andre Muezerie 2025-02-10 22:34 ` Stephen Hemminger @ 2025-02-19 1:39 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 1/5] doc: update guide on versioning macros Andre Muezerie ` (4 more replies) 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie 2 siblings, 5 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. v2: - updated versioning macros so that the latest mbuf/net code can compile with MSVC. V1 did not have these changes because by the time that series was sent out the versioning problem had not surfaced yet. - for testing purposes, dpdk-test was build with msvc and crc_autotest was run successfully. This test is known to call the versioned function which raised the issue. Andre Muezerie (5): doc: update guide on versioning macros buildtools: update map_to_win.py to use optional map file eal: update versioning macros net: update use of versioning macros mbuf: enable to be compiled with MSVC buildtools/map_to_win.py | 16 ++++++++++++++- doc/guides/contributing/abi_versioning.rst | 6 ++++++ lib/eal/include/rte_function_versioning.h | 19 ++++++++++++++++++ lib/mbuf/meson.build | 6 ------ lib/net/rte_net_crc.c | 2 ++ lib/net/version_ms_linker.map | 23 ++++++++++++++++++++++ 6 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 lib/net/version_ms_linker.map -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/5] doc: update guide on versioning macros 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie @ 2025-02-19 1:39 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 2/5] buildtools: update map_to_win.py to use optional map file Andre Muezerie ` (3 subsequent siblings) 4 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev Added explanation about new macro MAP_STATIC_BASE_SYMBOL. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- doc/guides/contributing/abi_versioning.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/guides/contributing/abi_versioning.rst b/doc/guides/contributing/abi_versioning.rst index 7afd1c1886..1179445da3 100644 --- a/doc/guides/contributing/abi_versioning.rst +++ b/doc/guides/contributing/abi_versioning.rst @@ -151,6 +151,11 @@ The macros exported are: fully qualified function ``p``, so that if a symbol becomes versioned, it can still be mapped back to the public symbol name. +* ``MAP_STATIC_BASE_SYMBOL(b, p)``: Declare the base symbol ``b``, and map it + to the fully qualified function ``p``, so that if a symbol becomes versioned, + it can still be mapped back to the public symbol name. Used for compatibility + with MSVC. + * ``__vsym``: Annotation to be used in a declaration of the internal symbol ``be`` to signal that it is being used as an implementation of a particular version of symbol ``b``. @@ -397,6 +402,7 @@ defined, we add this ... } MAP_STATIC_SYMBOL(struct rte_acl_ctx *rte_acl_create(const struct rte_acl_param *param, int debug), rte_acl_create_v22); + MAP_STATIC_BASE_SYMBOL(rte_acl_create, rte_acl_create_v22); That tells the compiler that, when building a static library, any calls to the symbol ``rte_acl_create`` should be linked to ``rte_acl_create_v22`` -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 2/5] buildtools: update map_to_win.py to use optional map file 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 1/5] doc: update guide on versioning macros Andre Muezerie @ 2025-02-19 1:39 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 3/5] eal: update versioning macros Andre Muezerie ` (2 subsequent siblings) 4 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Script map_to_win.py was updated to look for this optional file and use it when available. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- buildtools/map_to_win.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/buildtools/map_to_win.py b/buildtools/map_to_win.py index aa1752cacd..f75db3842b 100644 --- a/buildtools/map_to_win.py +++ b/buildtools/map_to_win.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2019 Intel Corporation +import os import sys @@ -27,7 +28,20 @@ def main(args): # This works taking indented lines only which end with a ";" and which don't # have a colon in them, i.e. the lines defining functions only. else: - with open(args[1]) as f_in: + input_map = args[1] + + # When an optional map file for Microsoft's linker exists, use it. Function aliases can + # be used in these optional files. They end up in the exports.def file: + # EXPORTS + # rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + # More details about the export file syntax accepted by Microsoft's linker can be found + # here: + # https://learn.microsoft.com/en-us/cpp/build/reference/exports?view=msvc-170 + optional_input_map = input_map.removesuffix('.map') + '_ms_linker.map' + if os.path.exists(optional_input_map): + input_map = optional_input_map + + with open(input_map) as f_in: functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines()) if is_function_line(ln)] functions = ["EXPORTS\n"] + functions -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 3/5] eal: update versioning macros 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 1/5] doc: update guide on versioning macros Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 2/5] buildtools: update map_to_win.py to use optional map file Andre Muezerie @ 2025-02-19 1:39 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 4/5] net: update use of " Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 5/5] mbuf: enable to be compiled with MSVC Andre Muezerie 4 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/eal/include/rte_function_versioning.h b/lib/eal/include/rte_function_versioning.h index eb6dd2bc17..aa3165a659 100644 --- a/lib/eal/include/rte_function_versioning.h +++ b/lib/eal/include/rte_function_versioning.h @@ -82,6 +82,13 @@ */ #define MAP_STATIC_SYMBOL(f, p) +/* + * MAP_STATIC_BASE_SYMBOL + * Has the same purpose as MAP_STATIC_SYMBOL, but takes a base function name + * instead of the whole function prototype. It is used to support MSVC. + */ +#define MAP_STATIC_BASE_SYMBOL(b, p) + #else /* * No symbol versioning in use @@ -90,7 +97,19 @@ #define VERSION_SYMBOL_EXPERIMENTAL(b, e) #define __vsym #define BIND_DEFAULT_SYMBOL(b, e, n) + +#ifdef RTE_TOOLCHAIN_MSVC +#define MAP_STATIC_SYMBOL(f, p) +#define MAP_STATIC_BASE_SYMBOL(b, p) __pragma(comment(linker, "/alternatename:" #b "=" #p)) +/* + * version.map file should also be updated with "b=p;", like + * rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + */ +#else #define MAP_STATIC_SYMBOL(f, p) f __attribute__((alias(RTE_STR(p)))) +#define MAP_STATIC_BASE_SYMBOL(b, p) +#endif + /* * RTE_BUILD_SHARED_LIB=n */ -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 4/5] net: update use of versioning macros 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie ` (2 preceding siblings ...) 2025-02-19 1:39 ` [PATCH v2 3/5] eal: update versioning macros Andre Muezerie @ 2025-02-19 1:39 ` Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 5/5] mbuf: enable to be compiled with MSVC Andre Muezerie 4 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/net/rte_net_crc.c | 2 ++ lib/net/version_ms_linker.map | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/net/version_ms_linker.map diff --git a/lib/net/rte_net_crc.c b/lib/net/rte_net_crc.c index 2fb3eec231..5b41085a36 100644 --- a/lib/net/rte_net_crc.c +++ b/lib/net/rte_net_crc.c @@ -418,6 +418,7 @@ BIND_DEFAULT_SYMBOL(rte_net_crc_set_alg, _v26, 26); MAP_STATIC_SYMBOL(struct rte_net_crc *rte_net_crc_set_alg( enum rte_net_crc_alg alg, enum rte_net_crc_type type), rte_net_crc_set_alg_v26); +MAP_STATIC_BASE_SYMBOL(rte_net_crc_set_alg, rte_net_crc_set_alg_v26) void rte_net_crc_free(struct rte_net_crc *crc) { @@ -449,6 +450,7 @@ BIND_DEFAULT_SYMBOL(rte_net_crc_calc, _v26, 26); MAP_STATIC_SYMBOL(uint32_t rte_net_crc_calc(const struct rte_net_crc *ctx, const void *data, const uint32_t data_len), rte_net_crc_calc_v26); +MAP_STATIC_BASE_SYMBOL(rte_net_crc_calc, rte_net_crc_calc_v26) /* Call initialisation helpers for all crc algorithm handlers */ RTE_INIT(rte_net_crc_init) diff --git a/lib/net/version_ms_linker.map b/lib/net/version_ms_linker.map new file mode 100644 index 0000000000..9503c669d1 --- /dev/null +++ b/lib/net/version_ms_linker.map @@ -0,0 +1,23 @@ +DPDK_25 { + global: + + rte_eth_random_addr; + rte_ether_format_addr; + rte_ether_unformat_addr; + rte_net_crc_calc=rte_net_crc_calc_v26; + rte_net_crc_free; + rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + rte_net_get_ptype; + rte_net_make_rarp_packet; + rte_net_skip_ip6_ext; + + local: *; +}; + +DPDK_26 { + global: + + rte_net_crc_calc=rte_net_crc_calc_v26; + rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + +} DPDK_25; -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 5/5] mbuf: enable to be compiled with MSVC 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie ` (3 preceding siblings ...) 2025-02-19 1:39 ` [PATCH v2 4/5] net: update use of " Andre Muezerie @ 2025-02-19 1:39 ` Andre Muezerie 4 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-19 1:39 UTC (permalink / raw) To: andremue; +Cc: dev Now that the issues preventing this lib from be compiled with MSVC are fixed it can be included in the compilation. The "net" library will automatically get compiled as well as it has a dependency on "mbuf" which will now get fulfilled. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> --- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/mbuf/meson.build b/lib/mbuf/meson.build index 2cee9057a5..0435c5e628 100644 --- a/lib/mbuf/meson.build +++ b/lib/mbuf/meson.build @@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if is_ms_compiler - build = false - reason = 'not supported building with Visual Studio Toolset' - subdir_done() -endif - sources = files( 'rte_mbuf.c', 'rte_mbuf_ptype.c', -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/6] mbuf: enable to be compiled with MSVC 2025-02-10 21:51 [PATCH] mbuf: enable to be compiled with MSVC Andre Muezerie 2025-02-10 22:34 ` Stephen Hemminger 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 1/6] doc: update guide on versioning macros Andre Muezerie ` (5 more replies) 2 siblings, 6 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. v3: - updated check-symbol-maps.sh to also handle ms_linker.map files. v2: - updated versioning macros so that the latest mbuf/net code can compile with MSVC. V1 did not have these changes because by the time that series was sent out the versioning problem had not surfaced yet. - for testing purposes, dpdk-test was build with msvc and crc_autotest was run successfully. This test is known to call the versioned function which raised the issue. Andre Muezerie (6): doc: update guide on versioning macros buildtools: update map_to_win.py to use optional map file eal: update versioning macros devtools: check ms linker map files net: update use of versioning macros mbuf: enable to be compiled with MSVC buildtools/map_to_win.py | 16 ++++++- devtools/check-symbol-maps.sh | 49 ++++++++++++++++++---- doc/guides/contributing/abi_versioning.rst | 6 +++ lib/eal/include/rte_function_versioning.h | 19 +++++++++ lib/mbuf/meson.build | 6 --- lib/net/rte_net_crc.c | 2 + lib/net/version_ms_linker.map | 23 ++++++++++ 7 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 lib/net/version_ms_linker.map -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/6] doc: update guide on versioning macros 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 2/6] buildtools: update map_to_win.py to use optional map file Andre Muezerie ` (4 subsequent siblings) 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev Added explanation about new macro MAP_STATIC_BASE_SYMBOL. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- doc/guides/contributing/abi_versioning.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/guides/contributing/abi_versioning.rst b/doc/guides/contributing/abi_versioning.rst index 7afd1c1886..1179445da3 100644 --- a/doc/guides/contributing/abi_versioning.rst +++ b/doc/guides/contributing/abi_versioning.rst @@ -151,6 +151,11 @@ The macros exported are: fully qualified function ``p``, so that if a symbol becomes versioned, it can still be mapped back to the public symbol name. +* ``MAP_STATIC_BASE_SYMBOL(b, p)``: Declare the base symbol ``b``, and map it + to the fully qualified function ``p``, so that if a symbol becomes versioned, + it can still be mapped back to the public symbol name. Used for compatibility + with MSVC. + * ``__vsym``: Annotation to be used in a declaration of the internal symbol ``be`` to signal that it is being used as an implementation of a particular version of symbol ``b``. @@ -397,6 +402,7 @@ defined, we add this ... } MAP_STATIC_SYMBOL(struct rte_acl_ctx *rte_acl_create(const struct rte_acl_param *param, int debug), rte_acl_create_v22); + MAP_STATIC_BASE_SYMBOL(rte_acl_create, rte_acl_create_v22); That tells the compiler that, when building a static library, any calls to the symbol ``rte_acl_create`` should be linked to ``rte_acl_create_v22`` -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 2/6] buildtools: update map_to_win.py to use optional map file 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 1/6] doc: update guide on versioning macros Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 3/6] eal: update versioning macros Andre Muezerie ` (3 subsequent siblings) 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Script map_to_win.py was updated to look for this optional file and use it when available. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- buildtools/map_to_win.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/buildtools/map_to_win.py b/buildtools/map_to_win.py index aa1752cacd..f75db3842b 100644 --- a/buildtools/map_to_win.py +++ b/buildtools/map_to_win.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2019 Intel Corporation +import os import sys @@ -27,7 +28,20 @@ def main(args): # This works taking indented lines only which end with a ";" and which don't # have a colon in them, i.e. the lines defining functions only. else: - with open(args[1]) as f_in: + input_map = args[1] + + # When an optional map file for Microsoft's linker exists, use it. Function aliases can + # be used in these optional files. They end up in the exports.def file: + # EXPORTS + # rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + # More details about the export file syntax accepted by Microsoft's linker can be found + # here: + # https://learn.microsoft.com/en-us/cpp/build/reference/exports?view=msvc-170 + optional_input_map = input_map.removesuffix('.map') + '_ms_linker.map' + if os.path.exists(optional_input_map): + input_map = optional_input_map + + with open(input_map) as f_in: functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines()) if is_function_line(ln)] functions = ["EXPORTS\n"] + functions -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 3/6] eal: update versioning macros 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 1/6] doc: update guide on versioning macros Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 2/6] buildtools: update map_to_win.py to use optional map file Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 4/6] devtools: check ms linker map files Andre Muezerie ` (2 subsequent siblings) 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/eal/include/rte_function_versioning.h b/lib/eal/include/rte_function_versioning.h index eb6dd2bc17..aa3165a659 100644 --- a/lib/eal/include/rte_function_versioning.h +++ b/lib/eal/include/rte_function_versioning.h @@ -82,6 +82,13 @@ */ #define MAP_STATIC_SYMBOL(f, p) +/* + * MAP_STATIC_BASE_SYMBOL + * Has the same purpose as MAP_STATIC_SYMBOL, but takes a base function name + * instead of the whole function prototype. It is used to support MSVC. + */ +#define MAP_STATIC_BASE_SYMBOL(b, p) + #else /* * No symbol versioning in use @@ -90,7 +97,19 @@ #define VERSION_SYMBOL_EXPERIMENTAL(b, e) #define __vsym #define BIND_DEFAULT_SYMBOL(b, e, n) + +#ifdef RTE_TOOLCHAIN_MSVC +#define MAP_STATIC_SYMBOL(f, p) +#define MAP_STATIC_BASE_SYMBOL(b, p) __pragma(comment(linker, "/alternatename:" #b "=" #p)) +/* + * version.map file should also be updated with "b=p;", like + * rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + */ +#else #define MAP_STATIC_SYMBOL(f, p) f __attribute__((alias(RTE_STR(p)))) +#define MAP_STATIC_BASE_SYMBOL(b, p) +#endif + /* * RTE_BUILD_SHARED_LIB=n */ -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 4/6] devtools: check ms linker map files 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie ` (2 preceding siblings ...) 2025-02-20 20:31 ` [PATCH v3 3/6] eal: update versioning macros Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 5/6] net: update use of versioning macros Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 6/6] mbuf: enable to be compiled with MSVC Andre Muezerie 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Script check-symbol-maps.sh was updated to check these optional files. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- devtools/check-symbol-maps.sh | 49 +++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/devtools/check-symbol-maps.sh b/devtools/check-symbol-maps.sh index 6121f78ec6..816d52eae0 100755 --- a/devtools/check-symbol-maps.sh +++ b/devtools/check-symbol-maps.sh @@ -21,6 +21,21 @@ find_orphan_symbols () symsrc=${sym#per_lcore_} elif echo $sym | grep -q '^__rte_.*_trace_' ; then symsrc=${sym#__} + elif echo $map | grep -Eq '_ms_linker.map$' ; then + if echo $sym | grep -q '=' ; then + symsrc=$(echo $sym | awk ' + { + idx = index($0, "=") + if (idx > 0) { + # Use only what is on the left side of "=" + s = substr($0, 0, idx-1) + print s + } else { + print $0 + } + } + ') + fi else symsrc=$sym fi @@ -79,14 +94,32 @@ find_bad_format_maps () abi_version=$(cut -d'.' -f 1 ABI_VERSION) next_abi_version=$((abi_version + 1)) for map in $@ ; do - cat $map | awk ' - /^(DPDK_('$abi_version'|'$next_abi_version')|EXPERIMENTAL|INTERNAL) \{$/ { next; } # start of a section - /^}( DPDK_'$abi_version')?;$/ { next; } # end of a section - /^$/ { next; } # empty line - /^\t(global:|local: \*;)$/ { next; } # qualifiers - /^\t[a-zA-Z_0-9]*;( # WINDOWS_NO_EXPORT)?$/ { next; } # symbols - /^\t# added in [0-9]*\.[0-9]*$/ { next; } # version comments - { print $0; }' || echo $map + if echo $map | grep -Eq '_ms_linker.map$'; + then + # ms linker maps are only used for Windows, so there's no reason for + # them to allow WINDOWS_NO_EXPORT. + # These .map files accept alias function names, like + # rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + # Note that alias function names are not allowed in normal .map files. + cat $map | awk ' + /^(DPDK_('$abi_version'|'$next_abi_version')|EXPERIMENTAL|INTERNAL) \{$/ { next; } # start of a section + /^}( DPDK_'$abi_version')?;$/ { next; } # end of a section + /^$/ { next; } # empty line + /^\t(global:|local: \*;)$/ { next; } # qualifiers + /^\t[a-zA-Z_0-9]*;$/ { next; } # symbols + /^\t[a-zA-Z_0-9]*=[a-zA-Z_0-9]*;$/ { next; } # symbols with aliases + /^\t# added in [0-9]*\.[0-9]*$/ { next; } # version comments + { print $0; }' || echo $map + else + cat $map | awk ' + /^(DPDK_('$abi_version'|'$next_abi_version')|EXPERIMENTAL|INTERNAL) \{$/ { next; } # start of a section + /^}( DPDK_'$abi_version')?;$/ { next; } # end of a section + /^$/ { next; } # empty line + /^\t(global:|local: \*;)$/ { next; } # qualifiers + /^\t[a-zA-Z_0-9]*;( # WINDOWS_NO_EXPORT)?$/ { next; } # symbols + /^\t# added in [0-9]*\.[0-9]*$/ { next; } # version comments + { print $0; }' || echo $map + fi done } -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 5/6] net: update use of versioning macros 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie ` (3 preceding siblings ...) 2025-02-20 20:31 ` [PATCH v3 4/6] devtools: check ms linker map files Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 6/6] mbuf: enable to be compiled with MSVC Andre Muezerie 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev When compiling with MSVC the error below shows up due to function versioning: ../lib/net/rte_net_crc.c(418): error C2061: syntax error: identifier '__attribute__' MSVC allows alias function names to be exported, but the mechanism is different than the one used by gcc. It was considered to enhance the logic in the existing version.map files but that file is also passed to other tools on Linux, making this challenging. A simpler approach is to have an optional version.map file to be used only when Microsoft's linker is to be used. This optional map file is only necessary for libraries that have versioned code. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/net/rte_net_crc.c | 2 ++ lib/net/version_ms_linker.map | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/net/version_ms_linker.map diff --git a/lib/net/rte_net_crc.c b/lib/net/rte_net_crc.c index 2fb3eec231..5b41085a36 100644 --- a/lib/net/rte_net_crc.c +++ b/lib/net/rte_net_crc.c @@ -418,6 +418,7 @@ BIND_DEFAULT_SYMBOL(rte_net_crc_set_alg, _v26, 26); MAP_STATIC_SYMBOL(struct rte_net_crc *rte_net_crc_set_alg( enum rte_net_crc_alg alg, enum rte_net_crc_type type), rte_net_crc_set_alg_v26); +MAP_STATIC_BASE_SYMBOL(rte_net_crc_set_alg, rte_net_crc_set_alg_v26) void rte_net_crc_free(struct rte_net_crc *crc) { @@ -449,6 +450,7 @@ BIND_DEFAULT_SYMBOL(rte_net_crc_calc, _v26, 26); MAP_STATIC_SYMBOL(uint32_t rte_net_crc_calc(const struct rte_net_crc *ctx, const void *data, const uint32_t data_len), rte_net_crc_calc_v26); +MAP_STATIC_BASE_SYMBOL(rte_net_crc_calc, rte_net_crc_calc_v26) /* Call initialisation helpers for all crc algorithm handlers */ RTE_INIT(rte_net_crc_init) diff --git a/lib/net/version_ms_linker.map b/lib/net/version_ms_linker.map new file mode 100644 index 0000000000..9503c669d1 --- /dev/null +++ b/lib/net/version_ms_linker.map @@ -0,0 +1,23 @@ +DPDK_25 { + global: + + rte_eth_random_addr; + rte_ether_format_addr; + rte_ether_unformat_addr; + rte_net_crc_calc=rte_net_crc_calc_v26; + rte_net_crc_free; + rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + rte_net_get_ptype; + rte_net_make_rarp_packet; + rte_net_skip_ip6_ext; + + local: *; +}; + +DPDK_26 { + global: + + rte_net_crc_calc=rte_net_crc_calc_v26; + rte_net_crc_set_alg=rte_net_crc_set_alg_v26; + +} DPDK_25; -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 6/6] mbuf: enable to be compiled with MSVC 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie ` (4 preceding siblings ...) 2025-02-20 20:31 ` [PATCH v3 5/6] net: update use of versioning macros Andre Muezerie @ 2025-02-20 20:31 ` Andre Muezerie 5 siblings, 0 replies; 18+ messages in thread From: Andre Muezerie @ 2025-02-20 20:31 UTC (permalink / raw) To: andremue; +Cc: dev Now that the issues preventing this lib from be compiled with MSVC are fixed it can be included in the compilation. The "net" library will automatically get compiled as well as it has a dependency on "mbuf" which will now get fulfilled. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> --- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/mbuf/meson.build b/lib/mbuf/meson.build index 2cee9057a5..0435c5e628 100644 --- a/lib/mbuf/meson.build +++ b/lib/mbuf/meson.build @@ -1,12 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -if is_ms_compiler - build = false - reason = 'not supported building with Visual Studio Toolset' - subdir_done() -endif - sources = files( 'rte_mbuf.c', 'rte_mbuf_ptype.c', -- 2.48.1.vfs.0.0 ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-02-20 20:32 UTC | newest] Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-02-10 21:51 [PATCH] mbuf: enable to be compiled with MSVC Andre Muezerie 2025-02-10 22:34 ` Stephen Hemminger 2025-02-11 2:19 ` Andre Muezerie 2025-02-12 14:23 ` Thomas Monjalon 2025-02-12 16:24 ` Thomas Monjalon 2025-02-19 1:39 ` [PATCH v2 0/5] " Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 1/5] doc: update guide on versioning macros Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 2/5] buildtools: update map_to_win.py to use optional map file Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 3/5] eal: update versioning macros Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 4/5] net: update use of " Andre Muezerie 2025-02-19 1:39 ` [PATCH v2 5/5] mbuf: enable to be compiled with MSVC Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 0/6] " Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 1/6] doc: update guide on versioning macros Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 2/6] buildtools: update map_to_win.py to use optional map file Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 3/6] eal: update versioning macros Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 4/6] devtools: check ms linker map files Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 5/6] net: update use of versioning macros Andre Muezerie 2025-02-20 20:31 ` [PATCH v3 6/6] mbuf: enable to be compiled with MSVC Andre Muezerie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).