From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 99690A04FA; Sun, 2 Feb 2020 22:09:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 449DE1BFE3; Sun, 2 Feb 2020 22:09:14 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 28EFA1BF7B for ; Sun, 2 Feb 2020 22:09:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580677752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=01SVZcXmINevzvzyV4TWF/UasMQPopBC6K5terdK1ho=; b=E7X/+TmMu4BfL5ef5oABowsyJ2H6f6cDUW+hoQKO1DewDi8ic81LF59tF/k3IoPtNt79hz h8cwr/kP+n2JBBisnL7S93qjcjUtyqFvUj4etU8jupHKDuQcZVCBBnFv9M+feEpmlcyr6T WZwufC+C1P8POM0HUwSjOyS2NI7Wx+8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-dL7CuTYKMP2UwQ78m-gVUQ-1; Sun, 02 Feb 2020 16:09:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 461528017DF; Sun, 2 Feb 2020 21:09:01 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FEC98E9E5; Sun, 2 Feb 2020 21:08:58 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, aconole@redhat.com, nhorman@tuxdriver.com, akhil.goyal@nxp.com, anoobj@marvell.com, bluca@debian.org, fiona.trahe@intel.com, ferruh.yigit@intel.com, Michael Santana , John McNamara , Marko Kovacevic Date: Sun, 2 Feb 2020 22:08:34 +0100 Message-Id: <20200202210835.29791-4-david.marchand@redhat.com> In-Reply-To: <20200202210835.29791-1-david.marchand@redhat.com> References: <20191220152058.10739-1-david.marchand@redhat.com> <20200202210835.29791-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: dL7CuTYKMP2UwQ78m-gVUQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v4 3/3] add ABI checks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For normal developers, those checks are disabled. Enabling them requires a configuration that will trigger the ABI dumps generation as part of the existing devtools/test-build.sh and devtools/test-meson-builds.sh scripts. Those checks are enabled in the CI for the default meson options on x86 and aarch64 so that proposed patches are validated via our CI robot. A cache of the ABI is stored in travis jobs to avoid rebuilding too often. Checks can be informational only, by setting ABI_CHECKS_WARN_ONLY when breaking the ABI in a future release. Explicit suppression rules have been added on internal structures exposed to crypto drivers as the current ABI policy does not apply to them. This could be improved in the future by carefully splitting the headers content with application and driver "users" in mind. We currently have issues reported for librte_crypto recent changes for which suppression rules have been added too. Mellanox glue libraries are explicitly skipped as they are not part of the application ABI. Signed-off-by: David Marchand Acked-by: Luca Boccassi --- Changelog since v3: - rebased following patch 3 removal, - added dpdk.abignore to MAINTAINERS, - avoided meson reconfiguration when unneeded, - switched to fixed sources location for building ABI references, Changelog since v2: - forced -g / buildtype=3Ddebugoptimised in the test scripts so that we can check ABI in existing environments, - little update on the documentation, Changelog since v1: - reworked the scripts so that the build test scripts clone and build the reference automatically. A developer only needs to set one variable to enable the checks, - meson builds are done with debug so that abidiff can inspect the structures, - abidiff checks only public types by looking at installed headers, - abidiff has some issue when comparing a dump with a .so built with clang so all diff are now done with dump files only, - suppression rules have been added to waive warnings on exposed internal types, - an abi breakage has been reported on changes in cryptodev. For now, suppression rules have been put in place to let the CI run, --- .ci/linux-build.sh | 24 ++++++++++++ .travis.yml | 20 +++++++++- MAINTAINERS | 3 ++ devtools/check-abi.sh | 59 +++++++++++++++++++++++++++++ devtools/dpdk.abignore | 21 ++++++++++ devtools/gen-abi.sh | 26 +++++++++++++ devtools/test-build.sh | 52 ++++++++++++++++++++++--- devtools/test-meson-builds.sh | 50 ++++++++++++++++++++++-- doc/guides/contributing/patches.rst | 15 ++++++++ 9 files changed, 260 insertions(+), 10 deletions(-) create mode 100755 devtools/check-abi.sh create mode 100644 devtools/dpdk.abignore create mode 100755 devtools/gen-abi.sh diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index ccc3a7ccd..c7c3840fc 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -29,6 +29,7 @@ if [ "$BUILD_32BIT" =3D "1" ]; then fi =20 OPTS=3D"$OPTS --default-library=3D$DEF_LIB" +OPTS=3D"$OPTS --buildtype=3Ddebugoptimized" meson build --werror -Dexamples=3Dall $OPTS ninja -C build =20 @@ -36,6 +37,29 @@ if [ "$AARCH64" !=3D "1" ]; then devtools/test-null.sh fi =20 +if [ "$ABI_CHECKS" =3D "1" ]; then + REF_GIT_REPO=3D${REF_GIT_REPO:-https://dpdk.org/git/dpdk} + REF_GIT_TAG=3D${REF_GIT_TAG:-v19.11} + + if [ "$(cat reference/VERSION 2>/dev/null)" !=3D "$REF_GIT_TAG" ]; the= n + rm -rf reference + fi + + if [ ! -d reference ]; then + refsrcdir=3D$(readlink -f $(pwd)/../dpdk-$REF_GIT_TAG) + git clone --single-branch -b $REF_GIT_TAG $REF_GIT_REPO $refsrcdir + meson --werror $OPTS $refsrcdir $refsrcdir/build + ninja -C $refsrcdir/build + DESTDIR=3D$(pwd)/reference ninja -C $refsrcdir/build install + devtools/gen-abi.sh reference + echo $REF_GIT_TAG > reference/VERSION + fi + + DESTDIR=3D$(pwd)/install ninja -C build install + devtools/gen-abi.sh install + devtools/check-abi.sh reference install ${ABI_CHECKS_WARN_ONLY:-} +fi + if [ "$RUN_TESTS" =3D "1" ]; then sudo meson test -C build --suite fast-tests -t 3 fi diff --git a/.travis.yml b/.travis.yml index 8162f1c05..22539d823 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: c -cache: ccache +cache: + ccache: true + directories: + - reference compiler: - gcc - clang @@ -21,7 +24,7 @@ aarch64_packages: &aarch64_packages =20 extra_packages: &extra_packages - *required_packages - - [libbsd-dev, libpcap-dev, libcrypto++-dev, libjansson4] + - [libbsd-dev, libpcap-dev, libcrypto++-dev, libjansson4, abigail-tools] =20 build_32b_packages: &build_32b_packages - *required_packages @@ -151,5 +154,18 @@ matrix: packages: - *required_packages - *doc_packages + - env: DEF_LIB=3D"shared" EXTRA_PACKAGES=3D1 ABI_CHECKS=3D1 + compiler: gcc + addons: + apt: + packages: + - *extra_packages + - env: DEF_LIB=3D"shared" EXTRA_PACKAGES=3D1 ABI_CHECKS=3D1 + arch: arm64 + compiler: gcc + addons: + apt: + packages: + - *extra_packages =20 script: ./.ci/${TRAVIS_OS_NAME}-build.sh diff --git a/MAINTAINERS b/MAINTAINERS index 94bccae6d..db4b8c5b6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -144,8 +144,11 @@ M: Neil Horman F: lib/librte_eal/common/include/rte_compat.h F: lib/librte_eal/common/include/rte_function_versioning.h F: doc/guides/rel_notes/deprecation.rst +F: devtools/check-abi.sh F: devtools/check-abi-version.sh F: devtools/check-symbol-change.sh +F: devtools/dpdk.abignore +F: devtools/gen-abi.sh F: devtools/update-abi.sh F: devtools/update_version_map_abi.py F: devtools/validate-abi.sh diff --git a/devtools/check-abi.sh b/devtools/check-abi.sh new file mode 100755 index 000000000..5872499ec --- /dev/null +++ b/devtools/check-abi.sh @@ -0,0 +1,59 @@ +#!/bin/sh -e +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2019 Red Hat, Inc. + +if [ $# !=3D 2 ] && [ $# !=3D 3 ]; then +=09echo "Usage: $0 refdir newdir [warnonly]" +=09exit 1 +fi + +refdir=3D$1 +newdir=3D$2 +warnonly=3D${3:-} +ABIDIFF_OPTIONS=3D"--suppr $(dirname $0)/dpdk.abignore --no-added-syms" + +if [ ! -d $refdir ]; then +=09echo "Error: reference directory '$refdir' does not exist." +=09exit 1 +fi +incdir=3D$(find $refdir -type d -a -name include) +if [ -z "$incdir" ] || [ ! -e "$incdir" ]; then +=09echo "WARNING: could not identify a include directory for $refdir, expe= ct false positives..." +else +=09ABIDIFF_OPTIONS=3D"$ABIDIFF_OPTIONS --headers-dir1 $incdir" +fi + +if [ ! -d $newdir ]; then +=09echo "Error: directory to check '$newdir' does not exist." +=09exit 1 +fi +incdir2=3D$(find $newdir -type d -a -name include) +if [ -z "$incdir2" ] || [ ! -e "$incdir2" ]; then +=09echo "WARNING: could not identify a include directory for $newdir, expe= ct false positives..." +else +=09ABIDIFF_OPTIONS=3D"$ABIDIFF_OPTIONS --headers-dir2 $incdir2" +fi + +error=3D +for dump in $(find $refdir -name "*.dump"); do +=09name=3D$(basename $dump) +=09# skip glue drivers, example librte_pmd_mlx5_glue.dump +=09# We can't rely on a suppression rule for now: +=09# https://sourceware.org/bugzilla/show_bug.cgi?id=3D25480 +=09if [ "$name" !=3D "${name%%_glue.dump}" ]; then +=09=09echo "Skipping ${dump}..." +=09=09continue +=09fi +=09dump2=3D$(find $newdir -name $name) +=09if [ -z "$dump2" ] || [ ! -e "$dump2" ]; then +=09=09echo "Error: can't find $name in $newdir" +=09=09error=3D1 +=09=09continue +=09fi +=09if ! abidiff $ABIDIFF_OPTIONS $dump $dump2; then +=09=09echo "Error: ABI issue reported for 'abidiff $ABIDIFF_OPTIONS $dump = $dump2'" +=09=09error=3D1 +=09fi +done + +[ -z "$error" ] || [ -n "$warnonly" ] diff --git a/devtools/dpdk.abignore b/devtools/dpdk.abignore new file mode 100644 index 000000000..f2903612c --- /dev/null +++ b/devtools/dpdk.abignore @@ -0,0 +1,21 @@ +[suppress_function] + symbol_version =3D EXPERIMENTAL +[suppress_variable] + symbol_version =3D EXPERIMENTAL + +; Explicit ignore for driver-only ABI +[suppress_type] + name =3D rte_cryptodev_ops +; Ignore this enum update as it is part of an experimental API +[suppress_type] + type_kind =3D enum + name =3D rte_crypto_asym_xform_type + changed_enumerators =3D RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END + +; FIXME +[suppress_type] + type_kind =3D enum + name =3D rte_crypto_aead_algorithm + changed_enumerators =3D RTE_CRYPTO_AEAD_LIST_END +[suppress_variable] + name =3D rte_crypto_aead_algorithm_strings diff --git a/devtools/gen-abi.sh b/devtools/gen-abi.sh new file mode 100755 index 000000000..c44b0e228 --- /dev/null +++ b/devtools/gen-abi.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2019 Red Hat, Inc. + +if [ $# !=3D 1 ]; then +=09echo "Usage: $0 installdir" +=09exit 1 +fi + +installdir=3D$1 +if [ ! -d $installdir ]; then +=09echo "Error: install directory '$installdir' does not exist." +=09exit 1 +fi + +dumpdir=3D$installdir/dump +rm -rf $dumpdir +mkdir -p $dumpdir +for f in $(find $installdir -name "*.so.*"); do +=09if test -L $f; then +=09=09continue +=09fi + +=09libname=3D$(basename $f) +=09abidw --out-file $dumpdir/${libname%.so*}.dump $f +done diff --git a/devtools/test-build.sh b/devtools/test-build.sh index 52305fbb8..2f55e9147 100755 --- a/devtools/test-build.sh +++ b/devtools/test-build.sh @@ -6,6 +6,8 @@ default_path=3D$PATH =20 # Load config options: # - ARMV8_CRYPTO_LIB_PATH +# - DPDK_ABI_REF_DIR +# - DPDK_ABI_REF_VERSION # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2) # - DPDK_BUILD_TEST_DIR # - DPDK_DEP_ARCHIVE @@ -30,7 +32,8 @@ default_path=3D$PATH # - LIBSSO_SNOW3G_PATH # - LIBSSO_KASUMI_PATH # - LIBSSO_ZUC_PATH -. $(dirname $(readlink -f $0))/load-devel-config +devtools_dir=3D$(dirname $(readlink -f $0)) +. $devtools_dir/load-devel-config =20 print_usage () { =09echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]" @@ -67,7 +70,8 @@ J=3D$DPDK_MAKE_JOBS builds_dir=3D${DPDK_BUILD_TEST_DIR:-.} short=3Dfalse unset verbose -maxerr=3D-Wfatal-errors +# for ABI checks, we need debuginfo +test_cflags=3D"-Wfatal-errors -g" while getopts hj:sv ARG ; do =09case $ARG in =09=09j ) J=3D$OPTARG ;; @@ -97,7 +101,7 @@ trap "signal=3DINT ; trap - INT ; kill -INT $$" INT # notify result on exit trap on_exit EXIT =20 -cd $(dirname $(readlink -f $0))/.. +cd $devtools_dir/.. =20 reset_env () { @@ -233,14 +237,14 @@ for conf in $configs ; do =09# reload config with DPDK_TARGET set =09DPDK_TARGET=3D$target =09reset_env -=09. $(dirname $(readlink -f $0))/load-devel-config +=09. $devtools_dir/load-devel-config =20 =09options=3D$(echo $conf | sed 's,[^~+]*,,') =09dir=3D$builds_dir/$conf =09config $dir $target $options =20 =09echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Build $con= f" -=09${MAKE} -j$J EXTRA_CFLAGS=3D"$maxerr $DPDK_DEP_CFLAGS" \ +=09${MAKE} -j$J EXTRA_CFLAGS=3D"$test_cflags $DPDK_DEP_CFLAGS" \ =09=09EXTRA_LDFLAGS=3D"$DPDK_DEP_LDFLAGS" $verbose O=3D$dir =09! $short || break =09export RTE_TARGET=3D$target @@ -253,6 +257,44 @@ for conf in $configs ; do =09=09EXTRA_LDFLAGS=3D"$DPDK_DEP_LDFLAGS" $verbose \ =09=09O=3D$(readlink -f $dir)/examples =09unset RTE_TARGET +=09if [ -n "$DPDK_ABI_REF_VERSION" ]; then +=09=09abirefdir=3D${DPDK_ABI_REF_DIR:-reference}/$DPDK_ABI_REF_VERSION +=09=09if [ ! -d $abirefdir/$conf ]; then +=09=09=09# clone current sources +=09=09=09if [ ! -d $abirefdir/src ]; then +=09=09=09=09git clone --local --no-hardlinks \ +=09=09=09=09=09--single-branch \ +=09=09=09=09=09-b $DPDK_ABI_REF_VERSION \ +=09=09=09=09=09$(pwd) $abirefdir/src +=09=09=09fi + +=09=09=09cd $abirefdir/src + +=09=09=09rm -rf $abirefdir/build +=09=09=09config $abirefdir/build $target $options + +=09=09=09echo -n "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D B= uild $conf " +=09=09=09echo "($DPDK_ABI_REF_VERSION)" +=09=09=09${MAKE} -j$J \ +=09=09=09=09EXTRA_CFLAGS=3D"$test_cflags $DPDK_DEP_CFLAGS" \ +=09=09=09=09EXTRA_LDFLAGS=3D"$DPDK_DEP_LDFLAGS" $verbose \ +=09=09=09=09O=3D$abirefdir/build +=09=09=09! $short || break +=09=09=09export RTE_TARGET=3D$target +=09=09=09${MAKE} install O=3D$abirefdir/build \ +=09=09=09=09DESTDIR=3D$abirefdir/$conf \ +=09=09=09=09prefix=3D +=09=09=09unset RTE_TARGET +=09=09=09$devtools_dir/gen-abi.sh $abirefdir/$conf + +=09=09=09# back to current workdir +=09=09=09cd $devtools_dir/.. +=09=09fi + +=09=09echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Check A= BI $conf" +=09=09$devtools_dir/gen-abi.sh $dir/install +=09=09$devtools_dir/check-abi.sh $abirefdir/$conf $dir/install +=09fi =09echo "################## $conf done." =09unset dir done diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index fb6c404e5..c2d33b3b9 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -64,9 +64,18 @@ config () # =09builddir=3D$1 =09shift =09if [ -f "$builddir/build.ninja" ] ; then +=09=09# for existing environments, switch to debugoptimized if unset +=09=09# so that ABI checks can run +=09=09if ! $MESON configure $builddir | +=09=09=09=09awk '$1=3D=3D"buildtype" {print $2}' | +=09=09=09=09grep -qw debugoptimized; then +=09=09=09$MESON configure --buildtype=3Ddebugoptimized $builddir +=09=09fi =09=09return =09fi -=09options=3D"--werror -Dexamples=3Dall" +=09options=3D +=09options=3D"$options --werror -Dexamples=3Dall" +=09options=3D"$options --buildtype=3Ddebugoptimized" =09for option in $DPDK_MESON_OPTIONS ; do =09=09options=3D"$options -D$option" =09done @@ -92,6 +101,13 @@ compile () # =09fi } =20 +install_target () # +{ +=09rm -rf $2 +=09echo "DESTDIR=3D$2 $ninja_cmd -C $1 install" +=09DESTDIR=3D$2 $ninja_cmd -C $1 install +} + build () # { =09targetdir=3D$1 @@ -103,6 +119,31 @@ build () # =09load_env $targetcc || return 0 =09config $srcdir $builds_dir/$targetdir $* =09compile $builds_dir/$targetdir +=09if [ -n "$DPDK_ABI_REF_VERSION" ]; then +=09=09abirefdir=3D${DPDK_ABI_REF_DIR:-reference}/$DPDK_ABI_REF_VERSION +=09=09if [ ! -d $abirefdir/$targetdir ]; then +=09=09=09# clone current sources +=09=09=09if [ ! -d $abirefdir/src ]; then +=09=09=09=09git clone --local --no-hardlinks \ +=09=09=09=09=09--single-branch \ +=09=09=09=09=09-b $DPDK_ABI_REF_VERSION \ +=09=09=09=09=09$srcdir $abirefdir/src +=09=09=09fi + +=09=09=09rm -rf $abirefdir/build +=09=09=09config $abirefdir/src $abirefdir/build $* +=09=09=09compile $abirefdir/build +=09=09=09install_target $abirefdir/build $abirefdir/$targetdir +=09=09=09$srcdir/devtools/gen-abi.sh $abirefdir/$targetdir +=09=09fi + +=09=09install_target $builds_dir/$targetdir \ +=09=09=09$(readlink -f $builds_dir/$targetdir/install) +=09=09$srcdir/devtools/gen-abi.sh \ +=09=09=09$(readlink -f $builds_dir/$targetdir/install) +=09=09$srcdir/devtools/check-abi.sh $abirefdir/$targetdir \ +=09=09=09$(readlink -f $builds_dir/$targetdir/install) +=09fi } =20 if [ "$1" =3D "-vv" ] ; then @@ -153,8 +194,11 @@ done # Test installation of the x86-default target, to be used for checking # the sample apps build using the pkg-config file for cflags and libs build_path=3D$(readlink -f $builds_dir/build-x86-default) -export DESTDIR=3D$build_path/install-root -$ninja_cmd -C $build_path install +export DESTDIR=3D$build_path/install +# No need to reinstall if ABI checks are enabled +if [ -z "$DPDK_ABI_REF_VERSION" ]; then +=09install_target $build_path $DESTDIR +fi =20 load_env cc pc_file=3D$(find $DESTDIR -name libdpdk.pc) diff --git a/doc/guides/contributing/patches.rst b/doc/guides/contributing/= patches.rst index 0686450e4..59442824a 100644 --- a/doc/guides/contributing/patches.rst +++ b/doc/guides/contributing/patches.rst @@ -513,6 +513,21 @@ in a single subfolder called "__builds" created in the= current directory. Setting ``DPDK_BUILD_TEST_DIR`` to an absolute directory path e.g. ``/tmp`= ` is also supported. =20 =20 +Checking ABI compatibility +-------------------------- + +By default, ABI compatibility checks are disabled. + +To enable them, a reference version must be selected via the environment +variable ``DPDK_ABI_REF_VERSION``. + +The ``devtools/test-build.sh`` and ``devtools/test-meson-builds.sh`` scrip= ts +then build this reference version in a temporary directory and store the +results in a subfolder of the current working directory. +The environment variable ``DPDK_ABI_REF_DIR`` can be set so that the resul= ts go +to a different location. + + Sending Patches --------------- =20 --=20 2.23.0