build: add internal tag check
authorHaiyue Wang <haiyue.wang@intel.com>
Sat, 25 Apr 2020 10:56:17 +0000 (18:56 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Sat, 25 Apr 2020 15:01:01 +0000 (17:01 +0200)
Add checks during build to ensure that all symbols in the INTERNAL
version map section have __internal tags on their definitions, and
enable the warnings needed to announce their use.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
MAINTAINERS
buildtools/check-experimental-syms.sh [deleted file]
buildtools/check-symbols.sh [new file with mode: 0755]
buildtools/meson.build
drivers/meson.build
lib/meson.build
mk/internal/rte.compile-pre.mk

index 73506cf..d31a809 100644 (file)
@@ -153,7 +153,7 @@ F: devtools/libabigail.abignore
 F: devtools/update-abi.sh
 F: devtools/update_version_map_abi.py
 F: devtools/validate-abi.sh
-F: buildtools/check-experimental-syms.sh
+F: buildtools/check-symbols.sh
 F: buildtools/map-list-symbol.sh
 
 Driver information
diff --git a/buildtools/check-experimental-syms.sh b/buildtools/check-experimental-syms.sh
deleted file mode 100755 (executable)
index f3603e5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh
-
-# SPDX-License-Identifier: BSD-3-Clause
-
-MAPFILE=$1
-OBJFILE=$2
-
-LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
-
-# added check for "make -C test/" usage
-if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
-then
-       exit 0
-fi
-
-if [ -d $MAPFILE ]
-then
-       exit 0
-fi
-
-DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
-trap 'rm -f "$DUMPFILE"' EXIT
-objdump -t $OBJFILE >$DUMPFILE
-
-ret=0
-for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
-do
-       if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
-               ! grep -q "\.text\.experimental.*[[:space:]]$SYM$" $DUMPFILE
-       then
-               cat >&2 <<- END_OF_MESSAGE
-               $SYM is not flagged as experimental
-               but is listed in version map
-               Please add __rte_experimental to the definition of $SYM
-               END_OF_MESSAGE
-               ret=1
-       fi
-done
-
-# Filter out symbols suffixed with a . for icc
-for SYM in `awk '{
-       if ($2 != "l" && $4 == ".text.experimental" && !($NF ~ /\.$/)) {
-               print $NF
-       }
-}' $DUMPFILE`
-do
-       $LIST_SYMBOL -S EXPERIMENTAL -s $SYM -q $MAPFILE || {
-               cat >&2 <<- END_OF_MESSAGE
-               $SYM is flagged as experimental
-               but is not listed in version map
-               Please add $SYM to the version map
-               END_OF_MESSAGE
-               ret=1
-       }
-done
-
-exit $ret
diff --git a/buildtools/check-symbols.sh b/buildtools/check-symbols.sh
new file mode 100755 (executable)
index 0000000..3df57c3
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+# SPDX-License-Identifier: BSD-3-Clause
+
+MAPFILE=$1
+OBJFILE=$2
+
+LIST_SYMBOL=$(dirname $(readlink -f $0))/map-list-symbol.sh
+
+# added check for "make -C test/" usage
+if [ ! -e $MAPFILE ] || [ ! -f $OBJFILE ]
+then
+       exit 0
+fi
+
+if [ -d $MAPFILE ]
+then
+       exit 0
+fi
+
+DUMPFILE=$(mktemp -t dpdk.${0##*/}.XXX.objdump)
+trap 'rm -f "$DUMPFILE"' EXIT
+objdump -t $OBJFILE >$DUMPFILE
+
+ret=0
+for SYM in `$LIST_SYMBOL -S EXPERIMENTAL $MAPFILE |cut -d ' ' -f 3`
+do
+       if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
+               ! grep -q "\.text\.experimental.*[[:space:]]$SYM$" $DUMPFILE
+       then
+               cat >&2 <<- END_OF_MESSAGE
+               $SYM is not flagged as experimental
+               but is listed in version map
+               Please add __rte_experimental to the definition of $SYM
+               END_OF_MESSAGE
+               ret=1
+       fi
+done
+
+# Filter out symbols suffixed with a . for icc
+for SYM in `awk '{
+       if ($2 != "l" && $4 == ".text.experimental" && !($NF ~ /\.$/)) {
+               print $NF
+       }
+}' $DUMPFILE`
+do
+       $LIST_SYMBOL -S EXPERIMENTAL -s $SYM -q $MAPFILE || {
+               cat >&2 <<- END_OF_MESSAGE
+               $SYM is flagged as experimental
+               but is not listed in version map
+               Please add $SYM to the version map
+               END_OF_MESSAGE
+               ret=1
+       }
+done
+
+for SYM in `$LIST_SYMBOL -S INTERNAL $MAPFILE |cut -d ' ' -f 3`
+do
+       if grep -q "\.text.*[[:space:]]$SYM$" $DUMPFILE &&
+               ! grep -q "\.text\.internal.*[[:space:]]$SYM$" $DUMPFILE
+       then
+               cat >&2 <<- END_OF_MESSAGE
+               $SYM is not flagged as internal
+               but is listed in version map
+               Please add __rte_internal to the definition of $SYM
+               END_OF_MESSAGE
+               ret=1
+       fi
+done
+
+# Filter out symbols suffixed with a . for icc
+for SYM in `awk '{
+       if ($2 != "l" && $4 == ".text.internal" && !($NF ~ /\.$/)) {
+               print $NF
+       }
+}' $DUMPFILE`
+do
+       $LIST_SYMBOL -S INTERNAL -s $SYM -q $MAPFILE || {
+               cat >&2 <<- END_OF_MESSAGE
+               $SYM is flagged as internal
+               but is not listed in version map
+               Please add $SYM to the version map
+               END_OF_MESSAGE
+               ret=1
+       }
+done
+
+exit $ret
index 9812917..d5f8291 100644 (file)
@@ -6,7 +6,7 @@ subdir('pmdinfogen')
 pkgconf = find_program('pkg-config', 'pkgconf', required: false)
 pmdinfo = find_program('gen-pmdinfo-cfile.sh')
 list_dir_globs = find_program('list-dir-globs.py')
-check_experimental_syms = find_program('check-experimental-syms.sh')
+check_symbols = find_program('check-symbols.sh')
 ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
 
 # set up map-to-def script using python, either built-in or external
@@ -20,4 +20,4 @@ map_to_def_cmd = py3 + files('map_to_def.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
 
 # stable ABI always starts with "DPDK_"
-is_experimental_cmd = [find_program('grep', 'findstr'), '^DPDK_']
+is_stable_cmd = [find_program('grep', 'findstr'), '^DPDK_']
index f3dd23d..dc293b2 100644 (file)
@@ -131,15 +131,15 @@ foreach class:dpdk_driver_classes
                                        meson.current_source_dir(),
                                        drv_path, lib_name)
 
-                       is_experimental = run_command(is_experimental_cmd,
-                               files(version_map)).returncode()
+                       is_stable = run_command(is_stable_cmd,
+                               files(version_map)).returncode() == 0
 
-                       if is_experimental != 0
-                               lib_version = experimental_abi_version
-                               so_version = experimental_so_version
-                       else
+                       if is_stable
                                lib_version = abi_version
                                so_version = stable_so_version
+                       else
+                               lib_version = experimental_abi_version
+                               so_version = experimental_so_version
                        endif
 
                        # now build the static driver
@@ -168,14 +168,14 @@ foreach class:dpdk_driver_classes
                        else
                                lk_args = ['-Wl,--version-script=' + version_map]
                                # on unix systems check the output of the
-                               # experimental syms script, using it as a
+                               # check-symbols.sh script, using it as a
                                # dependency of the .so build
-                               lk_deps += custom_target(lib_name + '.exp_chk',
-                                       command: [check_experimental_syms,
+                               lk_deps += custom_target(lib_name + '.sym_chk',
+                                       command: [check_symbols,
                                                version_map, '@INPUT@'],
                                        capture: true,
                                        input: static_lib,
-                                       output: lib_name + '.exp_chk')
+                                       output: lib_name + '.sym_chk')
                        endif
 
                        shared_lib = shared_library(lib_name,
index 8697941..07a65a6 100644 (file)
@@ -109,15 +109,15 @@ foreach l:libraries
                        version_map = '@0@/@1@/rte_@2@_version.map'.format(
                                        meson.current_source_dir(), dir_name, name)
 
-                       is_experimental = run_command(is_experimental_cmd,
-                                       files(version_map)).returncode()
+                       is_stable = run_command(is_stable_cmd,
+                                       files(version_map)).returncode() == 0
 
-                       if is_experimental != 0
-                               lib_version = experimental_abi_version
-                               so_version = experimental_so_version
-                       else
+                       if is_stable
                                lib_version = abi_version
                                so_version = stable_so_version
+                       else
+                               lib_version = experimental_abi_version
+                               so_version = experimental_so_version
                        endif
 
                        # first build static lib
@@ -160,14 +160,14 @@ foreach l:libraries
                        lk_deps = [version_map, def_file]
                        if not is_windows
                                # on unix systems check the output of the
-                               # experimental syms script, using it as a
+                               # check-symbols.sh script, using it as a
                                # dependency of the .so build
-                               lk_deps += custom_target(name + '.exp_chk',
-                                       command: [check_experimental_syms,
+                               lk_deps += custom_target(name + '.sym_chk',
+                                       command: [check_symbols,
                                                version_map, '@INPUT@'],
                                        capture: true,
                                        input: static_lib,
-                                       output: name + '.exp_chk')
+                                       output: name + '.sym_chk')
                        endif
 
                        shared_lib = shared_library(libname,
index 82fe098..df05b55 100644 (file)
@@ -56,8 +56,8 @@ C_TO_O = $(CC) -Wp,-MD,$(call obj2dep,$(@)).tmp $(CPPFLAGS) $(CFLAGS) \
 C_TO_O_STR = $(subst ','\'',$(C_TO_O)) #'# fix syntax highlight
 C_TO_O_DISP = $(if $(V),"$(C_TO_O_STR)","  CC $(@)")
 endif
-EXPERIMENTAL_CHECK = $(RTE_SDK)/buildtools/check-experimental-syms.sh
-CHECK_EXPERIMENTAL = $(EXPERIMENTAL_CHECK) $(SRCDIR)/$(EXPORT_MAP) $@
+CHECK_SYMBOLS_SCRIPT = $(RTE_SDK)/buildtools/check-symbols.sh
+CHECK_SYMBOLS = $(CHECK_SYMBOLS_SCRIPT) $(SRCDIR)/$(EXPORT_MAP) $@
 
 PMDINFO_GEN = $(RTE_SDK_BIN)/app/dpdk-pmdinfogen $@ $@.pmd.c
 PMDINFO_CC = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@.pmd.o $@.pmd.c
@@ -75,7 +75,7 @@ C_TO_O_DO = @set -e; \
        echo $(C_TO_O_DISP); \
        $(C_TO_O) && \
        $(PMDINFO_TO_O) && \
-       $(CHECK_EXPERIMENTAL) && \
+       $(CHECK_SYMBOLS) && \
        echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \
        sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \
        rm -f $(call obj2dep,$(@)).tmp