Commit f51e7812 authored by sammc's avatar sammc Committed by Commit bot

GN: Implement is_lsan, is_tsan and is_msan.

Review URL: https://codereview.chromium.org/1134003008

Cr-Commit-Position: refs/heads/master@{#330710}
parent a0d7e3c8
...@@ -136,13 +136,31 @@ config("feature_flags") { ...@@ -136,13 +136,31 @@ config("feature_flags") {
if (use_allocator != "tcmalloc") { if (use_allocator != "tcmalloc") {
defines += [ "NO_TCMALLOC" ] defines += [ "NO_TCMALLOC" ]
} }
if (is_asan) { if (is_asan || is_lsan || is_tsan || is_msan) {
defines += [ defines += [
"ADDRESS_SANITIZER",
"MEMORY_TOOL_REPLACES_ALLOCATOR", "MEMORY_TOOL_REPLACES_ALLOCATOR",
"MEMORY_SANITIZER_INITIAL_SIZE", "MEMORY_SANITIZER_INITIAL_SIZE",
] ]
} }
if (is_asan) {
defines += [ "ADDRESS_SANITIZER" ]
}
if (is_lsan) {
defines += [
"LEAK_SANITIZER",
"WTF_USE_LEAK_SANITIZER=1",
]
}
if (is_tsan) {
defines += [
"THREAD_SANITIZER",
"DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
"WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
]
}
if (is_msan) {
defines += [ "MEMORY_SANITIZER" ]
}
if (enable_webrtc) { if (enable_webrtc) {
defines += [ "ENABLE_WEBRTC=1" ] defines += [ "ENABLE_WEBRTC=1" ]
} }
...@@ -287,7 +305,12 @@ config("release") { ...@@ -287,7 +305,12 @@ config("release") {
# Sanitizers. # Sanitizers.
# TODO(GYP) The GYP build has "release_valgrind_build == 0" for this # TODO(GYP) The GYP build has "release_valgrind_build == 0" for this
# condition. When Valgrind is set up, we need to do the same here. # condition. When Valgrind is set up, we need to do the same here.
if (!is_tsan) { if (is_tsan) {
defines += [
"DYNAMIC_ANNOTATIONS_ENABLED=1",
"WTF_USE_DYNAMIC_ANNOTATIONS=1",
]
} else {
defines += [ "NVALGRIND" ] defines += [ "NVALGRIND" ]
if (!is_nacl) { if (!is_nacl) {
# NaCl always enables dynamic annotations. Currently this value is set to # NaCl always enables dynamic annotations. Currently this value is set to
......
...@@ -373,6 +373,9 @@ if (symbol_level == -1) { ...@@ -373,6 +373,9 @@ if (symbol_level == -1) {
# Mac and Windows have them separate, so in Release Linux, default them off. # Mac and Windows have them separate, so in Release Linux, default them off.
if (is_debug || !is_linux) { if (is_debug || !is_linux) {
symbol_level = 2 symbol_level = 2
} else if (is_asan || is_lsan || is_tsan || is_msan) {
# Sanitizers require symbols for filename suppressions to work.
symbol_level = 1
} else { } else {
symbol_level = 0 symbol_level = 0
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# TODO(GYP): Make tcmalloc work on win. # TODO(GYP): Make tcmalloc work on win.
if (is_android || current_cpu == "mipsel" || is_mac || is_ios || is_asan || if (is_android || current_cpu == "mipsel" || is_mac || is_ios || is_asan ||
is_win) { is_lsan || is_tsan || is_msan || is_win) {
_default_allocator = "none" _default_allocator = "none"
} else { } else {
_default_allocator = "tcmalloc" _default_allocator = "tcmalloc"
......
...@@ -56,6 +56,11 @@ declare_args() { ...@@ -56,6 +56,11 @@ declare_args() {
# The patch is preapplied to the internal toolchain and hence all bots. # The patch is preapplied to the internal toolchain and hence all bots.
msvs_xtree_patched = false msvs_xtree_patched = false
} }
# Track where uninitialized memory originates from. From fastest to slowest:
# 0 - no tracking, 1 - track only the initial allocation site, 2 - track the
# chain of stores leading from allocation site to use site.
msan_track_origins = 2
} }
# default_include_dirs --------------------------------------------------------- # default_include_dirs ---------------------------------------------------------
...@@ -139,12 +144,39 @@ config("compiler") { ...@@ -139,12 +144,39 @@ config("compiler") {
] ]
} }
if (is_asan) { if (is_asan) {
cflags += [ "-fsanitize=address" ] asan_blacklist_path =
rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir)
cflags += [
"-fsanitize=address",
"-fsanitize-blacklist=$asan_blacklist_path",
]
if (is_mac) { if (is_mac) {
cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073 cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073
# TODO(GYP): deal with mac_bundles. # TODO(GYP): deal with mac_bundles.
} }
} }
if (is_lsan) {
cflags += [ "-fsanitize=leak" ]
}
if (is_tsan) {
tsan_blacklist_path =
rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
cflags += [
"-fsanitize=thread",
"-fsanitize-blacklist=$tsan_blacklist_path",
]
}
if (is_msan) {
msan_blacklist_path =
rebase_path("//tools/msan/blacklist.txt", root_build_dir)
cflags += [
"-fsanitize=memory",
"-fsanitize-memory-track-origins=$msan_track_origins",
"-fsanitize-blacklist=$msan_blacklist_path",
]
# TODO(GYP): Support instrumented libraries and custom libc++.
}
} }
if (is_clang && is_debug) { if (is_clang && is_debug) {
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Contains the dependencies needed for asan to link into executables and # Contains the dependencies needed for sanitizers to link into executables and
# shared_libraries. Unconditionally depend upon this target as it is empty if # shared_libraries. Unconditionally depend upon this target as it is empty if
# |is_asan| is false. # |is_asan|, |is_lsan|, |is_tsan| and |is_msan| are false.
group("deps") { group("deps") {
if (is_asan) { if (is_asan || is_lsan || is_tsan || is_msan) {
public_configs = [ ":sanitizer_options_link_helper" ] public_configs = [ ":sanitizer_options_link_helper" ]
deps = [ deps = [
":options_sources", ":options_sources",
...@@ -15,10 +15,19 @@ group("deps") { ...@@ -15,10 +15,19 @@ group("deps") {
} }
config("sanitizer_options_link_helper") { config("sanitizer_options_link_helper") {
ldflags = [ ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]
"-Wl,-u_sanitizer_options_link_helper", if (is_asan) {
"-fsanitize=address", ldflags += [ "-fsanitize=address" ]
] }
if (is_lsan) {
ldflags += [ "-fsanitize=leak" ]
}
if (is_tsan) {
ldflags += [ "-fsanitize=thread" ]
}
if (is_msan) {
ldflags += [ "-fsanitize=memory" ]
}
} }
source_set("options_sources") { source_set("options_sources") {
...@@ -34,6 +43,10 @@ source_set("options_sources") { ...@@ -34,6 +43,10 @@ source_set("options_sources") {
sources += [ "//build/sanitizers/asan_suppressions.cc" ] sources += [ "//build/sanitizers/asan_suppressions.cc" ]
} }
if (is_lsan) {
sources += [ "//build/sanitizers/lsan_suppressions.cc" ]
}
if (is_tsan) { if (is_tsan) {
sources += [ "//build/sanitizers/tsan_suppressions.cc" ] sources += [ "//build/sanitizers/tsan_suppressions.cc" ]
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment