]>
Commit | Line | Data |
---|---|---|
826bc7b6 TG |
1 | #!/bin/bash |
2 | ||
de0ae686 | 3 | set -o errexit |
13429e32 | 4 | set -x |
de0ae686 | 5 | |
aa135fb9 | 6 | CFLAGS_FOR_OVS="-g -O2" |
3c6b3a51 | 7 | SPARSE_FLAGS="-Wno-flexible-array-array" |
dbd48310 | 8 | EXTRA_OPTS="--enable-Werror" |
826bc7b6 TG |
9 | |
10 | function install_kernel() | |
11 | { | |
2adada0e YS |
12 | if [[ "$1" =~ ^5.* ]]; then |
13 | PREFIX="v5.x" | |
14 | elif [[ "$1" =~ ^4.* ]]; then | |
3afcde43 JS |
15 | PREFIX="v4.x" |
16 | elif [[ "$1" =~ ^3.* ]]; then | |
517f9311 TG |
17 | PREFIX="v3.x" |
18 | else | |
19 | PREFIX="v2.6/longterm/v2.6.32" | |
20 | fi | |
21 | ||
c94e2d64 IM |
22 | base_url="https://cdn.kernel.org/pub/linux/kernel/${PREFIX}" |
23 | # Download page with list of all available kernel versions. | |
24 | wget ${base_url}/ | |
25 | # Uncompress in case server returned gzipped page. | |
26 | (file index* | grep ASCII) || (mv index* index.new.gz && gunzip index*) | |
27 | # Get version of the latest stable release. | |
28 | hi_ver=$(echo ${1} | sed 's/\./\\\./') | |
29 | lo_ver=$(cat ./index* | grep -P -o "${hi_ver}\.[0-9]+" | \ | |
30 | sed 's/.*\..*\.\(.*\)/\1/' | sort -h | tail -1) | |
31 | version="${1}.${lo_ver}" | |
32 | ||
2581b0ad IM |
33 | rm -rf index* linux-* |
34 | ||
c94e2d64 | 35 | url="${base_url}/linux-${version}.tar.xz" |
048674b4 IM |
36 | # Download kernel sources. Try direct link on CDN failure. |
37 | wget ${url} || wget ${url} || wget ${url/cdn/www} | |
c94e2d64 IM |
38 | |
39 | tar xvf linux-${version}.tar.xz > /dev/null | |
d5ad5804 | 40 | pushd linux-${version} |
de0ae686 | 41 | make allmodconfig |
517f9311 | 42 | |
c3cbb286 PS |
43 | # Cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler |
44 | sed -i 's/CONFIG_KCOV=y/CONFIG_KCOV=n/' .config | |
45 | ||
46 | # stack validation depends on tools/objtool, but objtool does not compile on travis. | |
47 | # It is giving following error. | |
48 | # >>> GEN arch/x86/insn/inat-tables.c | |
49 | # >>> Semantic error at 40: Unknown imm opnd: AL | |
50 | # So for now disable stack-validation for the build. | |
51 | ||
52 | sed -i 's/CONFIG_STACK_VALIDATION=y/CONFIG_STACK_VALIDATION=n/' .config | |
53 | make oldconfig | |
54 | ||
517f9311 TG |
55 | # Older kernels do not include openvswitch |
56 | if [ -d "net/openvswitch" ]; then | |
57 | make net/openvswitch/ | |
58 | else | |
59 | make net/bridge/ | |
60 | fi | |
61 | ||
d5ad5804 IM |
62 | if [ "$AFXDP" ]; then |
63 | sudo make headers_install INSTALL_HDR_PATH=/usr | |
64 | pushd tools/lib/bpf/ | |
65 | # Bulding with gcc because there are some issues in make files | |
66 | # that breaks building libbpf with clang on Travis. | |
67 | CC=gcc sudo make install | |
68 | CC=gcc sudo make install_headers | |
69 | sudo ldconfig | |
70 | popd | |
71 | # The Linux kernel defines __always_inline in stddef.h (283d7573), and | |
72 | # sys/cdefs.h tries to re-define it. Older libc-dev package in xenial | |
73 | # doesn't have a fix for this issue. Applying it manually. | |
74 | sudo sed -i '/^# define __always_inline .*/i # undef __always_inline' \ | |
75 | /usr/include/x86_64-linux-gnu/sys/cdefs.h || true | |
76 | EXTRA_OPTS="${EXTRA_OPTS} --enable-afxdp" | |
77 | else | |
78 | EXTRA_OPTS="${EXTRA_OPTS} --with-linux=$(pwd)" | |
79 | echo "Installed kernel source in $(pwd)" | |
80 | fi | |
81 | popd | |
826bc7b6 TG |
82 | } |
83 | ||
84 | function install_dpdk() | |
85 | { | |
7654a3ed IM |
86 | local DPDK_VER=$1 |
87 | local VERSION_FILE="dpdk-dir/travis-dpdk-cache-version" | |
88 | ||
e99c53ee LY |
89 | if [ -z "$TRAVIS_ARCH" ] || |
90 | [ "$TRAVIS_ARCH" == "amd64" ]; then | |
91 | TARGET="x86_64-native-linuxapp-gcc" | |
92 | elif [ "$TRAVIS_ARCH" == "aarch64" ]; then | |
93 | TARGET="arm64-armv8a-linuxapp-gcc" | |
94 | else | |
95 | echo "Target is unknown" | |
96 | exit 1 | |
97 | fi | |
98 | ||
7654a3ed IM |
99 | if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then |
100 | # Avoid using cache for git tree build. | |
101 | rm -rf dpdk-dir | |
102 | ||
3925b3e9 | 103 | DPDK_GIT=${DPDK_GIT:-https://dpdk.org/git/dpdk} |
7654a3ed IM |
104 | git clone --single-branch $DPDK_GIT dpdk-dir -b "${DPDK_VER##refs/*/}" |
105 | pushd dpdk-dir | |
3925b3e9 | 106 | git log -1 --oneline |
6c3cc113 | 107 | else |
7654a3ed IM |
108 | if [ -f "${VERSION_FILE}" ]; then |
109 | VER=$(cat ${VERSION_FILE}) | |
110 | if [ "${VER}" = "${DPDK_VER}" ]; then | |
111 | EXTRA_OPTS="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build" | |
112 | echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir" | |
113 | return | |
114 | fi | |
115 | fi | |
116 | # No cache or version mismatch. | |
117 | rm -rf dpdk-dir | |
03f3f9c0 OM |
118 | wget https://fast.dpdk.org/rel/dpdk-$1.tar.xz |
119 | tar xvf dpdk-$1.tar.xz > /dev/null | |
120 | DIR_NAME=$(tar -tf dpdk-$1.tar.xz | head -1 | cut -f1 -d"/") | |
7654a3ed IM |
121 | mv ${DIR_NAME} dpdk-dir |
122 | pushd dpdk-dir | |
6c3cc113 | 123 | fi |
bb16fbcc IM |
124 | |
125 | make config CC=gcc T=$TARGET | |
126 | ||
edfe8d26 | 127 | if [ "$DPDK_SHARED" ]; then |
bb16fbcc | 128 | sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build/.config |
edfe8d26 IS |
129 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/$TARGET/lib |
130 | fi | |
bb16fbcc IM |
131 | |
132 | # Disable building DPDK kernel modules. Not needed for OVS build or tests. | |
133 | sed -i '/CONFIG_RTE_EAL_IGB_UIO=y/s/=y/=n/' build/.config | |
134 | sed -i '/CONFIG_RTE_KNI_KMOD=y/s/=y/=n/' build/.config | |
135 | ||
7639e066 | 136 | make -j4 CC=gcc EXTRA_CFLAGS='-fPIC' |
3925b3e9 | 137 | EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build" |
de0ae686 | 138 | echo "Installed DPDK source in $(pwd)" |
7654a3ed IM |
139 | popd |
140 | echo "${DPDK_VER}" > ${VERSION_FILE} | |
826bc7b6 TG |
141 | } |
142 | ||
143 | function configure_ovs() | |
144 | { | |
aa135fb9 IM |
145 | ./boot.sh |
146 | ./configure CFLAGS="${CFLAGS_FOR_OVS}" $* || { cat config.log; exit 1; } | |
826bc7b6 TG |
147 | } |
148 | ||
2581b0ad IM |
149 | function build_ovs() |
150 | { | |
151 | local KERNEL=$1 | |
152 | ||
153 | configure_ovs $OPTS | |
154 | make selinux-policy | |
155 | ||
d5ad5804 IM |
156 | # Only build datapath if we are testing kernel w/o running testsuite and |
157 | # AF_XDP support. | |
158 | if [ "${KERNEL}" ] && ! [ "$AFXDP" ]; then | |
2581b0ad IM |
159 | pushd datapath |
160 | make -j4 | |
161 | popd | |
162 | else | |
c98f6907 | 163 | make -j4 || { cat config.log; exit 1; } |
2581b0ad IM |
164 | fi |
165 | } | |
166 | ||
00d3374d IM |
167 | if [ "$DEB_PACKAGE" ]; then |
168 | mk-build-deps --install --root-cmd sudo --remove debian/control | |
169 | dpkg-checkbuilddeps | |
170 | DEB_BUILD_OPTIONS='parallel=4 nocheck' fakeroot debian/rules binary | |
171 | # Not trying to install ipsec package as there are issues with system-wide | |
172 | # installed python3-openvswitch package and the pyenv used by Travis. | |
173 | packages=$(ls $(pwd)/../*.deb | grep -v ipsec) | |
174 | sudo apt install ${packages} | |
175 | exit 0 | |
176 | fi | |
177 | ||
bb16fbcc | 178 | if [ "$KERNEL" ]; then |
517f9311 | 179 | install_kernel $KERNEL |
826bc7b6 TG |
180 | fi |
181 | ||
edfe8d26 | 182 | if [ "$DPDK" ] || [ "$DPDK_SHARED" ]; then |
6c3cc113 | 183 | if [ -z "$DPDK_VER" ]; then |
02abe831 | 184 | DPDK_VER="19.11.2" |
6c3cc113 SS |
185 | fi |
186 | install_dpdk $DPDK_VER | |
543342a4 MK |
187 | if [ "$CC" = "clang" ]; then |
188 | # Disregard cast alignment errors until DPDK is fixed | |
aa135fb9 | 189 | CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} -Wno-cast-align" |
543342a4 | 190 | fi |
50f48c27 | 191 | fi |
826bc7b6 | 192 | |
418d2485 | 193 | if [ "$CC" = "clang" ]; then |
aa135fb9 IM |
194 | CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} -Wno-error=unused-command-line-argument" |
195 | elif [ "$M32" ]; then | |
196 | # Not using sparse for 32bit builds on 64bit machine. | |
197 | # Adding m32 flag directly to CC to avoid any posiible issues with API/ABI | |
198 | # difference on 'configure' and 'make' stages. | |
199 | export CC="$CC -m32" | |
e99c53ee | 200 | elif [ "$TRAVIS_ARCH" != "aarch64" ]; then |
2581b0ad | 201 | OPTS="--enable-sparse" |
d5ad5804 IM |
202 | if [ "$AFXDP" ]; then |
203 | # netdev-afxdp uses memset for 64M for umem initialization. | |
204 | SPARSE_FLAGS="${SPARSE_FLAGS} -Wno-memcpy-max-count" | |
205 | fi | |
aa135fb9 | 206 | CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${SPARSE_FLAGS}" |
95c9bfd4 BP |
207 | fi |
208 | ||
2581b0ad IM |
209 | save_OPTS="${OPTS} $*" |
210 | OPTS="${EXTRA_OPTS} ${save_OPTS}" | |
211 | ||
d643d62c | 212 | if [ "$TESTSUITE" ]; then |
8e7d5b64 | 213 | # 'distcheck' will reconfigure with required options. |
1a11f527 | 214 | # Now we only need to prepare the Makefile without sparse-wrapped CC. |
8e7d5b64 IM |
215 | configure_ovs |
216 | ||
217 | export DISTCHECK_CONFIGURE_FLAGS="$OPTS" | |
aa135fb9 IM |
218 | if ! make distcheck CFLAGS="${CFLAGS_FOR_OVS}" \ |
219 | TESTSUITEFLAGS=-j4 RECHECK=yes; then | |
95c9bfd4 | 220 | # testsuite.log is necessary for debugging. |
4e5c87e9 | 221 | cat */_build/sub/tests/testsuite.log |
95c9bfd4 | 222 | exit 1 |
aeef7193 | 223 | fi |
8e7d5b64 | 224 | else |
2581b0ad IM |
225 | if [ -z "${KERNEL_LIST}" ]; then build_ovs ${KERNEL}; |
226 | else | |
227 | save_EXTRA_OPTS="${EXTRA_OPTS}" | |
228 | for KERNEL in ${KERNEL_LIST}; do | |
229 | echo "==============================" | |
230 | echo "Building with kernel ${KERNEL}" | |
231 | echo "==============================" | |
232 | EXTRA_OPTS="${save_EXTRA_OPTS}" | |
233 | install_kernel ${KERNEL} | |
234 | OPTS="${EXTRA_OPTS} ${save_OPTS}" | |
235 | build_ovs ${KERNEL} | |
236 | make distclean | |
237 | done | |
8e7d5b64 | 238 | fi |
826bc7b6 TG |
239 | fi |
240 | ||
241 | exit 0 |