Partition libcxx build code from build/config/sanitizers

This CL:
* Removes the last dependency on sanitizers:deps_no_options and replaces it
  with exe_and_shlib_deps
* Merges sanitizers:deps and sanitizers:deps_no_options
* Adds a weak symbol for NaCl to override the default sanitizer options

BUG=593874
R=thakis@chromium.org,bradnelson@chromium.org
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_msan_rel_ng;master.tryserver.chromium.linux:linux_chromium_ubsan_rel_ng;master.tryserver.chromium.mac:mac_chromium_asan_rel_ng

Review-Url: https://codereview.chromium.org/2911513002
Cr-Original-Commit-Position: refs/heads/master@{#475093}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f59081471b68cb0a0c484fe9c9c3b8a1f7f2d122
This commit is contained in:
thomasanderson 2017-05-26 13:01:39 -07:00 коммит произвёл Commit bot
Родитель e2e8f8926d
Коммит 358b868b28
3 изменённых файлов: 28 добавлений и 51 удалений

Просмотреть файл

@ -264,13 +264,17 @@ config("default_libs") {
}
# Dependencies that all executables and shared libraries should have.
# All targets that currently depend on //build/config/sanitizers:deps
# are being made to depend on this target instead
# (https://crbug.com/723069).
group("exe_and_shlib_deps") {
public_deps = [
"//build/config/sanitizers:deps",
]
public_deps = []
if (using_sanitizer) {
public_deps += [ "//build/config/sanitizers:deps" ]
}
if (use_custom_libcxx) {
public_deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ]
}
if (use_afl) {
public_deps += [ "//third_party/afl" ]
}
}
# Executable configs -----------------------------------------------------------

Просмотреть файл

@ -18,9 +18,6 @@ if (is_ios) {
# "//build/config:exe_and_shlib_deps" to pull in this target.
group("deps") {
visibility = [ "//build/config:exe_and_shlib_deps" ]
public_deps = [
":deps_no_options",
]
if (using_sanitizer) {
public_configs = [
":sanitizer_options_link_helper",
@ -33,32 +30,15 @@ group("deps") {
deps = [
":options_sources",
]
}
if (use_afl) {
deps += [ "//third_party/afl" ]
}
}
group("deps_no_options") {
if (using_sanitizer) {
public_configs = [
# Even when a target removes default_sanitizer_flags, it may be depending
# on a library that did not remove default_sanitizer_flags. Thus, we need
# to add the ldflags here as well as in default_sanitizer_flags.
":default_sanitizer_ldflags",
]
deps = []
public_deps = []
data = [
"//tools/valgrind/asan/",
]
if (is_win) {
exe = ".exe"
} else {
exe = ""
}
data += [ "$clang_base_path/bin/llvm-symbolizer${exe}" ]
data = [
"//tools/valgrind/asan/",
"$clang_base_path/bin/llvm-symbolizer${exe}",
]
if (is_linux) {
# llvm-symbolizer needs this.
data += [ "$clang_base_path/lib/libstdc++.so.6" ]
@ -68,10 +48,6 @@ group("deps_no_options") {
use_locally_built_instrumented_libraries) {
deps += [ "//third_party/instrumented_libraries:deps" ]
}
if (use_custom_libcxx) {
public_deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ]
data += [ "$root_out_dir/libc++.so" ]
}
# ASAN is supported on iOS but the runtime library depends on the compiler
# used (Chromium version of clang versus Xcode version of clang). Only copy
@ -82,7 +58,9 @@ group("deps_no_options") {
]
}
if (is_mac || (is_ios && !use_xcode_clang)) {
public_deps += [ ":asan_runtime_bundle_data" ]
public_deps = [
":asan_runtime_bundle_data",
]
}
}
}
@ -275,7 +253,6 @@ config("default_sanitizer_ldflags") {
config("common_sanitizer_flags") {
cflags = []
cflags_cc = []
# Sanitizers need line table info for stack traces. They don't need type info
# or variable info, so we can leave that out to speed up the build (unless
@ -303,11 +280,14 @@ config("common_sanitizer_flags") {
cflags += [ "/Oy-" ]
}
}
}
# TODO(thomasanderson): Move this out of build/config/sanitizers.
config("libcxx_flags") {
if (use_custom_libcxx) {
prefix = "//buildtools/third_party"
include = "trunk/include"
cflags_cc += [
cflags_cc = [
"-nostdinc++",
"-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
"-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
@ -558,6 +538,7 @@ config("fuzzing_build_mode") {
all_sanitizer_configs = [
":common_sanitizer_flags",
":libcxx_flags",
":coverage_flags",
":default_sanitizer_ldflags",
":asan_flags",

Просмотреть файл

@ -82,24 +82,16 @@ const char *kAsanDefaultOptions =
"check_printf=1 use_sigaltstack=1 "
"strip_path_prefix=/../../ fast_unwind_on_fatal=1 "
"detect_stack_use_after_return=1 detect_odr_violation=0 ";
static const char kNaClDefaultOptions[] = "handle_segv=0";
static const char kNaClFlag[] = "--type=nacl-loader";
#endif // OS_LINUX
#if defined(OS_LINUX) || defined(OS_MACOSX)
// Allow NaCl to override the default asan options.
extern const char* kAsanDefaultOptionsNaCl;
__attribute__((weak)) const char* kAsanDefaultOptionsNaCl = nullptr;
SANITIZER_HOOK_ATTRIBUTE const char *__asan_default_options() {
#if defined(OS_MACOSX)
char*** argvp = _NSGetArgv();
int* argcp = _NSGetArgc();
if (!argvp || !argcp) return kAsanDefaultOptions;
char** argv = *argvp;
int argc = *argcp;
for (int i = 0; i < argc; ++i) {
if (strcmp(argv[i], kNaClFlag) == 0) {
return kNaClDefaultOptions;
}
}
#endif
if (kAsanDefaultOptionsNaCl)
return kAsanDefaultOptionsNaCl;
return kAsanDefaultOptions;
}