diff --git a/engine/src/build/config/BUILDCONFIG.gn b/engine/src/build/config/BUILDCONFIG.gn index b74b2e23738..3e4c1c40da8 100644 --- a/engine/src/build/config/BUILDCONFIG.gn +++ b/engine/src/build/config/BUILDCONFIG.gn @@ -143,6 +143,10 @@ declare_args() { # Compile for Address Sanitizer to find memory bugs. is_asan = false + # Compile with HWAddress Sanitizer to find memory bugs. + # Requires ARM64 hardware + is_hwasan = false + # Compile for Leak Sanitizer to find leaks. is_lsan = false @@ -319,7 +323,7 @@ default_library_type = "static_library" # These Sanitizers all imply using the Clang compiler. On Windows they either # don't work or work differently. -using_sanitizer = !is_win && (is_asan || is_lsan || is_tsan || is_msan) +using_sanitizer = !is_win && (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) if (!is_clang && using_sanitizer) { is_clang = true } @@ -413,7 +417,7 @@ if (symbol_level == -1) { # size is paramount. if (is_debug || (!is_linux && !is_wasm)) { symbol_level = 2 - } else if (is_asan || is_lsan || is_tsan || is_msan) { + } else if (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) { # Sanitizers require symbols for filename suppressions to work. symbol_level = 1 } else { diff --git a/engine/src/build/config/compiler/BUILD.gn b/engine/src/build/config/compiler/BUILD.gn index de15cb053e4..fbd79449b99 100644 --- a/engine/src/build/config/compiler/BUILD.gn +++ b/engine/src/build/config/compiler/BUILD.gn @@ -125,6 +125,10 @@ config("compiler") { cflags += [ "-fsanitize=address" ] ldflags += [ "-fsanitize=address" ] } + if (is_hwasan && is_android && current_cpu == "arm64") { + cflags += [ "-fsanitize=hwaddress" ] + ldflags += [ "-fsanitize=hwaddress" ] + } if (is_lsan) { cflags += [ "-fsanitize=leak" ] ldflags += [ "-fsanitize=leak" ] diff --git a/engine/src/build/config/sanitizers/BUILD.gn b/engine/src/build/config/sanitizers/BUILD.gn index 243f07e1723..ebcd69472b2 100644 --- a/engine/src/build/config/sanitizers/BUILD.gn +++ b/engine/src/build/config/sanitizers/BUILD.gn @@ -10,7 +10,7 @@ import("//build/toolchain/toolchain.gni") # shared_libraries. Unconditionally depend upon this target as it is empty if # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false. group("deps") { - if (is_asan || is_lsan || is_tsan || is_msan) { + if (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) { public_configs = [ ":sanitizer_options_link_helper" ] deps += [ ":options_sources" ] } @@ -24,6 +24,9 @@ config("sanitizer_options_link_helper") { if (is_asan) { ldflags += [ "-fsanitize=address" ] } + if (is_hwasan && is_android && current_cpu == "arm64") { + ldflags += [ "-fsanitize=hwaddress" ] + } if (is_lsan) { ldflags += [ "-fsanitize=leak" ] }