[PATCH v3 2/6] buildtools: update map_to_win.py to use optional map file
Andre Muezerie
andremue at linux.microsoft.com
Thu Feb 20 21:31:44 CET 2025
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 at 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
More information about the dev
mailing list