[lxc-devel] [lxc/master] travis: enable -fsanitize=undefined
brauner on Github
lxc-bot at linuxcontainers.org
Mon Dec 23 20:37:11 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191223/5902abfc/attachment.bin>
-------------- next part --------------
From 8728e6b79eadd31bc3b380c1f64236399d4f8518 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 23 Dec 2019 20:12:57 +0100
Subject: [PATCH] travis: enable -fsanitize=undefined
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
.travis.yml | 51 +++++++++++++++++++++++++++++----------------
configure.ac | 6 ++++++
src/lxc/Makefile.am | 5 +++++
3 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b8c695ffee..81878e615c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,26 +1,41 @@
language: c
-compiler:
- - gcc
- - clang
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
+compiler:
+ - gcc
+ 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 --enable-ubsan --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
+ - clang
+ 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
notifications:
email:
diff --git a/configure.ac b/configure.ac
index 3ef4d37fdb..2cf74b86ba 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 eea8adcc9d..b85ebedfe0 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 ., , at LXC_ABI@)) \
More information about the lxc-devel
mailing list