Skip to content

Commit ca758ac

Browse files
Add buildroot compatibility for HWASAN. (flutter#167133)
Needed to roll https://dart-review.googlesource.com/c/sdk/+/421180.
1 parent 8703147 commit ca758ac

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

engine/src/build/config/BUILDCONFIG.gn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ declare_args() {
143143
# Compile for Address Sanitizer to find memory bugs.
144144
is_asan = false
145145

146+
# Compile with HWAddress Sanitizer to find memory bugs.
147+
# Requires ARM64 hardware
148+
is_hwasan = false
149+
146150
# Compile for Leak Sanitizer to find leaks.
147151
is_lsan = false
148152

@@ -319,7 +323,7 @@ default_library_type = "static_library"
319323

320324
# These Sanitizers all imply using the Clang compiler. On Windows they either
321325
# don't work or work differently.
322-
using_sanitizer = !is_win && (is_asan || is_lsan || is_tsan || is_msan)
326+
using_sanitizer = !is_win && (is_asan || is_hwasan || is_lsan || is_tsan || is_msan)
323327
if (!is_clang && using_sanitizer) {
324328
is_clang = true
325329
}
@@ -413,7 +417,7 @@ if (symbol_level == -1) {
413417
# size is paramount.
414418
if (is_debug || (!is_linux && !is_wasm)) {
415419
symbol_level = 2
416-
} else if (is_asan || is_lsan || is_tsan || is_msan) {
420+
} else if (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) {
417421
# Sanitizers require symbols for filename suppressions to work.
418422
symbol_level = 1
419423
} else {

engine/src/build/config/compiler/BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ config("compiler") {
125125
cflags += [ "-fsanitize=address" ]
126126
ldflags += [ "-fsanitize=address" ]
127127
}
128+
if (is_hwasan && is_android && current_cpu == "arm64") {
129+
cflags += [ "-fsanitize=hwaddress" ]
130+
ldflags += [ "-fsanitize=hwaddress" ]
131+
}
128132
if (is_lsan) {
129133
cflags += [ "-fsanitize=leak" ]
130134
ldflags += [ "-fsanitize=leak" ]

engine/src/build/config/sanitizers/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import("//build/toolchain/toolchain.gni")
1010
# shared_libraries. Unconditionally depend upon this target as it is empty if
1111
# |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false.
1212
group("deps") {
13-
if (is_asan || is_lsan || is_tsan || is_msan) {
13+
if (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) {
1414
public_configs = [ ":sanitizer_options_link_helper" ]
1515
deps += [ ":options_sources" ]
1616
}
@@ -24,6 +24,9 @@ config("sanitizer_options_link_helper") {
2424
if (is_asan) {
2525
ldflags += [ "-fsanitize=address" ]
2626
}
27+
if (is_hwasan && is_android && current_cpu == "arm64") {
28+
ldflags += [ "-fsanitize=hwaddress" ]
29+
}
2730
if (is_lsan) {
2831
ldflags += [ "-fsanitize=leak" ]
2932
}

0 commit comments

Comments
 (0)