summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-07-13 16:14:54 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-07-13 16:14:54 -0700
commit757e9874be785ef23980034b41c91c7d9db55661 (patch)
tree6406257b717bc7dcd02fe3051cc28bd62d56136c
parentMerge branch 'sb/pull-rebase-submodule' (diff)
parentMakefile: disable unaligned loads with UBSan (diff)
downloadtgif-757e9874be785ef23980034b41c91c7d9db55661.tar.xz
Merge branch 'jk/build-with-asan'
The build procedure has been improved to allow building and testing Git with address sanitizer more easily. * jk/build-with-asan: Makefile: disable unaligned loads with UBSan Makefile: turn off -fomit-frame-pointer with sanitizers Makefile: add helper for compiling with -fsanitize test-lib: turn on ASan abort_on_error by default test-lib: set ASAN_OPTIONS variable before we run git
-rw-r--r--Makefile8
-rw-r--r--t/test-lib.sh11
2 files changed, 16 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index bfa5b3a4ca..ba4359ef8d 100644
--- a/Makefile
+++ b/Makefile
@@ -1022,6 +1022,14 @@ ifdef DEVELOPER
CFLAGS += $(DEVELOPER_CFLAGS)
endif
+ifdef SANITIZE
+BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
+BASIC_CFLAGS += -fno-omit-frame-pointer
+ifeq ($(SANITIZE),undefined)
+BASIC_CFLAGS += -DNO_UNALIGNED_LOADS
+endif
+endif
+
ifndef sysconfdir
ifeq ($(prefix),/usr)
sysconfdir = /etc
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 2306574dc9..1b6e53f78a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -36,6 +36,14 @@ then
fi
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+# If we were built with ASAN, it may complain about leaks
+# of program-lifetime variables. Disable it by default to lower
+# the noise level. This needs to happen at the start of the script,
+# before we even do our "did we build git yet" check (since we don't
+# want that one to complain to stderr).
+: ${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1}
+export ASAN_OPTIONS
+
################################################################
# It appears that people try to run tests without building...
"$GIT_BUILD_DIR/git" >/dev/null
@@ -148,9 +156,6 @@ else
}
fi
-: ${ASAN_OPTIONS=detect_leaks=0}
-export ASAN_OPTIONS
-
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
unset CDPATH