提交 757e9874 编写于 作者: J Junio C Hamano

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
...@@ -1022,6 +1022,14 @@ ifdef DEVELOPER ...@@ -1022,6 +1022,14 @@ ifdef DEVELOPER
CFLAGS += $(DEVELOPER_CFLAGS) CFLAGS += $(DEVELOPER_CFLAGS)
endif 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 ifndef sysconfdir
ifeq ($(prefix),/usr) ifeq ($(prefix),/usr)
sysconfdir = /etc sysconfdir = /etc
......
...@@ -36,6 +36,14 @@ then ...@@ -36,6 +36,14 @@ then
fi fi
GIT_BUILD_DIR="$TEST_DIRECTORY"/.. 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... # It appears that people try to run tests without building...
"$GIT_BUILD_DIR/git" >/dev/null "$GIT_BUILD_DIR/git" >/dev/null
...@@ -148,9 +156,6 @@ else ...@@ -148,9 +156,6 @@ else
} }
fi fi
: ${ASAN_OPTIONS=detect_leaks=0}
export ASAN_OPTIONS
# Protect ourselves from common misconfiguration to export # Protect ourselves from common misconfiguration to export
# CDPATH into the environment # CDPATH into the environment
unset CDPATH unset CDPATH
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册