Adds ability to build for asan with gn
BUG=none TEST=none R=brettw@chromium.org Review URL: https://codereview.chromium.org/682843002 Cr-Original-Commit-Position: refs/heads/master@{#301751} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: fec68221196ae74b73f6c7a4c574bd33666bb7ed
This commit is contained in:
Родитель
33c6e6d12d
Коммит
59039fcb01
|
@ -121,6 +121,13 @@ config("feature_flags") {
|
|||
if (use_allocator != "tcmalloc") {
|
||||
defines += [ "NO_TCMALLOC" ]
|
||||
}
|
||||
if (is_asan) {
|
||||
defines += [
|
||||
"ADDRESS_SANITIZER",
|
||||
"MEMORY_TOOL_REPLACES_ALLOCATOR",
|
||||
"MEMORY_SANITIZER_INITIAL_SIZE",
|
||||
]
|
||||
}
|
||||
if (enable_webrtc) {
|
||||
defines += [ "ENABLE_WEBRTC=1" ]
|
||||
}
|
||||
|
|
|
@ -568,7 +568,13 @@ template("component") {
|
|||
if (defined(invoker.data)) { data = invoker.data }
|
||||
if (defined(invoker.datadeps)) { datadeps = invoker.datadeps }
|
||||
if (defined(invoker.defines)) { defines = invoker.defines }
|
||||
if (defined(invoker.deps)) { deps = invoker.deps }
|
||||
# All shared libraries must have the sanitizer deps to properly link in
|
||||
# asan mode (this target will be empty in other cases).
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps + [ "//build/config/sanitizers:deps" ]
|
||||
} else {
|
||||
deps = [ "//build/config/sanitizers:deps" ]
|
||||
}
|
||||
if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs }
|
||||
if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from }
|
||||
if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs }
|
||||
|
@ -691,7 +697,13 @@ template("test") {
|
|||
if (defined(invoker.data)) { data = invoker.data }
|
||||
if (defined(invoker.datadeps)) { datadeps = invoker.datadeps }
|
||||
if (defined(invoker.defines)) { defines = invoker.defines }
|
||||
if (defined(invoker.deps)) { deps = invoker.deps }
|
||||
# All shared libraries must have the sanitizer deps to properly link in
|
||||
# asan mode (this target will be empty in other cases).
|
||||
if (defined(invoker.deps)) {
|
||||
deps = invoker.deps + [ "//build/config/sanitizers:deps" ]
|
||||
} else {
|
||||
deps = [ "//build/config/sanitizers:deps" ]
|
||||
}
|
||||
if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs = invoker.direct_dependent_configs }
|
||||
if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_configs_from = invoker.forward_dependent_configs_from }
|
||||
if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
if (is_android || cpu_arch == "mipsel" || is_mac) {
|
||||
if (is_android || cpu_arch == "mipsel" || is_mac || is_asan) {
|
||||
_default_allocator = "none"
|
||||
} else {
|
||||
_default_allocator = "tcmalloc"
|
||||
|
|
|
@ -45,6 +45,9 @@ config("default_include_dirs") {
|
|||
]
|
||||
}
|
||||
|
||||
# TODO(GYP): is_ubsan, is_ubsan_vptr
|
||||
using_sanitizer = is_asan || is_lsan || is_tsan || is_msan
|
||||
|
||||
# compiler ---------------------------------------------------------------------
|
||||
#
|
||||
# Base compiler configuration.
|
||||
|
@ -103,6 +106,22 @@ config("compiler") {
|
|||
# TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
|
||||
ldflags += [ "-Wl,--fatal-warnings" ]
|
||||
}
|
||||
|
||||
# Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
|
||||
# MemorySanitizer
|
||||
if (using_sanitizer) {
|
||||
cflags += [
|
||||
"-fno-omit-frame-pointer",
|
||||
"-gline-tables-only",
|
||||
]
|
||||
}
|
||||
if (is_asan) {
|
||||
cflags += [ "-fsanitize=address" ]
|
||||
if (is_mac) {
|
||||
cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073
|
||||
# TODO(GYP): deal with mac_bundles.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_clang && is_debug) {
|
||||
|
@ -814,9 +833,9 @@ if (is_win) {
|
|||
common_optimize_on_ldflags = []
|
||||
|
||||
if (is_android) {
|
||||
common_optimize_on_cflags += [
|
||||
"-fomit-frame-pointer",
|
||||
]
|
||||
if (!using_sanitizer) {
|
||||
common_optimize_on_cflags += [ "-fomit-frame-pointer" ]
|
||||
}
|
||||
common_optimize_on_ldflags += [
|
||||
# Warn in case of text relocations.
|
||||
"-Wl,--warn-shared-textrel",
|
||||
|
@ -874,10 +893,12 @@ config("no_optimize") {
|
|||
# much even when optimization is disabled to get the binary size down.
|
||||
cflags = [
|
||||
"-Os",
|
||||
"-fomit-frame-pointer",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
]
|
||||
if (!using_sanitizer) {
|
||||
cflags += [ "-fomit-frame-pointer" ]
|
||||
}
|
||||
ldflags = common_optimize_on_ldflags
|
||||
} else {
|
||||
cflags = [ "-O0" ]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Contains the dependencies needed for asan to link into executables and
|
||||
# shared_libraries. Unconditionally depend upon this target as it is empty if
|
||||
# |is_asan| is false.
|
||||
group("deps") {
|
||||
if (is_asan) {
|
||||
public_configs = [ ":sanitizer_options_link_helper" ]
|
||||
deps = [ ":options_sources" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("sanitizer_options_link_helper") {
|
||||
ldflags = [ "-Wl,-u_sanitizer_options_link_helper", "-fsanitize=address" ]
|
||||
}
|
||||
|
||||
source_set("options_sources") {
|
||||
visibility = [ ":deps" ]
|
||||
sources = [ "//build/sanitizers/sanitizer_options.cc" ]
|
||||
|
||||
if (is_tsan) {
|
||||
sources += [ "//build/sanitizers/tsan_suppressions.cc" ]
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче