diff --git a/.travis/build-debian.sh b/.travis/build-debian.sh index 7f895fdd..03e83e30 100755 --- a/.travis/build-debian.sh +++ b/.travis/build-debian.sh @@ -4,8 +4,10 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D mkdir build cd build -# We build without the GUI until Travis updates to an Ubuntu version with GTK 3.22. -cmake .. -DCMAKE_C_COMPILER=clang-3.9 -DCMAKE_CXX_COMPILER=clang++-3.9 \ +# We build without the GUI until Travis updates to an Ubuntu version with GTK 3.16+. +cmake .. \ + -DCMAKE_C_COMPILER=gcc-5 \ + -DCMAKE_CXX_COMPILER=g++-5 \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DENABLE_GUI=OFF \ -DENABLE_SANITIZERS=ON diff --git a/.travis/install-debian.sh b/.travis/install-debian.sh index 3f1e4388..6b23cc8b 100755 --- a/.travis/install-debian.sh +++ b/.travis/install-debian.sh @@ -1,10 +1,8 @@ #!/bin/sh -xe -wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test -sudo add-apt-repository -y 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main' sudo apt-get update -qq sudo apt-get install -q -y \ cmake cmake-data libc6-dev libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev \ libgtkmm-3.0-dev libpangomm-1.4-dev libcairo2-dev libgl1-mesa-dev libglu-dev \ - libfreetype6-dev dpkg-dev libstdc++-5-dev clang-3.9 clang++-3.9 lcov + libfreetype6-dev dpkg-dev gcc-5 g++-5 lcov diff --git a/CMakeLists.txt b/CMakeLists.txt index 901f7fbd..edc3b77c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,15 +80,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") endif() if(ENABLE_SANITIZERS) - if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") - message(FATAL_ERROR "Sanitizers are only available when using Clang/Clang++") + list(APPEND SANITIZERS address alignment bounds) + list(APPEND SANITIZERS shift signed-integer-overflow integer-divide-by-zero) + list(APPEND SANITIZERS null bool enum) + list(APPEND SANITIZERS return) + string(REPLACE ";" "," SANITIZERS "${SANITIZERS}") + set(SANITIZE_FLAGS "-O1 -fsanitize=${SANITIZERS} -fno-sanitize-recover=address,undefined") + + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fuse-ld=gold") + else() + message(FATAL_ERROR "Sanitizers are only available when using GCC or Clang") endif() - set(SANITIZE_FLAGS "-O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls") - set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address,integer") - set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize-recover=integer") - # We assume IEEE floats, which means DIV/0 is defined; but ubsan doesn't do so by default. - set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize=float-divide-by-zero") - set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fno-sanitize=unsigned-integer-overflow") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_FLAGS}")