Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Introduce --with-lsan configure flag that enables LeakSanitizer.
Gleb Popov committed 2 years ago
commit c1a699cb3c200bff526a61702353356d8f59a625
parent 48f2604
2 files changed +17 -2
modified auto.def
@@ -17,6 +17,7 @@ options {
	with-libarchive.pc => "build with libarchive getting flags via pc files"
	with-coverage => "build with llvm coverage support"
	with-asan => "build with libasan support"
+
	with-lsan => "build with liblsan support"
	with-ubsan => "Build with libubsan support"
	default-format:txz => "Default compression format: tzst, txz (default), tbz, tar"
}
@@ -273,7 +274,7 @@ cc-with { -libs { -ljail} } {
cc-check-includes bsd/err.h bsd/libutil.h bsd/readpassphrase.h \
	bsd/stdio.h bsd/stdlib.h bsd/strlib.h bsd/string.h \
	bsd/sys/cdefs.h bsd/sys/queue.h bsd/unistd.h
-
 
+

if {[opt-bool with-asan]} {
	define-append ASAN_CFLAGS -O0 -ggdb -fsanitize=address
	define-append ASAN_LDFLAGS -fsanitize=address
@@ -284,6 +285,15 @@ if {[opt-bool with-asan]} {
	define asan 1
	undefine HAVE_STATIC
}
+
if {[opt-bool with-lsan]} {
+
	define-append LSAN_CFLAGS -O0 -ggdb -fsanitize=leak
+
	define-append LSAN_LDFLAGS -fsanitize=leak
+
	if {[string match *-linux* [get-define host]]} {
+
		# LSAN depends on libdl for dlsym when building with GCC
+
		define-append LSAN_LDFLAGS -ldl
+
	}
+
	define lsan 1
+
}
if {[opt-bool with-ubsan]} {
	# Avoid alignment error when building with UBSan inside _mum_hash_avx2
	define-append UBSAN_CFLAGS -D_MUM_UNALIGNED_ACCESS=0
@@ -298,7 +308,7 @@ if {[opt-bool with-coverage]} {
# disable capsicum when coverage is used because coverage does not work in
# capsicum mode
} else {
-
# capsicum 
+
# capsicum
	if {[cc-check-functions cap_sandboxed]} {
		define-feature capsicum
			cc-check-includes sys/capsicum.h
modified mk/defs.mk.in
@@ -11,6 +11,11 @@ CFLAGS+= @ASAN_CFLAGS@
LDFLAGS+=	@ASAN_LDFLAGS@
SH_LDFLAGS+=	@ASAN_LDFLAGS@
@endif
+
@if lsan
+
CFLAGS+=	@LSAN_CFLAGS@
+
LDFLAGS+=	@LSAN_LDFLAGS@
+
SH_LDFLAGS+=	@LSAN_LDFLAGS@
+
@endif
@if ubsan
CFLAGS+=	@UBSAN_CFLAGS@
LDFLAGS+=	@UBSAN_LDFLAGS@