Skip to content

Commit 9cf56fb

Browse files
mralephCommit Queue
authored andcommitted
[vm] Add builtin TSAN suppressions
Sanitizers can pickup configuration and suppressions via special symbols in the binary (e.g. __*_default_suppressions and __*_default_options). We have a bunch of stale files in the buildroot which showed how to do it, but none of these were actually used by the build process. Update our BUILDCONFIG.gn to actually link this code into the binaries and clean it up leaving behind only one relevant suppression for TSAN. Additionally fix libplatform targets - libdart_platform_no_tsan was accidentally disabling TSAN for the whole libplatform by adding no_tsan_config into public_configs instead of extra_configs. This is needed to unblock landing https://dart-review.googlesource.com/c/sdk/+/444983 TEST=manually with the referenced CL to verify that suppressions work Cq-Include-Trybots: luci.dart.try:vm-tsan-linux-release-x64-try,vm-tsan-linux-release-arm64-try Change-Id: Id4e8a5b89c665cf5d89b18c4f5881ef31c3c9396 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445941 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 080af85 commit 9cf56fb

File tree

9 files changed

+33
-667
lines changed

9 files changed

+33
-667
lines changed

build/config/BUILDCONFIG.gn

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ if (current_os == "win") {
259259
use_flutter_cxx =
260260
is_clang && ((is_asan && is_mac) || is_msan || is_tsan || is_ios)
261261

262+
using_sanitizer = !is_win && (is_asan || is_hwasan || is_lsan || is_msan ||
263+
is_tsan || is_ubsan)
264+
262265
# =============================================================================
263266
# TARGET DEFAULTS
264267
# =============================================================================
@@ -511,6 +514,7 @@ foreach(_target_type,
511514
deps = []
512515
}
513516
if (!defined(invoker.no_default_deps) || !invoker.no_default_deps) {
517+
deps += [ "//build/config/sanitizers:deps" ]
514518
if (use_flutter_cxx) {
515519
deps += [ "//third_party/libcxx" ]
516520
}
@@ -653,7 +657,7 @@ if (!is_shared_library) {
653657
if (!defined(deps)) {
654658
deps = []
655659
}
656-
660+
deps += [ "//build/config/sanitizers:deps" ]
657661
if (use_flutter_cxx) {
658662
deps += [ "//third_party/libcxx" ]
659663
}

build/config/compiler/BUILD.gn

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ config("default_include_dirs") {
3838
]
3939
}
4040

41-
if (!is_win) {
42-
using_sanitizer =
43-
is_asan || is_hwasan || is_lsan || is_msan || is_tsan || is_ubsan
44-
}
45-
4641
# compiler ---------------------------------------------------------------------
4742
#
4843
# Base compiler configuration.

build/config/sanitizers/BUILD.gn

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,23 @@ import("//build/config/sanitizers/sanitizers.gni")
66

77
# Contains the dependencies needed for sanitizers to link into executables and
88
# shared_libraries. Unconditionally depend upon this target as it is empty if
9-
# |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false.
9+
# |using_sanitizer| is false.
1010
group("deps") {
11-
deps = [ "//third_party/instrumented_libraries:deps" ]
12-
if (is_asan || is_hwasan || is_lsan || is_msan || is_tsan || is_ubsan) {
11+
if (using_sanitizer) {
1312
public_configs = [ ":sanitizer_options_link_helper" ]
14-
deps += [ ":options_sources" ]
15-
}
16-
if (use_custom_libcxx) {
17-
deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ]
13+
deps = [ ":options_sources" ]
1814
}
1915
}
2016

2117
config("sanitizer_options_link_helper") {
2218
ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]
23-
if (is_asan) {
24-
ldflags += [ "-fsanitize=address" ]
25-
}
26-
if (is_hwasan && is_android && current_cpu == "arm64") {
27-
ldflags += [ "-fsanitize=hwaddress" ]
28-
}
29-
if (is_lsan) {
30-
ldflags += [ "-fsanitize=leak" ]
31-
}
32-
if (is_msan) {
33-
ldflags += [ "-fsanitize=memory" ]
34-
}
35-
if (is_tsan) {
36-
ldflags += [ "-fsanitize=thread" ]
37-
}
38-
if (is_ubsan) {
39-
ldflags += [
40-
"-fsanitize=undefined",
41-
"-fsanitize=float-divide-by-zero",
42-
"-fsanitize=float-cast-overflow",
43-
]
44-
}
4519
}
4620

4721
source_set("options_sources") {
4822
visibility = [
4923
":deps",
5024
"//:gn_visibility",
5125
]
26+
include_dirs = [ "../../../runtime" ]
5227
sources = [ "//build/sanitizers/sanitizer_options.cc" ]
53-
54-
if (is_asan) {
55-
sources += [ "//build/sanitizers/asan_suppressions.cc" ]
56-
}
57-
58-
if (is_lsan) {
59-
sources += [ "//build/sanitizers/lsan_suppressions.cc" ]
60-
}
61-
62-
if (is_tsan) {
63-
sources += [ "//build/sanitizers/tsan_suppressions.cc" ]
64-
}
6528
}

build/sanitizers/BUILD.gn

Lines changed: 0 additions & 16 deletions
This file was deleted.

build/sanitizers/asan_suppressions.cc

Lines changed: 0 additions & 23 deletions
This file was deleted.

build/sanitizers/lsan_suppressions.cc

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)