mbuf: enable to be compiled with MSVC
PATCH 1/1 mbuf: enable to be compiled with MSVC
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.
--- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-)
lib/mbuf/meson.build +0 -6
@@ -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',
Signature · 1 line
2.47.2.vfs.0.1
Quoted 8 lines · On Mon, 10 Feb 2025 13:51:05 -0800 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 <[email protected]>---
Getting close to building test-pmd on Windows?
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Mon, 10 Feb 2025 13:51:05 -0800 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.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Andre Muezerie <[email protected]>---
Getting close to building test-pmd on Windows?
We are getting closer, yes :-)
Thomas Monjalon
Applied11/02/2025 03:19, Andre Muezerie:
Quoted 10 lines · Stephen Hemminger
Quoted 9 lines
Quoted 6 lines · On Mon, 10 Feb 2025 13:51:05 -0800 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.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Andre Muezerie <[email protected]>---
Getting close to building test-pmd on Windows?
We are getting closer, yes :-)
Good news
Applied, thanks.
Mer 12 févr 2025, à 15:23, Thomas Monjalon a écrit :
Quoted 16 lines
11/02/2025 03:19, Andre Muezerie:
Quoted 15 lines · Stephen Hemminger
Quoted 14 lines
Quoted 8 lines · On Mon, 10 Feb 2025 13:51:05 -0800 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 <[email protected]>---
Getting close to building test-pmd on Windows?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
We are getting closer, yes :-)
Good news
Applied, thanks.
The patch has been removed from main because Andre reported a compilation issue.
v2 cover mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieWhen 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
PATCH v2 1/5 doc: update guide on versioning macros
Added explanation about new macro MAP_STATIC_BASE_SYMBOL.
--- doc/guides/contributing/abi_versioning.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/guides/contributing/abi_versioning.rst +6 -0
@@ -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``
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 4/5 net: update use of versioning macros
In reply to Andre MuezerieWhen 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.
--- 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
lib/net/rte_net_crc.c +2 -0
@@ -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)
lib/net/version_ms_linker.map new file +23 -0
@@ -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;
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 3/5 eal: update versioning macros
In reply to Andre MuezerieWhen 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.
--- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
lib/eal/include/rte_function_versioning.h +19 -0
@@ -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 */
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 2/5 buildtools: update map_to_win.py to use optional map file
In reply to Andre MuezerieWhen 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.
--- buildtools/map_to_win.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
buildtools/map_to_win.py +15 -1
@@ -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
Signature · 1 line
2.48.1.vfs.0.0
PATCH v2 5/5 mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieNow 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.
--- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-)
lib/mbuf/meson.build +0 -6
@@ -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',
Signature · 1 line
2.48.1.vfs.0.0
v3 cover mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieWhen 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
PATCH v3 1/6 doc: update guide on versioning macros
Added explanation about new macro MAP_STATIC_BASE_SYMBOL.
--- doc/guides/contributing/abi_versioning.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/guides/contributing/abi_versioning.rst +6 -0
@@ -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``
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 2/6 buildtools: update map_to_win.py to use optional map file
In reply to Andre MuezerieWhen 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.
--- buildtools/map_to_win.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
buildtools/map_to_win.py +15 -1
@@ -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
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 3/6 eal: update versioning macros
In reply to Andre MuezerieWhen 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.
--- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
lib/eal/include/rte_function_versioning.h +19 -0
@@ -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 */
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 4/6 devtools: check ms linker map files
In reply to Andre MuezerieMSVC 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.
--- devtools/check-symbol-maps.sh | 49 +++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-)
devtools/check-symbol-maps.sh +41 -8
@@ -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 }
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 6/6 mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieNow 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.
--- lib/mbuf/meson.build | 6 ------ 1 file changed, 6 deletions(-)
lib/mbuf/meson.build +0 -6
@@ -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',
Signature · 1 line
2.48.1.vfs.0.0
PATCH v3 5/6 net: update use of versioning macros
In reply to Andre MuezerieWhen 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.
--- 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
lib/net/rte_net_crc.c +2 -0
@@ -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)
lib/net/version_ms_linker.map new file +23 -0
@@ -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;
Signature · 1 line
2.48.1.vfs.0.0
Re: [PATCH v2 3/5] eal: update versioning macros
In reply to Andre MuezerieQuoted 39 lines · Andre Muezerie
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 <[email protected]>--- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)lib/eal/include/rte_function_versioning.h +7
-0@@ -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
lib/eal/include/rte_function_versioning.h line 102
Quoted 6 lines
lib/eal/include/rte_function_versioning.h +3
-0@@ -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)
I would prefer we trigger an explicit error when some code calling MAP_STATIC_SYMBOL() is built with MSVC.
lib/eal/include/rte_function_versioning.h line 112
Quoted 10 lines
lib/eal/include/rte_function_versioning.h +9
-0+#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 +
But in any case, I don't like as we end up with one macro for each linker.
I have been thinking about this topic, and I sent a RFC series, please have a look.
https://patchwork.dpdk.org/project/dpdk/list/?series=34798
I hope this type of approach will also make it possible to stop converting from GNU linker type version.map commited in DPDK to Windows linker format.
Signature · 1 line
David Marchand
Re: [PATCH v2 3/5] eal: update versioning macros
Quoted 65 lines · David Marchand
Quoted 39 lines · Andre Muezerie
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 <[email protected]>--- lib/eal/include/rte_function_versioning.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)lib/eal/include/rte_function_versioning.h +7
-0@@ -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 lib/eal/include/rte_function_versioning.h line 102
Quoted 6 lines
lib/eal/include/rte_function_versioning.h +3
-0@@ -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)I would prefer we trigger an explicit error when some code calling
MAP_STATIC_SYMBOL()is built with MSVC.lib/eal/include/rte_function_versioning.h line 112
Quoted 10 lines
lib/eal/include/rte_function_versioning.h +9
-0+#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 +But in any case, I don't like as we end up with one macro for each linker.
Quoted 8 lines
I have been thinking about this topic, and I sent a RFC series, please have a look.
https://patchwork.dpdk.org/project/dpdk/list/?series=34798I hope this type of approach will also make it possible to stop converting from GNU linker type version.map commited in DPDK to Windows linker format.
I like what you're proposing. This makes DPDK less coupled with the GNU linker and therefore easier to be supported by other toolsets.
Quoted 3 lines
Signature · 2 lines
-- David Marchand
Hello Andre,
Quoted 9 lines · 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 <[email protected]>Acked-by Bruce Richardson <[email protected]>
I just merged the symbol export / versioning rework series. Could you please resend this patch only, for the CI to have a go?
Thank you.
Signature · 1 line
David Marchand
Quoted 8 lines · David Marchand
Hello Andre,
Quoted 4 lines · Andre Muezerie
Now that the issues preventing this lib from be compiled with MSVC are fixed it can be included in the compilation.
Quoted 9 lines
Quoted 5 lines
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 <[email protected]>Acked-by Bruce Richardson <[email protected]>I just merged the symbol export / versioning rework series. Could you please resend this patch only, for the CI to have a go?
That's great news!
I'll send out the updated patch, and also review the other patches to see if they need changes.
Quoted 5 lines
Thank you.
Signature · 1 line
David Marchand
PATCH v4 1/1 mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieNow that the issues preventing this lib from being 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.
--- lib/mbuf/meson.build | 6 ------ lib/net/meson.build | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-)
lib/mbuf/meson.build +0 -6
@@ -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',
lib/net/meson.build +6 -1
@@ -43,7 +43,12 @@ use_function_versioning = true if dpdk_conf.has('RTE_ARCH_X86_64') sources += files('net_crc_sse.c') - cflags += ['-mpclmul', '-maes'] + cflags_options = ['-mpclmul', '-maes'] + foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif + endforeach # only build AVX-512 support if we also have PCLMULQDQ support if cc.has_argument('-mvpclmulqdq') sources_avx512 += files('net_crc_avx512.c')
Signature · 1 line
2.49.0.vfs.0.0
v4 cover mbuf: enable to be compiled with MSVC
In reply to Andre MuezerieNow that the issues preventing this lib from being compiled with MSVC are fixed it can be included in the compilation.
v4:
- removed all symbol-related changes, leaving only the change to enable MSVC compilation.
- only adding cflags '-mpclmul' and '-maes' when the compiler used supports them.
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 (1):
mbuf: enable to be compiled with MSVC
lib/mbuf/meson.build | 6 ------ lib/net/meson.build | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-)
--
2.49.0.vfs.0.0
Quoted 5 lines · Andre Muezerie
lib/net/meson.build +0
-0
lib/net/meson.build use_function_versioning = true · line 51
Quoted 10 lines
lib/net/meson.build +6
-1@@ -43,7 +43,12 @@ use_function_versioning = true if dpdk_conf.has('RTE_ARCH_X86_64') sources += files('net_crc_sse.c') - cflags += ['-mpclmul', '-maes'] + cflags_options = ['-mpclmul', '-maes'] + foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif + endforeach
What guarantee do we have that MSVC builds with those instructions?
Quoted 3 lines
lib/net/meson.build +0
-0# only build AVX-512 support if we also have PCLMULQDQ support if cc.has_argument('-mvpclmulqdq') sources_avx512 += files('net_crc_avx512.c')
Signature · 1 line
David Marchand
Quoted 8 lines · David Marchand
Quoted 6 lines · Andre Muezerie
lib/net/meson.build +0
-0@@ -43,7 +43,12 @@ use_function_versioning = true
Quoted 12 lines
lib/net/meson.build use_function_versioning = true · line 51
Quoted 9 lines
lib/net/meson.build +6
-1if dpdk_conf.has('RTE_ARCH_X86_64') sources += files('net_crc_sse.c') - cflags += ['-mpclmul', '-maes'] + cflags_options = ['-mpclmul', '-maes'] + foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif + endforeachWhat guarantee do we have that MSVC builds with those instructions?
The granularity msvc offers for extended instruction sets is different. I had sent a patch that allows DPDK code to benefit from those settings, but it likely needs to be updated after recent changes were merged. I'll revisit that in the next few days.
For reference, here is what the original patch series looked like:
https://patches.dpdk.org/project/dpdk/list/?series=34803
Quoted 7 lines
Quoted 3 lines
lib/net/meson.build +0
-0# only build AVX-512 support if we also have PCLMULQDQ support if cc.has_argument('-mvpclmulqdq') sources_avx512 += files('net_crc_avx512.c')Signature · 1 line
David Marchand
David Marchand
AppliedQuoted 9 lines · Andre Muezerie
Now that the issues preventing this lib from being 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 <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand
Quoted 22 lines · Andre Muezerie
Quoted 8 lines · David Marchand
Quoted 6 lines · Andre Muezerie
lib/net/meson.build +0
-0@@ -43,7 +43,12 @@ use_function_versioning = trueQuoted 12 lines
lib/net/meson.build use_function_versioning = true · line 51
Quoted 9 lines
lib/net/meson.build +6
-1if dpdk_conf.has('RTE_ARCH_X86_64') sources += files('net_crc_sse.c') - cflags += ['-mpclmul', '-maes'] + cflags_options = ['-mpclmul', '-maes'] + foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif + endforeachWhat guarantee do we have that MSVC builds with those instructions?
Quoted 8 lines
The granularity msvc offers for extended instruction sets is different. I had sent a patch that allows DPDK code to benefit from those settings, but it likely needs to be updated after recent changes were merged. I'll revisit that in the next few days.
For reference, here is what the original patch series looked like:
https://patches.dpdk.org/project/dpdk/list/?series=34803
I checked the patch mentioned and confirmed that it still applies cleanly and that the build succeeds with the patch applied. It's ready to be reviewed.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
lib/net/meson.build +0
-0# only build AVX-512 support if we also have PCLMULQDQ support if cc.has_argument('-mvpclmulqdq') sources_avx512 += files('net_crc_avx512.c')Signature · 1 line
David Marchand