dpdk/.ci/linux-build.sh
<<
>>
Prefs
   1#!/bin/sh -xe
   2
   3# Builds are run as root in containers, no need for sudo
   4[ "$(id -u)" != '0' ] || alias sudo=
   5
   6on_error() {
   7    if [ $? = 0 ]; then
   8        exit
   9    fi
  10    FILES_TO_PRINT="build/meson-logs/testlog.txt"
  11    FILES_TO_PRINT="$FILES_TO_PRINT build/.ninja_log"
  12    FILES_TO_PRINT="$FILES_TO_PRINT build/meson-logs/meson-log.txt"
  13    FILES_TO_PRINT="$FILES_TO_PRINT build/gdb.log"
  14
  15    for pr_file in $FILES_TO_PRINT; do
  16        if [ -e "$pr_file" ]; then
  17            cat "$pr_file"
  18        fi
  19    done
  20}
  21# We capture the error logs as artifacts in Github Actions, no need to dump
  22# them via a EXIT handler.
  23[ -n "$GITHUB_WORKFLOW" ] || trap on_error EXIT
  24
  25install_libabigail() {
  26    version=$1
  27    instdir=$2
  28
  29    wget -q "http://mirrors.kernel.org/sourceware/libabigail/${version}.tar.gz"
  30    tar -xf ${version}.tar.gz
  31    cd $version && autoreconf -vfi && cd -
  32    mkdir $version/build
  33    cd $version/build && ../configure --prefix=$instdir && cd -
  34    make -C $version/build all install
  35    rm -rf $version
  36    rm ${version}.tar.gz
  37}
  38
  39configure_coredump() {
  40    # No point in configuring coredump without gdb
  41    which gdb >/dev/null || return 0
  42    ulimit -c unlimited
  43    sudo sysctl -w kernel.core_pattern=/tmp/dpdk-core.%e.%p
  44}
  45
  46catch_coredump() {
  47    ls /tmp/dpdk-core.*.* 2>/dev/null || return 0
  48    for core in /tmp/dpdk-core.*.*; do
  49        binary=$(sudo readelf -n $core |grep $(pwd)/build/ 2>/dev/null |head -n1)
  50        [ -x $binary ] || binary=
  51        sudo gdb $binary -c $core \
  52            -ex 'info threads' \
  53            -ex 'thread apply all bt full' \
  54            -ex 'quit'
  55    done |tee -a build/gdb.log
  56    return 1
  57}
  58
  59cross_file=
  60
  61if [ "$AARCH64" = "true" ]; then
  62    if [ "${CC%%clang}" != "$CC" ]; then
  63        cross_file=config/arm/arm64_armv8_linux_clang_ubuntu
  64    else
  65        cross_file=config/arm/arm64_armv8_linux_gcc
  66    fi
  67fi
  68
  69if [ "$MINGW" = "true" ]; then
  70    cross_file=config/x86/cross-mingw
  71fi
  72
  73if [ "$PPC64LE" = "true" ]; then
  74    cross_file=config/ppc/ppc64le-power8-linux-gcc-ubuntu
  75fi
  76
  77if [ "$RISCV64" = "true" ]; then
  78    cross_file=config/riscv/riscv64_linux_gcc
  79fi
  80
  81if [ -n "$cross_file" ]; then
  82    OPTS="$OPTS --cross-file $cross_file"
  83fi
  84
  85if [ "$BUILD_DOCS" = "true" ]; then
  86    OPTS="$OPTS -Denable_docs=true"
  87fi
  88
  89if [ "$BUILD_32BIT" = "true" ]; then
  90    OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
  91    OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
  92    export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
  93fi
  94
  95if [ "$MINGW" = "true" ]; then
  96    OPTS="$OPTS -Dexamples=helloworld"
  97elif [ "$DEF_LIB" = "static" ]; then
  98    OPTS="$OPTS -Dexamples=l2fwd,l3fwd"
  99else
 100    OPTS="$OPTS -Dexamples=all"
 101fi
 102
 103OPTS="$OPTS -Dplatform=generic"
 104OPTS="$OPTS --default-library=$DEF_LIB"
 105OPTS="$OPTS --buildtype=debugoptimized"
 106OPTS="$OPTS -Dcheck_includes=true"
 107if [ "$MINI" = "true" ]; then
 108    OPTS="$OPTS -Denable_drivers=net/null"
 109    OPTS="$OPTS -Ddisable_libs=*"
 110fi
 111
 112if [ "$ASAN" = "true" ]; then
 113    OPTS="$OPTS -Db_sanitize=address"
 114    if [ "${CC%%clang}" != "$CC" ]; then
 115        OPTS="$OPTS -Db_lundef=false"
 116    fi
 117fi
 118
 119meson build --werror $OPTS
 120ninja -C build
 121
 122if [ -z "$cross_file" ]; then
 123    failed=
 124    configure_coredump
 125    devtools/test-null.sh || failed="true"
 126    catch_coredump
 127    [ "$failed" != "true" ]
 128fi
 129
 130if [ "$ABI_CHECKS" = "true" ]; then
 131    if [ "$(cat libabigail/VERSION 2>/dev/null)" != "$LIBABIGAIL_VERSION" ]; then
 132        rm -rf libabigail
 133        # if we change libabigail, invalidate existing abi cache
 134        rm -rf reference
 135    fi
 136
 137    if [ ! -d libabigail ]; then
 138        install_libabigail "$LIBABIGAIL_VERSION" $(pwd)/libabigail
 139        echo $LIBABIGAIL_VERSION > libabigail/VERSION
 140    fi
 141
 142    export PATH=$(pwd)/libabigail/bin:$PATH
 143
 144    REF_GIT_REPO=${REF_GIT_REPO:-https://dpdk.org/git/dpdk}
 145
 146    if [ "$(cat reference/VERSION 2>/dev/null)" != "$REF_GIT_TAG" ]; then
 147        rm -rf reference
 148    fi
 149
 150    if [ ! -d reference ]; then
 151        refsrcdir=$(readlink -f $(pwd)/../dpdk-$REF_GIT_TAG)
 152        git clone --single-branch -b "$REF_GIT_TAG" $REF_GIT_REPO $refsrcdir
 153        meson $OPTS -Dexamples= $refsrcdir $refsrcdir/build
 154        ninja -C $refsrcdir/build
 155        DESTDIR=$(pwd)/reference ninja -C $refsrcdir/build install
 156        devtools/gen-abi.sh reference
 157        find reference/usr/local -name '*.a' -delete
 158        rm -rf reference/usr/local/bin
 159        rm -rf reference/usr/local/share
 160        echo $REF_GIT_TAG > reference/VERSION
 161    fi
 162
 163    DESTDIR=$(pwd)/install ninja -C build install
 164    devtools/gen-abi.sh install
 165    devtools/check-abi.sh reference install ${ABI_CHECKS_WARN_ONLY:-}
 166fi
 167
 168if [ "$RUN_TESTS" = "true" ]; then
 169    failed=
 170    configure_coredump
 171    sudo meson test -C build --suite fast-tests -t 3 || failed="true"
 172    catch_coredump
 173    [ "$failed" != "true" ]
 174fi
 175