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 B2C36A052F; Wed, 29 Jan 2020 18:27:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F03191C0AC; Wed, 29 Jan 2020 18:27:06 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id D1BE71C0AB for ; Wed, 29 Jan 2020 18:27:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580318824; 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=AwqJsHphzE8HoQSA4h5l2U/VtrYfjQM87iq/riluFTk=; b=Lu0QW/oWtOPPGbTVuxcFE9moY50DZf9xFigO/l+4DgcIW16lZMMDy2yRNNdIrn4vdbqh5B iE4W+hrA6ftL69D/YpbTLk1yQSU7XGreMagdh5vTl68D0gc64KtOzvm4Tatit8DihkpYfk 4bOv3Vi9wk1vdMgoQVScy3QWjjeTGP4= 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-265-Itm83PelPHSwZZNckyU-ag-1; Wed, 29 Jan 2020 12:26:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70B5A8018A8; Wed, 29 Jan 2020 17:26:44 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-128.brq.redhat.com [10.40.204.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE71684BC9; Wed, 29 Jan 2020 17:26:41 +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, Michael Santana , John McNamara , Marko Kovacevic Date: Wed, 29 Jan 2020 18:26:21 +0100 Message-Id: <20200129172621.28565-5-david.marchand@redhat.com> In-Reply-To: <20200129172621.28565-1-david.marchand@redhat.com> References: <20191220152058.10739-1-david.marchand@redhat.com> <20200129172621.28565-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: Itm83PelPHSwZZNckyU-ag-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 v2 4/4] 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 only informational 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 and security 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 --- 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 | 23 +++++++++++ .travis.yml | 20 +++++++++- MAINTAINERS | 2 + devtools/check-abi.sh | 59 +++++++++++++++++++++++++++++ devtools/dpdk.abignore | 20 ++++++++++ devtools/gen-abi.sh | 26 +++++++++++++ devtools/test-build.sh | 45 ++++++++++++++++++++-- devtools/test-meson-builds.sh | 35 ++++++++++++++++- doc/guides/contributing/patches.rst | 13 +++++++ 9 files changed, 236 insertions(+), 7 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 e61aa2b0a..95bd869c3 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -30,6 +30,7 @@ fi =20 OPTS=3D"$OPTS --default-library=3D$DEF_LIB" OPTS=3D"$OPTS --prefix=3D/usr -Dlibdir=3Dlib" +OPTS=3D"$OPTS --buildtype=3Ddebugoptimized" meson build --werror -Dexamples=3Dall $OPTS ninja -C build DESTDIR=3D$(pwd)/install ninja -C build install @@ -40,6 +41,28 @@ if [ "$AARCH64" !=3D "1" ]; then unset LD_LIBRARY_PATH 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 + + 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..6dae4ee63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -144,8 +144,10 @@ 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/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..0c01eebea --- /dev/null +++ b/devtools/dpdk.abignore @@ -0,0 +1,20 @@ +[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 + +; FIXME +[suppress_type] + type_kind =3D enum + name =3D rte_crypto_aead_algorithm + changed_enumerators =3D RTE_CRYPTO_AEAD_LIST_END +[suppress_type] + type_kind =3D enum + name =3D rte_crypto_asym_xform_type + changed_enumerators =3D RTE_CRYPTO_ASYM_XFORM_TYPE_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..fba30bac9 100755 --- a/devtools/test-build.sh +++ b/devtools/test-build.sh @@ -30,7 +30,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] ...]]" @@ -64,6 +65,7 @@ print_help () { [ -z $MAKE ] && echo "Cannot find make or gmake" && exit 1 =20 J=3D$DPDK_MAKE_JOBS +refsrcdir=3D$(mktemp -d -t dpdk-${DPDK_ABI_REF_VERSION:-}.XXX) builds_dir=3D${DPDK_BUILD_TEST_DIR:-.} short=3Dfalse unset verbose @@ -91,13 +93,14 @@ on_exit () =09=09[ "$DPDK_NOTIFY" !=3D notify-send ] || \ =09=09=09notify-send -u low --icon=3Ddialog-error 'DPDK build' 'failed' =09fi +=09rm -rf $refsrcdir } # catch manual interrupt to ignore notification 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,7 +236,7 @@ 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 @@ -253,6 +256,42 @@ 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=09DPDK_ABI_REF_DIR=3D${DPDK_ABI_REF_DIR:-reference} +=09=09abirefdir=3D$DPDK_ABI_REF_DIR/$DPDK_ABI_REF_VERSION/$conf +=09=09if [ ! -d $abirefdir ]; then +=09=09=09# clone current sources +=09=09=09if [ ! -d $refsrcdir/.git ]; 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) $refsrcdir +=09=09=09fi + +=09=09=09cd $refsrcdir + +=09=09=09rm -rf build +=09=09=09config 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 EXTRA_CFLAGS=3D"$maxerr $DPDK_DEP_CFLAGS" \ +=09=09=09=09EXTRA_LDFLAGS=3D"$DPDK_DEP_LDFLAGS" $verbose \ +=09=09=09=09O=3Dbuild +=09=09=09! $short || break +=09=09=09export RTE_TARGET=3D$target +=09=09=09${MAKE} install O=3Dbuild DESTDIR=3D$abirefdir \ +=09=09=09=09prefix=3D +=09=09=09$devtools_dir/gen-abi.sh $abirefdir + +=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 $dir/install +=09fi =09echo "################## $conf done." =09unset dir done diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index 254588ae6..1b410c784 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -16,8 +16,15 @@ srcdir=3D$(dirname $(readlink -f $0))/.. =20 MESON=3D${MESON:-meson} use_shared=3D"--default-library=3Dshared" +refsrcdir=3D$(mktemp -d -t dpdk-${DPDK_ABI_REF_VERSION:-}.XXX) builds_dir=3D${DPDK_BUILD_TEST_DIR:-.} =20 +on_exit () +{ +=09rm -rf $refsrcdir +} +trap on_exit EXIT + if command -v gmake >/dev/null 2>&1 ; then =09MAKE=3Dgmake else @@ -63,7 +70,9 @@ config () # =09shift =09builddir=3D$1 =09shift -=09options=3D"--werror -Dexamples=3Dall --prefix=3D/usr -Dlibdir=3Dlib" +=09options=3D +=09options=3D"$options --werror --buildtype=3Ddebugoptimized -Dexamples=3D= all" +=09options=3D"$options --prefix=3D/usr -Dlibdir=3Dlib" =09for option in $DPDK_MESON_OPTIONS ; do =09=09options=3D"$options -D$option" =09done @@ -96,7 +105,6 @@ compile () # =09=09$ninja_cmd -C $builddir =09=09$ninja_cmd -C $builddir install =09fi -=09unset DESTDIR } =20 build () # @@ -111,6 +119,29 @@ build () # =09config $srcdir $builds_dir/$targetdir $* =09compile $builds_dir/$targetdir \ =09=09$(readlink -f $builds_dir/$targetdir/install) +=09if [ -n "$DPDK_ABI_REF_VERSION" ]; then +=09=09DPDK_ABI_REF_DIR=3D${DPDK_ABI_REF_DIR:-reference} +=09=09abirefdir=3D$DPDK_ABI_REF_DIR/$DPDK_ABI_REF_VERSION/$targetdir +=09=09if [ ! -d $abirefdir ]; then +=09=09=09# clone current sources +=09=09=09if [ ! -d $refsrcdir/.git ]; 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 $refsrcdir +=09=09=09fi + +=09=09=09rm -rf $refsrcdir/build +=09=09=09config $refsrcdir $refsrcdir/build $* +=09=09=09compile $refsrcdir/build $abirefdir +=09=09=09$srcdir/devtools/gen-abi.sh $abirefdir +=09=09fi + +=09=09$srcdir/devtools/gen-abi.sh \ +=09=09=09$(readlink -f $builds_dir/$targetdir/install) +=09=09$srcdir/devtools/check-abi.sh $abirefdir \ +=09=09=09$(readlink -f $builds_dir/$targetdir/install) +=09fi } =20 if [ "$1" =3D "-vv" ] ; then diff --git a/doc/guides/contributing/patches.rst b/doc/guides/contributing/= patches.rst index 0686450e4..2e16741ca 100644 --- a/doc/guides/contributing/patches.rst +++ b/doc/guides/contributing/patches.rst @@ -513,6 +513,19 @@ 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 the ``DPDK_ABI_REF_DIR`` directory. + + Sending Patches --------------- =20 --=20 2.23.0