Skip to contentSkip to conversation

devtools: catch symbol duplicates in version map

PATCH Superseded David Marchand 4 participants 16 messages Feb 25, 2021 – May 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: catch symbol duplicates in version map

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

---
 devtools/check-symbol-maps.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
devtools/check-symbol-maps.sh +15 -0
index c3cbcaf720..a430de7f64 100755
@@ -35,6 +35,21 @@ if [ -n "$orphan_symbols" ] ; then
     ret=1
 fi
 
+find_duplicate_symbols ()
+{
+    for map in $(find lib drivers -name '*.map') ; do
+        ! buildtools/map-list-symbol.sh $map | \
+		sort | uniq -c | grep -v " 1 $map"
+    done
+}
+
+duplicate_symbols=$(find_duplicate_symbols)
+if [ -n "$duplicate_symbols" ] ; then
+    echo "Found duplicates in symbol map file:"
+    echo "$duplicate_symbols"
+    ret=1
+fi
+
 find_orphan_windows_symbols ()
 {
     for def in $(find lib drivers -name '*_exports.def') ; do
Signature · 1 line
2.23.0
#1 lore raw

25/02/2021 12:14, David Marchand:

Quoted 7 lines

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

In general I am against adding developer tools in the build process, because it could cause more issues for normal users.

#2 lore raw
Quoted 12 lines · Thomas Monjalon

25/02/2021 12:14, David Marchand:

Quoted 7 lines

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

In general I am against adding developer tools in the build process, because it could cause more issues for normal users.

Is this really likely to cause issues for normal users? If we add this to the build process any issues will surely be caught be developers before merge.

#3 lore raw

25/02/2021 12:57, Bruce Richardson:

Quoted 10 lines · Thomas Monjalon
Quoted 9 lines

25/02/2021 12:14, David Marchand:

Quoted 7 lines

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

Quoted 4 lines
Quoted 3 lines

In general I am against adding developer tools in the build process, because it could cause more issues for normal users.

Is this really likely to cause issues for normal users?

Yes because some users will have a different shell, or other weird setup we don't think about yet.

Quoted 3 lines

If we add this to
the build process any issues will surely be caught be developers before merge.

If we want the checks to be more popular, we should write a script to help running the right script at the right time,
and ideally help in the contribution process.

#4 lore raw
Quoted 11 lines · Thomas Monjalon

25/02/2021 12:57, Bruce Richardson:

Quoted 10 lines · Thomas Monjalon
Quoted 9 lines

25/02/2021 12:14, David Marchand:

Quoted 7 lines

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

In general I am against adding developer tools in the build process, because it could cause more issues for normal users.

Is this really likely to cause issues for normal users?

Yes because some users will have a different shell, or other weird setup we don't think about yet.

I think it unlikely, but ok.

Now that meson (from version 0.53 onwards) has a "filesystem" module, with an "exists" function, we can perhaps look to introduce a "developer mode" build again, based off the presence of the .git folder. Alternatively, we could make "developer mode" a regular meson option rather than trying to be too smart about it. [Or combine both and have developer mode option with "enabled"/"disabled"/"auto-detect" values]

/Bruce

#5 lore raw

25/02/2021 13:05, Bruce Richardson:

Quoted 15 lines · Thomas Monjalon
Quoted 14 lines

25/02/2021 12:57, Bruce Richardson:

Quoted 13 lines · Thomas Monjalon
Quoted 12 lines

25/02/2021 12:14, David Marchand:

Quoted 7 lines

Add a check on versioned symbol duplicates in map files.

---
This check could be added to buildtools/check-symbols.sh so that regular developers catch the issue when building their changes... Opinions?

In general I am against adding developer tools in the build process, because it could cause more issues for normal users.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Is this really likely to cause issues for normal users?

Yes because some users will have a different shell, or other weird setup we don't think about yet.

I think it unlikely, but ok.

You would be surprised.
I'm going to send a fix for running buildtools/check-symbols.sh on busybox.

Quoted 6 lines

Now that meson (from version 0.53 onwards) has a "filesystem" module, with an "exists" function, we can perhaps look to introduce a "developer mode" build again, based off the presence of the .git folder. Alternatively, we could make "developer mode" a regular meson option rather than trying to be too smart about it. [Or combine both and have developer mode option with "enabled"/"disabled"/"auto-detect" values]

Yes, a developer mode is a good idea.

#6 lore raw

PATCH v2 1/2 devtools: catch symbol duplicates in version map

In reply to David Marchand

Add a check on versioned symbol duplicates in map files.

---
Changes since v1:
- rebased,

---
 devtools/check-symbol-maps.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
devtools/check-symbol-maps.sh +15 -0
index f06353fc75..f2c7d29663 100755
@@ -35,4 +35,19 @@ if [ -n "$orphan_symbols" ] ; then
     ret=1
 fi
 
+find_duplicate_symbols ()
+{
+    for map in $(find lib drivers -name '*.map') ; do
+        buildtools/map-list-symbol.sh $map | \
+            sort | uniq -c | grep -v " 1 $map" || true
+    done
+}
+
+duplicate_symbols=$(find_duplicate_symbols)
+if [ -n "$duplicate_symbols" ] ; then
+    echo "Found duplicates in symbol map file:"
+    echo "$duplicate_symbols"
+    ret=1
+fi
+
 exit $ret
Signature · 1 line
2.23.0
#7 lore raw

PATCH v2 2/2 buildtools: check symbol maps in developer mode

Hook check-symbol-maps.sh in the symbol check when in developer mode to help developers catch issues before submitting their changes.

---
Changes since v1:
- now that we have the developer mode, added this check in the build process,

---
 buildtools/check-symbols.sh   |  9 ++++++++-
 devtools/check-symbol-maps.sh | 12 ++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
buildtools/check-symbols.sh +8 -1
index 83b3a0182f..e458c0af72 100755
@@ -5,7 +5,9 @@
 MAPFILE=$1
 OBJFILE=$2
 
-LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
+ROOTDIR=$(readlink -f $(dirname $(readlink -f $0))/..)
+LIST_SYMBOL=$ROOTDIR/buildtools/map-list-symbol.sh
+CHECK_SYMBOL_MAPS=$ROOTDIR/devtools/check-symbol-maps.sh
 
 # added check for "make -C test/" usage
 if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
@@ -23,6 +25,11 @@ trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
 ret=0
+
+if ! $CHECK_SYMBOL_MAPS $MAPFILE; then
+	ret=1
+fi
+
 for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
 do
 	if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
devtools/check-symbol-maps.sh +8 -4
index f2c7d29663..c52e28bd69 100755
@@ -7,11 +7,15 @@ cd $(dirname $0)/..
 # speed up by ignoring Unicode details
 export LC_ALL=C
 
+if [ $# = 0 ] ; then
+    set -- $(find lib drivers -name '*.map')
+fi
+
 ret=0
 
 find_orphan_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do
         for sym in $(sed -rn 's,^([^}]*_.*);.*$,\1,p' $map) ; do
             if echo $sym | grep -q '^per_lcore_' ; then
                 symsrc=${sym#per_lcore_}
@@ -28,7 +32,7 @@ find_orphan_symbols ()
     done
 }
 
-orphan_symbols=$(find_orphan_symbols)
+orphan_symbols=$(find_orphan_symbols $@)
 if [ -n "$orphan_symbols" ] ; then
     echo "Found only in symbol map file:"
     echo "$orphan_symbols" | sed 's,^,\t,'
@@ -37,13 +41,13 @@ fi
 
 find_duplicate_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do
         buildtools/map-list-symbol.sh $map | \
             sort | uniq -c | grep -v " 1 $map" || true
     done
 }
 
-duplicate_symbols=$(find_duplicate_symbols)
+duplicate_symbols=$(find_duplicate_symbols $@)
 if [ -n "$duplicate_symbols" ] ; then
     echo "Found duplicates in symbol map file:"
     echo "$duplicate_symbols"
Signature · 1 line
2.23.0
Reviewed-by on v2 2/2
#8 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] buildtools: check symbol maps in developer mode

Quoted 78 lines · David Marchand

Hook check-symbol-maps.sh in the symbol check when in developer mode to help developers catch issues before submitting their changes.

---
Changes since v1:
- now that we have the developer mode, added this check in the build process,

---
 buildtools/check-symbols.sh   |  9 ++++++++-
 devtools/check-symbol-maps.sh | 12 ++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
buildtools/check-symbols.sh +8 -1
index 83b3a0182f..e458c0af72 100755
@@ -5,7 +5,9 @@
 MAPFILE=$1
 OBJFILE=$2
 
-LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
+ROOTDIR=$(readlink -f $(dirname $(readlink -f $0))/..)
+LIST_SYMBOL=$ROOTDIR/buildtools/map-list-symbol.sh
+CHECK_SYMBOL_MAPS=$ROOTDIR/devtools/check-symbol-maps.sh
 
 # added check for "make -C test/" usage
 if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
@@ -23,6 +25,11 @@ trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
 ret=0
+
+if ! $CHECK_SYMBOL_MAPS $MAPFILE; then
+	ret=1
+fi
+
 for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
 do
 	if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
devtools/check-symbol-maps.sh +7 -3
index f2c7d29663..c52e28bd69 100755
@@ -7,11 +7,15 @@ cd $(dirname $0)/..
 # speed up by ignoring Unicode details
 export LC_ALL=C
 
+if [ $# = 0 ] ; then
+    set -- $(find lib drivers -name '*.map')
+fi
+
 ret=0
 
 find_orphan_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do
         for sym in $(sed -rn 's,^([^}]*_.*);.*$,\1,p' $map) ; do
             if echo $sym | grep -q '^per_lcore_' ; then
                 symsrc=${sym#per_lcore_}
@@ -28,7 +32,7 @@ find_orphan_symbols ()
     done
 }
 
-orphan_symbols=$(find_orphan_symbols)
+orphan_symbols=$(find_orphan_symbols $@)
 if [ -n "$orphan_symbols" ] ; then
     echo "Found only in symbol map file:"
     echo "$orphan_symbols" | sed 's,^,\t,'
@@ -37,13 +41,13 @@ fi
 
 find_duplicate_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do

devtools/check-symbol-maps.sh fi · line 53

Quoted 10 lines
devtools/check-symbol-maps.sh +1 -1
         buildtools/map-list-symbol.sh $map | \
             sort | uniq -c | grep -v " 1 $map" || true
     done
 }
 
-duplicate_symbols=$(find_duplicate_symbols)
+duplicate_symbols=$(find_duplicate_symbols $@)
 if [ -n "$duplicate_symbols" ] ; then
     echo "Found duplicates in symbol map file:"
     echo "$duplicate_symbols"

+1

#10 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] buildtools: check symbol maps in developer mode

12/05/2021 22:24, Thomas Monjalon:

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

Hook check-symbol-maps.sh in the symbol check when in developer mode to help developers catch issues before submitting their changes.

+1

Series applied, thanks

Oops, sorry no it cannot be merged as-is because of an incompatibility with Busybox grep: unrecognized option: exclude=version.map

I think it is because of the old function find_orphan_symbols() using the option --exclude.

#11 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] buildtools: check symbol maps in developer mode

Quoted 10 lines · Thomas Monjalon

12/05/2021 22:24, Thomas Monjalon:

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Hook check-symbol-maps.sh in the symbol check when in developer mode to help developers catch issues before submitting their changes.

+1

Quoted 7 lines
Quoted 1 line

Series applied, thanks

Oops, sorry no it cannot be merged as-is because of an incompatibility with Busybox grep: unrecognized option: exclude=version.map

I think it is because of the old function find_orphan_symbols() using the option --exclude.

This could be fixed with:
- if ! grep -q -r --exclude=$(basename $map) \
- -w $symsrc $(dirname $map) ; then
+ if [ -z "$(grep -rlw $symsrc $(dirname $map) |grep -v
$map)" ] ; then

Do you want a v3 with this change?

Signature · 1 line
David Marchand
#12 lore raw

PATCH v3 1/3 devtools: fix orphan symbols check with busybox

In reply to David Marchand

Avoid relying on GNU grep --exclude option.

Fixes f8ad40dc998c ("devtools: check orphan symbols in map files")
---
 devtools/check-symbol-maps.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
devtools/check-symbol-maps.sh +1 -2
index f06353fc75..08451ef5aa 100755
@@ -20,8 +20,7 @@ find_orphan_symbols ()
             else
                 symsrc=$sym
             fi
-            if ! grep -q -r --exclude=$(basename $map) \
-                    -w $symsrc $(dirname $map) ; then
+            if [ -z "$(grep -rlw $symsrc $(dirname $map) |grep -v $map)" ] ; then
                 echo "$map: $sym"
             fi
         done
Signature · 1 line
2.23.0
#13 lore raw

PATCH v3 2/3 devtools: catch symbol duplicates in version map

Add a check on versioned symbol duplicates in map files.

---
Changes since v1:
- rebased,

---
 devtools/check-symbol-maps.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
devtools/check-symbol-maps.sh +15 -0
index 08451ef5aa..8a976dc97f 100755
@@ -34,4 +34,19 @@ if [ -n "$orphan_symbols" ] ; then
     ret=1
 fi
 
+find_duplicate_symbols ()
+{
+    for map in $(find lib drivers -name '*.map') ; do
+        buildtools/map-list-symbol.sh $map | \
+            sort | uniq -c | grep -v " 1 $map" || true
+    done
+}
+
+duplicate_symbols=$(find_duplicate_symbols)
+if [ -n "$duplicate_symbols" ] ; then
+    echo "Found duplicates in symbol map file:"
+    echo "$duplicate_symbols"
+    ret=1
+fi
+
 exit $ret
Signature · 1 line
2.23.0
#14 lore raw

PATCH v3 3/3 build: check symbol maps in developer mode

In reply to David Marchand

Hook check-symbol-maps.sh in the symbol check when in developer mode to help developers catch issues before submitting their changes.

---
Changes since v1:
- now that we have the developer mode, added this check in the build process,

---
 buildtools/check-symbols.sh   |  9 ++++++++-
 devtools/check-symbol-maps.sh | 12 ++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
buildtools/check-symbols.sh +8 -1
index 83b3a0182f..e458c0af72 100755
@@ -5,7 +5,9 @@
 MAPFILE=$1
 OBJFILE=$2
 
-LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
+ROOTDIR=$(readlink -f $(dirname $(readlink -f $0))/..)
+LIST_SYMBOL=$ROOTDIR/buildtools/map-list-symbol.sh
+CHECK_SYMBOL_MAPS=$ROOTDIR/devtools/check-symbol-maps.sh
 
 # added check for "make -C test/" usage
 if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
@@ -23,6 +25,11 @@ trap 'rm -f "$DUMPFILE"' EXIT
 objdump -t $OBJFILE >$DUMPFILE
 
 ret=0
+
+if ! $CHECK_SYMBOL_MAPS $MAPFILE; then
+	ret=1
+fi
+
 for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
 do
 	if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
devtools/check-symbol-maps.sh +8 -4
index 8a976dc97f..23b0a05f78 100755
@@ -7,11 +7,15 @@ cd $(dirname $0)/..
 # speed up by ignoring Unicode details
 export LC_ALL=C
 
+if [ $# = 0 ] ; then
+    set -- $(find lib drivers -name '*.map')
+fi
+
 ret=0
 
 find_orphan_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do
         for sym in $(sed -rn 's,^([^}]*_.*);.*$,\1,p' $map) ; do
             if echo $sym | grep -q '^per_lcore_' ; then
                 symsrc=${sym#per_lcore_}
@@ -27,7 +31,7 @@ find_orphan_symbols ()
     done
 }
 
-orphan_symbols=$(find_orphan_symbols)
+orphan_symbols=$(find_orphan_symbols $@)
 if [ -n "$orphan_symbols" ] ; then
     echo "Found only in symbol map file:"
     echo "$orphan_symbols" | sed 's,^,\t,'
@@ -36,13 +40,13 @@ fi
 
 find_duplicate_symbols ()
 {
-    for map in $(find lib drivers -name '*.map') ; do
+    for map in $@ ; do
         buildtools/map-list-symbol.sh $map | \
             sort | uniq -c | grep -v " 1 $map" || true
     done
 }
 
-duplicate_symbols=$(find_duplicate_symbols)
+duplicate_symbols=$(find_duplicate_symbols $@)
 if [ -n "$duplicate_symbols" ] ; then
     echo "Found duplicates in symbol map file:"
     echo "$duplicate_symbols"
Signature · 1 line
2.23.0