From: Christian Brauner Date: Mon, 23 Dec 2019 19:12:57 +0000 (+0100) Subject: travis: enable -fsanitize=undefined X-Git-Tag: lxc-4.0.0~67^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=384db5d7618672e9b9808b5b631193f16496de92;p=thirdparty%2Flxc.git travis: enable -fsanitize=undefined Signed-off-by: Christian Brauner --- diff --git a/.travis.yml b/.travis.yml index b8c695ffe..4fc67d0f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,22 +6,7 @@ before_install: - sudo add-apt-repository ppa:ubuntu-lxc/daily -y - sudo apt-get update -qq - sudo apt-get install -qq coccinelle parallel libapparmor-dev libcap-dev libseccomp-dev python3-dev python3-setuptools docbook2x libgnutls-dev libselinux1-dev linux-libc-dev -script: - - ./coccinelle/run-coccinelle.sh -i - - git diff --exit-code - - export CFLAGS="-Wall -Werror" - - export LDFLAGS="-pthread -lpthread" - - ./autogen.sh - - rm -Rf build - - mkdir build - - cd build - - ../configure --enable-tests --with-distro=unknown - - make -j4 - - make DESTDIR=$TRAVIS_BUILD_DIR/install install - - cd ../config/apparmor - - ./lxc-generate-aa-rules.py container-rules.base > /tmp/output - - diff /tmp/output container-rules - +script: src/tests/travis.sh notifications: email: recipients: diff --git a/configure.ac b/configure.ac index 3ef4d37fd..2cf74b86b 100644 --- a/configure.ac +++ b/configure.ac @@ -440,6 +440,12 @@ AC_ARG_ENABLE([asan], [enable_asan=$enableval], [enable_asan=no]) AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"]) +# Build with UBSAN commands +AC_ARG_ENABLE([ubsan], + [AS_HELP_STRING([--enable-ubsan], [build with ubsan sanitizer enabled [default=no]])], + [enable_asan=$enableval], [enable_ubsan=no]) +AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = "xyes"]) + # Optional test binaries AC_ARG_ENABLE([tests], [AS_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])], diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index eea8adcc9..b85ebedfe 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -240,12 +240,17 @@ endif liblxc_la_CFLAGS = -fPIC \ -DPIC \ $(AM_CFLAGS) \ + $(LIBLXC_SANITIZER) \ -pthread if ENABLE_ASAN liblxc_la_CFLAGS += -fsanitize=address \ -fno-omit-frame-pointer endif +if ENABLE_UBSAN +liblxc_la_CFLAGS += -fsanitize=undefined +endif + liblxc_la_LDFLAGS = -pthread \ -Wl,-no-undefined \ -Wl,-soname,liblxc.so.$(firstword $(subst ., ,@LXC_ABI@)) \ diff --git a/src/tests/travis.sh b/src/tests/travis.sh new file mode 100755 index 000000000..e57004e09 --- /dev/null +++ b/src/tests/travis.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +set -e + +./coccinelle/run-coccinelle.sh -i +git diff --exit-code +export CFLAGS="-Wall -Werror" +export LDFLAGS="-pthread -lpthread" +./autogen.sh +rm -Rf build +mkdir build +cd build +if [ "$CC_FOR_BUILD" == "gcc" ]; then + ../configure --enable-tests --enable-ubsan --with-distro=unknown +else + ../configure --enable-tests --with-distro=unknown +fi +make -j4 +make DESTDIR="$TRAVIS_BUILD_DIR"/install install +cd ../config/apparmor +./lxc-generate-aa-rules.py container-rules.base > /tmp/output +diff /tmp/output container-rules