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