summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-08-14 23:40:46 -0500
committerBrian Smith <brian@dbsoft.org>2023-08-14 23:40:46 -0500
commitff81f4969c4c6394e9553fdcd442a5ea21e8a7b1 (patch)
tree0718566851ff969dbb9cb233fe58ca083147bfaa
parent369ba2e7d6dd91328e1e83a037daadf8f4b497f4 (diff)
downloaduxp-ff81f4969c4c6394e9553fdcd442a5ea21e8a7b1.tar.gz
Issue #2266 - Part 2 - Add Leak and Undefined Behavior Sanitizer support.
Also fix building on FreeBSD and Linux, from the previous commit.
-rw-r--r--build/autoconf/sanitize.m434
-rw-r--r--build/moz.build2
-rw-r--r--build/moz.configure/old.configure2
3 files changed, 37 insertions, 1 deletions
diff --git a/build/autoconf/sanitize.m4 b/build/autoconf/sanitize.m4
index 8b18cd5bc7..4f038ccb6f 100644
--- a/build/autoconf/sanitize.m4
+++ b/build/autoconf/sanitize.m4
@@ -80,6 +80,40 @@ if test -n "$MOZ_TSAN"; then
fi
AC_SUBST(MOZ_TSAN)
+dnl ========================================================
+dnl = Use Leak Sanitizer
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(leak-sanitizer,
+[ --enable-leak-sanitizer Enable Leak Sanitizer (default=no)],
+ MOZ_LSAN=1,
+ MOZ_LSAN= )
+if test -n "$MOZ_LSAN"; then
+ MOZ_LLVM_HACKS=1
+ LDFLAGS="-fsanitize=leak $LDFLAGS"
+ AC_DEFINE(MOZ_LSAN)
+ MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
+fi
+AC_SUBST(MOZ_LSAN)
+
+dnl ========================================================
+dnl = Use Undefined Behavior Sanitizer
+dnl ========================================================
+MOZ_ARG_ENABLE_BOOL(undefined-sanitizer,
+[ --enable-undefined-sanitizer Enable Undefined Behavior Sanitizer (default=no)],
+ MOZ_UBSAN=1,
+ MOZ_UBSAN= )
+if test -n "$MOZ_UBSAN"; then
+ MOZ_LLVM_HACKS=1
+ CFLAGS="-fsanitize=undefined $CFLAGS"
+ CXXFLAGS="-fsanitize=undefined $CXXFLAGS"
+ if test -z "$CLANG_CL"; then
+ LDFLAGS="-fsanitize=undefined $LDFLAGS"
+ fi
+ AC_DEFINE(MOZ_UBSAN)
+ MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
+fi
+AC_SUBST(MOZ_UBSAN)
+
# The LLVM symbolizer is used by all sanitizers
AC_SUBST(LLVM_SYMBOLIZER)
diff --git a/build/moz.build b/build/moz.build
index f3801976eb..1f1c7474cd 100644
--- a/build/moz.build
+++ b/build/moz.build
@@ -62,7 +62,7 @@ OBJDIR_FILES += ['!/dist/bin/.gdbinit_python']
if CONFIG['MOZ_ASAN'] and CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']:
FINAL_TARGET_FILES += [CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']]
if CONFIG['LLVM_SYMBOLIZER']:
- FINAL_TARGET_FILES += [CONFIG['LLVM_SYMBOLIZER']]
+ FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']]
if CONFIG['MOZ_APP_BASENAME']:
FINAL_TARGET_PP_FILES += ['application.ini']
diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure
index 3d3873eae8..091efc398d 100644
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -197,6 +197,7 @@ def old_configure_options(*options):
'--enable-ios-target',
'--enable-jitspew',
'--enable-js-lto',
+ '--enable-leak-sanitizer',
'--enable-libjpeg-turbo',
'--enable-libproxy',
'--enable-llvm-hacks',
@@ -246,6 +247,7 @@ def old_configure_options(*options):
'--enable-thread-sanitizer',
'--enable-trace-logging',
'--enable-ui-locale',
+ '--enable-undefined-sanitizer',
'--enable-universalchardet',
'--enable-updater',
'--enable-url-classifier',