Add buildroot compatibility for HWASAN. (#167133)
Needed to roll https://dart-review.googlesource.com/c/sdk/+/421180.
diff --git a/engine/src/build/config/BUILDCONFIG.gn b/engine/src/build/config/BUILDCONFIG.gn
index b74b2e23..3e4c1c4 100644
--- a/engine/src/build/config/BUILDCONFIG.gn
+++ b/engine/src/build/config/BUILDCONFIG.gn
@@ -143,6 +143,10 @@
# 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 @@
# 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 @@
# 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 de15cb0..fbd7944 100644
--- a/engine/src/build/config/compiler/BUILD.gn
+++ b/engine/src/build/config/compiler/BUILD.gn
@@ -125,6 +125,10 @@
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 243f07e..ebcd694 100644
--- a/engine/src/build/config/sanitizers/BUILD.gn
+++ b/engine/src/build/config/sanitizers/BUILD.gn
@@ -10,7 +10,7 @@
# 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 @@
if (is_asan) {
ldflags += [ "-fsanitize=address" ]
}
+ if (is_hwasan && is_android && current_cpu == "arm64") {
+ ldflags += [ "-fsanitize=hwaddress" ]
+ }
if (is_lsan) {
ldflags += [ "-fsanitize=leak" ]
}