build: list symbols exports in a single file
PATCH 1/1 build: list symbols exports in a single file
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: EAL version.map annotation achieved with:
$ ./buildtools/map-list-symbol.sh lib/librte_eal/version.map |
while read file version sym; do
! git grep -qw $sym lib/librte_eal/*.def || continue;
sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" lib/librte_eal/*.map;
done--- MAINTAINERS | 1 - buildtools/map_to_win.py | 8 +- devtools/check-symbol-maps.sh | 20 -- lib/librte_eal/rte_eal_exports.def | 336 ----------------------------- lib/librte_eal/version.map | 136 ++++++------ 5 files changed, 69 insertions(+), 432 deletions(-) delete mode 100644 lib/librte_eal/rte_eal_exports.def
MAINTAINERS +0 -1
@@ -333,7 +333,6 @@ M: Narcisa Ana Maria Vasile <[email protected]> M: Dmitry Malloy <[email protected]> M: Pallavi Kadam <[email protected]> F: lib/librte_eal/windows/ -F: lib/librte_eal/rte_eal_exports.def F: buildtools/map_to_win.py F: doc/guides/windows_gsg/
buildtools/map_to_win.py +1 -7
@@ -7,7 +7,7 @@ def is_function_line(ln): - return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln + return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln and "# WINDOWS_NO_EXPORT" not in ln # MinGW keeps the original .map file but replaces per_lcore* to __emutls_v.per_lcore* def create_mingw_map_file(input_map, output_map):
@@ -24,12 +24,6 @@ def main(args): create_mingw_map_file(args[1], args[2]) return 0 -# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() - # generate def file from map file. # 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.
devtools/check-symbol-maps.sh +0 -20
@@ -35,24 +35,4 @@ if [ -n "$orphan_symbols" ] ; then ret=1 fi -find_orphan_windows_symbols () -{ - for def in $(find lib drivers -name '*_exports.def') ; do - if echo $def | grep -q 'common_mlx5' ; then - continue # mlx5 exports different symbols per OS - fi - map=$(dirname $def)/version.map - for sym in $(grep -v ^EXPORTS $def); do - grep -q $sym $map || echo $sym - done - done -} - -orphan_windows_symbols=$(find_orphan_windows_symbols) -if [ -n "$orphan_windows_symbols" ] ; then - echo "Found only in Windows export file:" - echo "$orphan_windows_symbols" | sed 's,^,\t,' - ret=1 -fi - exit $ret
lib/librte_eal/rte_eal_exports.def deleted +0 -336
336 lines not on this page · raw message
lib/librte_eal/version.map +68 -68
252 lines not on this page · raw message
Signature · 1 line
2.23.0
Quoted 14 lines · David Marchand
buildtools/map_to_win.py +1
-1@@ -7,7 +7,7 @@ def is_function_line(ln): - return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln + return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln and "# WINDOWS_NO_EXPORT" not in ln # MinGW keeps the original .map file but replaces per_lcore* to __emutls_v.per_lcore* def create_mingw_map_file(input_map, output_map):
buildtools/map_to_win.py def main(args): · line 32
Quoted 9 lines
buildtools/map_to_win.py +0
-6@@ -24,12 +24,6 @@ def main(args): create_mingw_map_file(args[1], args[2]) return 0 -# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() -
Forgot to clean associated python imports.
Will be fixed in a v2 if no objection is raised on the principle of the patch.
Quoted 3 lines
buildtools/map_to_win.py +0
-0# generate def file from map file. # 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.
Signature · 1 line
David Marchand
Quoted 4 lines · David Marchand
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: EAL version.map annotation achieved with:
Quoted 8 lines
$ ./buildtools/map-list-symbol.sh lib/librte_eal/version.map | while read file version sym; do ! git grep -qw $sym lib/librte_eal/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" lib/librte_eal/*.map; doneSigned-off-by David Marchand <[email protected]>---
+1 to the idea, this is great to see.
Quoted 8 lines
MAINTAINERS | 1 - buildtools/map_to_win.py | 8 +- devtools/check-symbol-maps.sh | 20 -- lib/librte_eal/rte_eal_exports.def | 336 ----------------------------- lib/librte_eal/version.map | 136 ++++++------ 5 files changed, 69 insertions(+), 432 deletions(-) delete mode 100644 lib/librte_eal/rte_eal_exports.def
<snip>
buildtools/map_to_win.py def main(args): · line 32
Quoted 6 lines
buildtools/map_to_win.py +0
-6-# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() -
If this is removed, then drivers/common/mlx5/version.map similarly needs to be annotated so that we can remove rte_common_mlx5_exports.def
Quoted 9 lines · Bruce Richardson
buildtools/map_to_win.py def main(args): · line 32
Quoted 6 lines
buildtools/map_to_win.py +0
-6-# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() -If this is removed, then
drivers/common/mlx5/version.mapsimilarly needs to be annotated so that we can remove rte_common_mlx5_exports.def
Erf, and I thought I had checked...
v2 incoming.
Signature · 1 line
David Marchand
Quoted 11 lines · Bruce Richardson
Quoted 10 lines · David Marchand
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: EAL version.map annotation achieved with:
$ ./buildtools/map-list-symbol.sh lib/librte_eal/version.map | while read file version sym; do ! git grep -qw $sym lib/librte_eal/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" lib/librte_eal/*.map; done
Quoted 3 lines
Quoted 2 lines
Signed-off-by David Marchand <[email protected]>---
+1 to the idea, this is great to see.
+1 agreed.
Quoted 20 lines
Quoted 9 lines
MAINTAINERS | 1 - buildtools/map_to_win.py | 8 +- devtools/check-symbol-maps.sh | 20 -- lib/librte_eal/rte_eal_exports.def | 336 ----------------------------- lib/librte_eal/version.map | 136 ++++++------ 5 files changed, 69 insertions(+), 432 deletions(-) delete mode 100644 lib/librte_eal/rte_eal_exports.def<snip>
buildtools/map_to_win.py def main(args): · line 32
Quoted 6 lines
buildtools/map_to_win.py +0
-6-# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() -If this is removed, then
drivers/common/mlx5/version.mapsimilarly needs to be annotated so that we can remove rte_common_mlx5_exports.def
PATCH v2 1/1 build: list symbols exports in a single file
In reply to David MarchandRather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do
./buildtools/map-list-symbol.sh $dir/*.map |
while read file version sym; do
! git grep -qw $sym $dir/*.def || continue;
sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map;
done;
done---
Changes since v1:
- removed unused python imports in map_to_win.py,
- fixed symbol map check to ignore comments,
- aligned common/mlx5 map with exports.def (all symbols exported by Windows are available in Linux too),
- annotated common/mlx5 map,
- updated SPDX check,
- updated ABI update tool,
--- MAINTAINERS | 1 - buildtools/map_to_win.py | 9 +- devtools/check-spdx-tag.sh | 2 +- devtools/check-symbol-maps.sh | 22 +- devtools/update_version_map_abi.py | 12 +- .../common/mlx5/rte_common_mlx5_exports.def | 75 ---- drivers/common/mlx5/version.map | 79 ++-- lib/librte_eal/rte_eal_exports.def | 336 ------------------ lib/librte_eal/version.map | 136 +++---- 9 files changed, 123 insertions(+), 549 deletions(-) delete mode 100644 drivers/common/mlx5/rte_common_mlx5_exports.def delete mode 100644 lib/librte_eal/rte_eal_exports.def
MAINTAINERS +0 -1
@@ -333,7 +333,6 @@ M: Narcisa Ana Maria Vasile <[email protected]> M: Dmitry Malloy <[email protected]> M: Pallavi Kadam <[email protected]> F: lib/librte_eal/windows/ -F: lib/librte_eal/rte_eal_exports.def F: buildtools/map_to_win.py F: doc/guides/windows_gsg/
buildtools/map_to_win.py +1 -8
@@ -3,11 +3,10 @@ # Copyright(c) 2019 Intel Corporation import sys -from os.path import dirname, basename, join, exists def is_function_line(ln): - return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln + return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln and "# WINDOWS_NO_EXPORT" not in ln # MinGW keeps the original .map file but replaces per_lcore* to __emutls_v.per_lcore* def create_mingw_map_file(input_map, output_map):
@@ -24,12 +23,6 @@ def main(args): create_mingw_map_file(args[1], args[2]) return 0 -# special case, allow override if an def file already exists alongside map file - override_file = join(dirname(args[1]), basename(args[2])) - if exists(override_file): - with open(override_file) as f_in: - functions = f_in.readlines() - # generate def file from map file. # 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.
devtools/check-spdx-tag.sh +1 -1
@@ -25,7 +25,7 @@ check_spdx() { ':^*/Kbuild' ':^*/README' \ ':^license/' ':^config/' ':^buildtools/' \ ':^*.cocci' ':^*.abignore' \ - ':^*.def' ':^*.map' ':^*.ini' ':^*.data' ':^*.cfg' ':^*.txt' \ + ':^*.map' ':^*.ini' ':^*.data' ':^*.cfg' ':^*.txt' \ ':^*.svg' ':^*.png'\ > $tmpfile
devtools/check-symbol-maps.sh +1 -21
@@ -12,7 +12,7 @@ ret=0 find_orphan_symbols () { for map in $(find lib drivers -name '*.map') ; do - for sym in $(sed -rn 's,^([^}]*_.*);,\1,p' $map) ; do + for sym in $(sed -rn 's,^([^}]*_.*);.*$,\1,p' $map) ; do if echo $sym | grep -q '^per_lcore_' ; then symsrc=${sym#per_lcore_} elif echo $sym | grep -q '^__rte_.*_trace_' ; then
@@ -35,24 +35,4 @@ if [ -n "$orphan_symbols" ] ; then ret=1 fi -find_orphan_windows_symbols () -{ - for def in $(find lib drivers -name '*_exports.def') ; do - if echo $def | grep -q 'common_mlx5' ; then - continue # mlx5 exports different symbols per OS - fi - map=$(dirname $def)/version.map - for sym in $(grep -v ^EXPORTS $def); do - grep -q $sym $map || echo $sym - done - done -} - -orphan_windows_symbols=$(find_orphan_windows_symbols) -if [ -n "$orphan_windows_symbols" ] ; then - echo "Found only in Windows export file:" - echo "$orphan_windows_symbols" | sed 's,^,\t,' - ret=1 -fi - exit $ret
devtools/update_version_map_abi.py +8 -4
@@ -15,13 +15,17 @@ def __parse_map_file(f_in): - # match function name, followed by semicolon, followed by EOL, optionally - # with whitespace in between each item + # match function name, followed by semicolon, followed by EOL or comments, + # optionally with whitespace in between each item func_line_regex = re.compile(r"\s*" + r"(?P<line>" r"(?P<func>[a-zA-Z_0-9]+)" r"\s*" r";" r"\s*" + r"(?P<comment>#.+)?" + r")" + r"\s*" r"$") # match section name, followed by opening bracked, followed by EOL, # optionally with whitespace in between each item
@@ -99,7 +103,7 @@ def __parse_map_file(f_in): # is this a function? match = func_line_regex.match(line) if match: - stable_lines.add(match.group("func")) + stable_lines.add(match.group("line")) return has_stable, stable_lines, experimental_lines, internal_lines
@@ -116,7 +120,7 @@ def __generate_stable_abi(f_out, abi_major, lines): # print all stable lines, alphabetically sorted for line in sorted(lines): - print("\t{};".format(line), file=f_out) + print("\t{}".format(line), file=f_out) # another blank line print(file=f_out)
drivers/common/mlx5/rte_common_mlx5_exports.def deleted +0 -75
75 lines not on this page · raw message
drivers/common/mlx5/version.map +44 -35
123 lines not on this page · raw message
lib/librte_eal/rte_eal_exports.def deleted +0 -336
336 lines not on this page · raw message
lib/librte_eal/version.map +68 -68
252 lines not on this page · raw message
Signature · 1 line
2.23.0
About the title, it is not a single file but one file per lib/driver. I think it would better convey the idea by saying "remove .def files".
06/04/2021 19:59, David Marchand:
Quoted 11 lines
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do ./buildtools/map-list-symbol.sh $dir/*.map | while read file version sym; do ! git grep -qw $sym $dir/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map; done; done
This patch keeps the exact same behaviour, right?
There are a lot of symbols in EAL and mlx5 which should be exported for Windows too, but it is open for future fixes, right?
Quoted 3 lines · Thomas Monjalon
About the title, it is not a single file but one file per lib/driver. I think it would better convey the idea by saying "remove .def files".
Ok.
Quoted 14 lines
06/04/2021 19:59, David Marchand:
Quoted 11 lines
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do ./buildtools/map-list-symbol.sh $dir/*.map | while read file version sym; do ! git grep -qw $sym $dir/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map; done; done
Quoted 1 line
This patch keeps the exact same behaviour, right?
I checked by sorting/diff'ing previously committed .def files for EAL and common/mlx5 with the newly generated ones.
No difference, once aligning the mlx5 version.map.
There is one change in behavior.
I thought as exports.def being a subset of the map files, and this patch enforces it.
It seems there were some tries at going the opposite way, looking at the comment in check-symbol-maps.sh.
But looking at the current common/mlx5 state, I don't see this as a requirement (Linux and Windows share the same interface).
Quoted 2 lines
There are a lot of symbols in EAL and mlx5 which should be exported for Windows too, but it is open for future fixes, right?
Not sure I get this question.
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did not check yet). This current patch does not address such issues and we need fixes afterwards if this is what you mean.
Signature · 1 line
David Marchand
06/04/2021 22:09, David Marchand:
Quoted 39 lines · Thomas Monjalon
Quoted 3 lines
About the title, it is not a single file but one file per lib/driver. I think it would better convey the idea by saying "remove .def files".
Ok.
Quoted 14 lines
06/04/2021 19:59, David Marchand:
Quoted 11 lines
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do ./buildtools/map-list-symbol.sh $dir/*.map | while read file version sym; do ! git grep -qw $sym $dir/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map; done; doneQuoted 1 line
This patch keeps the exact same behaviour, right?
I checked by sorting/diff'ing previously committed .def files for EAL and common/mlx5 with the newly generated ones.
No difference, once aligning the mlx5 version.map.There is one change in behavior.
I thought as exports.def being a subset of the map files, and this patch enforces it.
It seems there were some tries at going the opposite way, looking at the comment incheck-symbol-maps.sh.
But looking at the current common/mlx5 state, I don't see this as a requirement (Linux and Windows share the same interface).Quoted 2 lines
There are a lot of symbols in EAL and mlx5 which should be exported for Windows too, but it is open for future fixes, right?
Quoted 7 lines
Not sure I get this question.
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did not check yet). This current patch does not address such issues and we need fixes afterwards if this is what you mean.
Yes this is what I mean.
I wanted to make clear to people in Cc list that some fixes are required as follow-up: some symbols in EAL and mlx5 are missing for Windows.
Quoted 5 lines · David Marchand
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did not check yet). This current patch does not address such issues and we need fixes afterwards if this is what you mean.
I did a first pass.
I see symbols from rte_random.c and rte_version.c not exported, while those files are compiled for Windows.
Could you explain why these are not exported?
Signature · 1 line
David Marchand
2021-04-07 10:16 (UTC+0200), David Marchand:
Quoted 8 lines
Quoted 5 lines · David Marchand
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did not check yet). This current patch does not address such issues and we need fixes afterwards if this is what you mean.
Quoted 5 lines
I did a first pass.
I see symbols from
rte_random.candrte_version.cnot exported, while those files are compiled for Windows.
Could you explain why these are not exported?
These are just forgotten, can be safely exported.
07/04/2021 10:53, Dmitry Kozlyuk:
Quoted 9 lines
2021-04-07 10:16 (UTC+0200), David Marchand:
Quoted 8 lines
Quoted 5 lines · David Marchand
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did not check yet). This current patch does not address such issues and we need fixes afterwards if this is what you mean.
Quoted 7 lines
Quoted 5 lines
I did a first pass.
I see symbols from
rte_random.candrte_version.cnot exported, while those files are compiled for Windows.
Could you explain why these are not exported?These are just forgotten, can be safely exported.
I prefer we don't mix fixes with this format rework. Please send fixes on top of this patch. Cc'ed Tal & Ophir for mlx5.
Tal Shnaiderman
Tested-byQuoted 22 lines
Subject: Re: [PATCH v2] build: list symbols exports in a single file
External email: Use caution opening links or attachments
07/04/2021 10:53, Dmitry Kozlyuk:
Quoted 6 lines
2021-04-07 10:16 (UTC+0200), David Marchand:
Quoted 5 lines
Quoted 3 lines · David Marchand
We have exports missing in EAL for some series posted on the ml waiting for merges.
I suspect some recent merged changes have issues too (but did notcheck yet).
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
This current patch does not address such issues and we need fixes afterwards if this is what you mean.
I did a first pass.
I see symbols from
rte_random.candrte_version.cnot exported, while those files are compiled for Windows.
Could you explain why these are not exported?
Quoted 6 lines
Quoted 1 line
These are just forgotten, can be safely exported.
I prefer we don't mix fixes with this format rework. Please send fixes on top of this patch. Cc'ed Tal & Ophir for mlx5.
Thanks David for resolving the duplication.
For mlx5, the functions mlx5_devx_cmd_*, mlx5_mp_* and mlx5_memory_stat_dump are compiled but currently not used.
I can send a separate patch exporting all of them to be more aligned with Linux, or we can export them whenever we'll actually start using them.
Regardless:
06/04/2021 19:59, David Marchand:
Quoted 12 lines
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do ./buildtools/map-list-symbol.sh $dir/*.map | while read file version sym; do ! git grep -qw $sym $dir/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map; done; done
Quoted 1 line
Signed-off-by David Marchand <[email protected]>
That's a nice improvement.
Fixes to remove WINDOWS_NO_EXPORT annotations would be great to see from the original authors of the concerned symbols.
I think we should merge this patch quickly to avoid having more discrepancies with the coming EAL patches.
Quoted 13 lines · David Marchand
Rather than have two files that keeps getting out of sync, let's annotate the version.map to generate the Windows export file.
Note: Existing version.map annotation achieved with:
$ for dir in lib/librte_eal drivers/common/mlx5; do ./buildtools/map-list-symbol.sh $dir/*.map | while read file version sym; do ! git grep -qw $sym $dir/*.def || continue; sed -i -e "s/$sym;/$sym; # WINDOWS_NO_EXPORT/" $dir/*.map; done; done
Quoted 1 line
Signed-off-by David Marchand <[email protected]>
Updated commitlog and sorted common/mlx5 updates (from offlist comments with Thomas).
Applied, thanks.
Signature · 1 line
David Marchand