Add buildroot compatibility for HWASAN. (#167133)

Needed to roll https://dart-review.googlesource.com/c/sdk/+/421180.
This commit is contained in:
Ryan Macnak 2025-04-14 17:56:07 -07:00 committed by GitHub
parent 8703147add
commit ca758ac49b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -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 {

View File

@ -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" ]

View File

@ -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" ]
}