widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11631
[Merge] lp:~widelands-dev/widelands/run-asan into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/run-asan into lp:widelands.
Commit message:
Added compile options for AddressSanitizer and for choosing the compiler. 2 new warning flags for the clang compiler.
Requested reviews:
Tino (tino79)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/run-asan/+merge/334227
Added compile options for AddressSanitizer and for choosing the compiler. 2 new warning flags for the clang compiler.
I switched ASAN off for Travis and AppVeyor - I am worried about both braking the test suite and timeouts if jobs take too long. We can look at that in a follow-up branch.
Pinging Tino in case he needs to change his setup.
--
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/run-asan.
=== modified file '.travis.sh'
--- .travis.sh 2017-07-31 17:14:06 +0000
+++ .travis.sh 2017-11-24 09:23:12 +0000
@@ -25,7 +25,7 @@
# Configure the build
mkdir build
cd build
-cmake .. -DCMAKE_BUILD_TYPE:STRING="$BUILD_TYPE"
+cmake .. -DCMAKE_BUILD_TYPE:STRING="$BUILD_TYPE" -DOPTION_ASAN="OFF"
if [ "$BUILD_TYPE" == "Debug" ]; then
@@ -45,7 +45,7 @@
# Any codecheck warning is an error in Debug builds. Keep the codebase clean!!
# Suppress color output.
TERM=dumb make -j1 codecheck 2>&1 | tee codecheck.out
- if grep '^[/_.a-zA-Z]\+:[0-9]\+:' codecheck.out; then
+ if grep '^[/_.a-zA-Z]\+:[0-9]\+:' codecheck.out; then
echo "You have codecheck warnings (see above) Please fix."
exit 1 # CodeCheck warnings.
fi
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2017-09-20 11:38:26 +0000
+++ CMakeLists.txt 2017-11-24 09:23:12 +0000
@@ -8,6 +8,7 @@
option(OPTION_GLEW_STATIC "Use static GLEW Library" OFF)
option(OPTION_BUILD_WEBSITE_TOOLS "Build website-related tools" ON)
option(OPTION_BUILD_TRANSLATIONS "Build translations" ON)
+option(OPTION_ASAN "Build with AddressSanitizer" ON)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Build directory and source directory must not be the same.")
@@ -37,6 +38,10 @@
message(WARNING "You are using an unsupported compiler! Supported are Clang and GCC.")
endif()
+if(OPTION_ASAN)
+ message(STATUS "Using AddressSanitizer http://clang.llvm.org/docs/AddressSanitizer.html")
+endif(OPTION_ASAN)
+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
if (WIN32)
@@ -115,6 +120,13 @@
wl_add_flag(WL_GENERIC_CXX_FLAGS "-std=c++11")
+if(OPTION_ASAN)
+ # See http://clang.llvm.org/docs/AddressSanitizer.html
+ wl_add_flag(WL_COMPILE_DIAGNOSTICS "-fsanitize=address")
+ wl_add_flag(WL_COMPILE_DIAGNOSTICS "-fno-omit-frame-pointer")
+ set (CMAKE_EXE_LINKER_FLAGS "-fsanitize=address" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
+endif(OPTION_ASAN)
+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Weverything")
@@ -143,6 +155,8 @@
wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Werror=non-pod-varargs")
wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Qunused-arguments")
+ wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Winconsistent-missing-override")
+ wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wint-to-void-pointer-cast")
else()
# Assuming GCC 4.8 or higher.
if(WIN32)
=== modified file 'appveyor.yml'
--- appveyor.yml 2017-05-14 21:06:23 +0000
+++ appveyor.yml 2017-11-24 09:23:12 +0000
@@ -32,7 +32,7 @@
- cmd: md build
- cmd: cd build
- cmd: echo %APPVEYOR_BUILD_VERSION%_%CONFIGURATION%_%PLATFORM% > %APPVEYOR_BUILD_FOLDER%\WL_RELEASE
- - cmd: "cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=ON %APPVEYOR_BUILD_FOLDER%"
+ - cmd: "cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=ON -DOPTION_ASAN=OFF %APPVEYOR_BUILD_FOLDER%"
# Appveyor does not provide enough memory to build/link thex64 debug build in parallel (Oct 2016)
# TODO(Tino): Optimize WL build scripts to use less memory/no cyclic dependencies
- cmd: "IF \"%PLATFORM%\" == \"x64\" (IF \"%CONFIGURATION%\" == \"Debug\" (ninja -j 1) ELSE (ninja)) ELSE (ninja)"
@@ -40,15 +40,15 @@
- cmd: strip -sv %APPVEYOR_BUILD_FOLDER%\build\src\widelands.exe
- cmd: ISCC /q /o%APPVEYOR_BUILD_FOLDER% /fWidelands-%APPVEYOR_BUILD_VERSION%-%CONFIGURATION%-%PLATFORM% c:\projects\widelands\utils\win32\innosetup\Widelands.iss
- appveyor PushArtifact %APPVEYOR_BUILD_FOLDER%\Widelands-%APPVEYOR_BUILD_VERSION%-%CONFIGURATION%-%PLATFORM%.exe
-
+
artifacts:
- path: Widelands-$(APPVEYOR_BUILD_VERSION)-$(CONFIGURATION)-$(PLATFORM).exe
name: Widelands Setup
-platform:
+platform:
- x64
- x86
configuration:
- Release
- - Debug
\ No newline at end of file
+ - Debug
=== modified file 'compile.sh'
--- compile.sh 2017-03-07 14:57:26 +0000
+++ compile.sh 2017-11-24 09:23:12 +0000
@@ -20,22 +20,90 @@
echo " "
echo "###########################################################"
echo " "
+print_help () {
+ # Print help for our options
+ echo "Per default, this script will create a full debug build."
+ echo "Unless explicitly switched off, AddressSanitizer will"
+ echo "be used as well with debug builds."
+ echo " "
+ echo "The following options are available:"
+ echo " "
+ echo "-a or --help Print this help."
+ echo " "
+ echo " "
+ echo "Omission options:"
+ echo " "
+ echo "-w or --no-website Omit building of website binaries."
+ echo " "
+ echo "-t or --no-translations"
+ echo " Omit building translations."
+ echo " "
+ echo "-a or --no-asan If in debug mode, switch off the AddressSanitizer."
+ echo " Release builds are created without AddressSanitizer"
+ echo " per default."
+ echo " "
+ echo "Compiler options:"
+ echo " "
+ echo "-r or --release Create a release build. If this is not set,"
+ echo " a debug build will be created."
+ echo " "
+ echo "--gcc Try to build with GCC rather than the system default."
+ echo " If you built with Clang before, you will have to clean"
+ echo " your build directory before switching compilers."
+ echo " Expects that the compiler is in '/usr/bin/'."
+ echo " "
+ echo "--clang Try to build with Clang rather than the system default."
+ echo " If you built with GCC before, you will have to clean"
+ echo " your build directory before switching compilers."
+ echo " Expects that the compiler is in '/usr/bin/'."
+ echo " "
+ echo "For the AddressSanitizer output to be useful, some systems (e.g. Ubuntu Linux)"
+ echo "require that you set a symlink to the symbolizer. For example:"
+ echo " "
+ echo " sudo ln -s /usr/bin/llvm-symbolizer-3.8 /usr/bin/llvm-symbolizer"
+ echo " "
+ echo "More info about AddressSanitizer at:"
+ echo " "
+ echo " http://clang.llvm.org/docs/AddressSanitizer.html"
+ echo " "
+ return
+ }
+
## Option to avoid building and linking website-related executables.
BUILD_WEBSITE="ON"
BUILD_TRANSLATIONS="ON"
-BUILDTYPE="Debug"
+BUILD_TYPE="Debug"
+USE_ASAN="ON"
+COMPILER="default"
while [ "$1" != "" ]; do
if [ "$1" = "--no-website" -o "$1" = "-w" ]; then
BUILD_WEBSITE="OFF"
elif [ "$1" = "--release" -o "$1" = "-r" ]; then
- BUILDTYPE="Release"
+ BUILD_TYPE="Release"
+ USE_ASAN="OFF"
elif [ "$1" = "--no-translations" -o "$1" = "-t" ]; then
BUILD_TRANSLATIONS="OFF"
+ elif [ "$1" = "--no-asan" -o "$1" = "-a" ]; then
+ USE_ASAN="OFF"
+ elif [ "$1" = "--gcc"]; then
+ if [ -f /usr/bin/gcc -a /usr/bin/g++ ]; then
+ export CC=/usr/bin/gcc
+ export CXX=/usr/bin/g++
+ fi
+ elif [ "$1" = "--clang" ]; then
+ if [ -f /usr/bin/clang -a /usr/bin/clang++ ]; then
+ export CC=/usr/bin/clang
+ export CXX=/usr/bin/clang++
+ fi
+ elif [ "$1" = "--help" -o "$1" = "-h" ]; then
+ print_help
+ exit 0
fi
shift
done
+
if [ $BUILD_WEBSITE = "ON" ]; then
echo "A complete build will be created."
echo "You can use -w or --no-website to omit building and"
@@ -55,12 +123,24 @@
echo " "
echo "###########################################################"
echo " "
-if [ $BUILDTYPE = "Release" ]; then
+if [ $BUILD_TYPE = "Release" ]; then
echo "Creating a Release build."
else
echo "Creating a Debug build. Use -r to create a Release build."
fi
echo " "
+if [ $USE_ASAN = "ON" ]; then
+ echo "Will build with AddressSanitizer."
+ echo "http://clang.llvm.org/docs/AddressSanitizer.html"
+ echo "You can use -a or --no-asan to switch it off."
+else
+ echo "Will build without AddressSanitizer."
+fi
+echo " "
+echo "###########################################################"
+echo " "
+echo "Call 'compile.sh -h' or 'compile.sh --help' for help."
+echo ""
echo "For instructions on how to adjust options and build with"
echo "CMake, please take a look at"
echo "https://wl.widelands.org/wiki/BuildingWidelands/."
@@ -114,9 +194,9 @@
# Compile Widelands
compile_widelands () {
if [ $buildtool = "ninja" ] || [ $buildtool = "ninja-build" ] ; then
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILDTYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS
+ cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_ASAN=$USE_ASAN
else
- cmake .. -DCMAKE_BUILD_TYPE=$BUILDTYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS
+ cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOPTION_BUILD_WEBSITE_TOOLS=$BUILD_WEBSITE -DOPTION_BUILD_TRANSLATIONS=$BUILD_TRANSLATIONS -DOPTION_ASAN=$USE_ASAN
fi
$buildtool
@@ -203,7 +283,7 @@
echo "# Congratulations! Widelands has been built successfully #"
echo "# with the following settings: #"
echo "# #"
-if [ $BUILDTYPE = "Release" ]; then
+if [ $BUILD_TYPE = "Release" ]; then
echo "# - Release build #"
else
echo "# - Debug build #"
Follow ups