Skip to content

Commit bf51b47

Browse files
Joost VandeVondelemcostalba
authored andcommitted
travis-ci: Enable undefined behavior checking
1 parent e18e557 commit bf51b47

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ matrix:
99
addons:
1010
apt:
1111
sources: ['ubuntu-toolchain-r-test']
12-
packages: ['g++-multilib', 'valgrind']
12+
packages: ['g++-6', 'g++-6-multilib', 'g++-multilib', 'valgrind']
1313
env:
14-
- COMPILER=g++
14+
- COMPILER=g++-6
1515
- COMP=gcc
1616

1717
- os: linux
@@ -51,3 +51,5 @@ script:
5151
- test ! -s result
5252
# if valgrind is available check the build is without error, reduce depth to speedup testing, but not too shallow to catch more cases.
5353
- if [ -x "$(command -v valgrind )" ] ; then make clean && make ARCH=x86-64 debug=yes build && valgrind --error-exitcode=42 ./stockfish bench 128 1 10 default depth 1>/dev/null ; fi
54+
# use g++-6 as a proxy for having sanitizers ... might need revision as they become available for more recent versions of clang/gcc than trusty provides
55+
- if [[ "$COMPILER" == "g++-6" ]]; then make clean && make ARCH=x86-64 sanitize=yes build && ! ./stockfish bench 2>&1 | grep "runtime error:" ; fi

src/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
5050
# ----------------------------------------------------------------------------
5151
#
5252
# debug = yes/no --- -DNDEBUG --- Enable/Disable debug mode
53+
# sanitize = yes/no --- (-fsanitize ) --- enable undefined behavior checks
5354
# optimize = yes/no --- (-O3/-fast etc.) --- Enable/Disable optimizations
5455
# arch = (name) --- (-arch) --- Target architecture
5556
# bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system
@@ -65,6 +66,7 @@ OBJS = benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o \
6566
### 2.1. General and architecture defaults
6667
optimize = yes
6768
debug = no
69+
sanitize = no
6870
bits = 32
6971
prefetch = no
7072
popcnt = no
@@ -253,13 +255,18 @@ ifneq ($(comp),mingw)
253255
endif
254256
endif
255257

256-
### 3.2 Debugging
258+
### 3.2.1 Debugging
257259
ifeq ($(debug),no)
258260
CXXFLAGS += -DNDEBUG
259261
else
260262
CXXFLAGS += -g
261263
endif
262264

265+
### 3.2.2 Debugging with undefined behavior sanitizers
266+
ifeq ($(sanitize),yes)
267+
CXXFLAGS += -g3 -fsanitize=undefined
268+
endif
269+
263270
### 3.3 Optimization
264271
ifeq ($(optimize),yes)
265272

0 commit comments

Comments
 (0)