diff options
author | Brian Smith <brian@dbsoft.org> | 2023-08-14 23:40:46 -0500 |
---|---|---|
committer | Brian Smith <brian@dbsoft.org> | 2023-08-14 23:40:46 -0500 |
commit | ff81f4969c4c6394e9553fdcd442a5ea21e8a7b1 (patch) | |
tree | 0718566851ff969dbb9cb233fe58ca083147bfaa | |
parent | 369ba2e7d6dd91328e1e83a037daadf8f4b497f4 (diff) | |
download | uxp-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.m4 | 34 | ||||
-rw-r--r-- | build/moz.build | 2 | ||||
-rw-r--r-- | build/moz.configure/old.configure | 2 |
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', |