6 CFLAGS_FOR_OVS
="-g -O2"
8 EXTRA_OPTS
="--enable-Werror"
9 TARGET
="x86_64-native-linuxapp-gcc"
11 function install_kernel
()
13 if [[ "$1" =~ ^
5.
* ]]; then
15 elif [[ "$1" =~ ^
4.
* ]]; then
17 elif [[ "$1" =~ ^
3.
* ]]; then
20 PREFIX
="v2.6/longterm/v2.6.32"
23 base_url
="https://cdn.kernel.org/pub/linux/kernel/${PREFIX}"
24 # Download page with list of all available kernel versions.
26 # Uncompress in case server returned gzipped page.
27 (file index
* |
grep ASCII
) ||
(mv index
* index.new.gz
&& gunzip index
*)
28 # Get version of the latest stable release.
29 hi_ver
=$
(echo ${1} |
sed 's/\./\\\./')
30 lo_ver
=$
(cat .
/index
* |
grep -P -o "${hi_ver}\.[0-9]+" | \
31 sed 's/.*\..*\.\(.*\)/\1/' |
sort -h |
tail -1)
32 version
="${1}.${lo_ver}"
36 url
="${base_url}/linux-${version}.tar.xz"
37 # Download kernel sources. Try direct link on CDN failure.
38 wget
${url} || wget ${url} || wget ${url/cdn/www}
40 tar xvf linux-
${version}.
tar.xz
> /dev
/null
41 pushd linux-
${version}
44 # Cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler
45 sed -i 's/CONFIG_KCOV=y/CONFIG_KCOV=n/' .config
47 # stack validation depends on tools/objtool, but objtool does not compile on travis.
48 # It is giving following error.
49 # >>> GEN arch/x86/insn/inat-tables.c
50 # >>> Semantic error at 40: Unknown imm opnd: AL
51 # So for now disable stack-validation for the build.
53 sed -i 's/CONFIG_STACK_VALIDATION=y/CONFIG_STACK_VALIDATION=n/' .config
56 # Older kernels do not include openvswitch
57 if [ -d "net/openvswitch" ]; then
64 sudo
make headers_install INSTALL_HDR_PATH
=/usr
66 # Bulding with gcc because there are some issues in make files
67 # that breaks building libbpf with clang on Travis.
68 CC
=gcc sudo
make install
69 CC
=gcc sudo
make install_headers
72 # The Linux kernel defines __always_inline in stddef.h (283d7573), and
73 # sys/cdefs.h tries to re-define it. Older libc-dev package in xenial
74 # doesn't have a fix for this issue. Applying it manually.
75 sudo
sed -i '/^# define __always_inline .*/i # undef __always_inline' \
76 /usr
/include
/x86_64-linux-gnu
/sys
/cdefs.h || true
77 EXTRA_OPTS
="${EXTRA_OPTS} --enable-afxdp"
79 EXTRA_OPTS
="${EXTRA_OPTS} --with-linux=$(pwd)"
80 echo "Installed kernel source in $(pwd)"
85 function install_dpdk
()
88 local VERSION_FILE
="dpdk-dir/travis-dpdk-cache-version"
90 if [ "${DPDK_VER##refs/*/}" != "${DPDK_VER}" ]; then
91 # Avoid using cache for git tree build.
94 DPDK_GIT
=${DPDK_GIT:-https://dpdk.org/git/dpdk}
95 git clone
--single-branch $DPDK_GIT dpdk-dir
-b "${DPDK_VER##refs/*/}"
99 if [ -f "${VERSION_FILE}" ]; then
100 VER
=$
(cat ${VERSION_FILE})
101 if [ "${VER}" = "${DPDK_VER}" ]; then
102 EXTRA_OPTS
="${EXTRA_OPTS} --with-dpdk=$(pwd)/dpdk-dir/build"
103 echo "Found cached DPDK ${VER} build in $(pwd)/dpdk-dir"
107 # No cache or version mismatch.
109 wget https
://fast.dpdk.org
/rel
/dpdk-
$1.
tar.xz
110 tar xvf dpdk-
$1.
tar.xz
> /dev
/null
111 DIR_NAME
=$
(tar -tf dpdk-
$1.
tar.xz |
head -1 | cut
-f1 -d"/")
112 mv ${DIR_NAME} dpdk-dir
116 make config CC
=gcc T
=$TARGET
118 if [ "$DPDK_SHARED" ]; then
119 sed -i '/CONFIG_RTE_BUILD_SHARED_LIB=n/s/=n/=y/' build
/.config
120 export LD_LIBRARY_PATH
=$LD_LIBRARY_PATH:$
(pwd)/$TARGET/lib
123 # Disable building DPDK kernel modules. Not needed for OVS build or tests.
124 sed -i '/CONFIG_RTE_EAL_IGB_UIO=y/s/=y/=n/' build
/.config
125 sed -i '/CONFIG_RTE_KNI_KMOD=y/s/=y/=n/' build
/.config
127 make -j4 CC
=gcc EXTRA_CFLAGS
='-fPIC'
128 EXTRA_OPTS
="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
129 echo "Installed DPDK source in $(pwd)"
131 echo "${DPDK_VER}" > ${VERSION_FILE}
134 function configure_ovs
()
137 .
/configure CFLAGS
="${CFLAGS_FOR_OVS}" $
* ||
{ cat config.log
; exit 1; }
147 # Only build datapath if we are testing kernel w/o running testsuite and
149 if [ "${KERNEL}" ] && ! [ "$AFXDP" ]; then
154 make -j4 ||
{ cat config.log
; exit 1; }
158 if [ "$KERNEL" ]; then
159 install_kernel
$KERNEL
162 if [ "$DPDK" ] ||
[ "$DPDK_SHARED" ]; then
163 if [ -z "$DPDK_VER" ]; then
166 install_dpdk
$DPDK_VER
167 if [ "$CC" = "clang" ]; then
168 # Disregard cast alignment errors until DPDK is fixed
169 CFLAGS_FOR_OVS
="${CFLAGS_FOR_OVS} -Wno-cast-align"
173 if [ "$CC" = "clang" ]; then
174 CFLAGS_FOR_OVS
="${CFLAGS_FOR_OVS} -Wno-error=unused-command-line-argument"
175 elif [ "$M32" ]; then
176 # Not using sparse for 32bit builds on 64bit machine.
177 # Adding m32 flag directly to CC to avoid any posiible issues with API/ABI
178 # difference on 'configure' and 'make' stages.
181 OPTS
="--enable-sparse"
182 if [ "$AFXDP" ]; then
183 # netdev-afxdp uses memset for 64M for umem initialization.
184 SPARSE_FLAGS
="${SPARSE_FLAGS} -Wno-memcpy-max-count"
186 CFLAGS_FOR_OVS
="${CFLAGS_FOR_OVS} ${SPARSE_FLAGS}"
189 save_OPTS
="${OPTS} $*"
190 OPTS
="${EXTRA_OPTS} ${save_OPTS}"
192 if [ "$TESTSUITE" ]; then
193 # 'distcheck' will reconfigure with required options.
194 # Now we only need to prepare the Makefile without sparse-wrapped CC.
197 export DISTCHECK_CONFIGURE_FLAGS
="$OPTS"
198 if ! make distcheck CFLAGS
="${CFLAGS_FOR_OVS}" \
199 TESTSUITEFLAGS
=-j4 RECHECK
=yes; then
200 # testsuite.log is necessary for debugging.
201 cat */_build
/sub
/tests
/testsuite.log
205 if [ -z "${KERNEL_LIST}" ]; then build_ovs
${KERNEL};
207 save_EXTRA_OPTS
="${EXTRA_OPTS}"
208 for KERNEL
in ${KERNEL_LIST}; do
209 echo "=============================="
210 echo "Building with kernel ${KERNEL}"
211 echo "=============================="
212 EXTRA_OPTS
="${save_EXTRA_OPTS}"
213 install_kernel
${KERNEL}
214 OPTS
="${EXTRA_OPTS} ${save_OPTS}"