OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build_overrides/build.gni") | 5 import("//build_overrides/build.gni") |
6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
7 import("//build/config/chromecast_build.gni") | 7 import("//build/config/chromecast_build.gni") |
8 import("//build/config/clang/clang.gni") | 8 import("//build/config/clang/clang.gni") |
9 import("//build/config/sanitizers/sanitizers.gni") | 9 import("//build/config/sanitizers/sanitizers.gni") |
10 import("//build/toolchain/toolchain.gni") | 10 import("//build/toolchain/toolchain.gni") |
11 | 11 |
12 if (is_ios) { | 12 if (is_ios) { |
13 import("//build/config/ios/ios_sdk.gni") | 13 import("//build/config/ios/ios_sdk.gni") |
14 } | 14 } |
15 | 15 |
16 # Contains the dependencies needed for sanitizers to link into | 16 # Contains the dependencies needed for sanitizers to link into |
17 # executables and shared_libraries. Unconditionally depend upon | 17 # executables and shared_libraries. Unconditionally depend upon |
18 # "//build/config:exe_and_shlib_deps" to pull in this target. | 18 # "//build/config:exe_and_shlib_deps" to pull in this target. |
19 group("deps") { | 19 group("deps") { |
20 visibility = [ "//build/config:exe_and_shlib_deps" ] | 20 visibility = [ "//build/config:exe_and_shlib_deps" ] |
21 public_deps = [ | |
22 ":deps_no_options", | |
23 ] | |
24 if (using_sanitizer) { | 21 if (using_sanitizer) { |
25 public_configs = [ | 22 public_configs = [ |
26 ":sanitizer_options_link_helper", | 23 ":sanitizer_options_link_helper", |
27 | 24 |
28 # Even when a target removes default_sanitizer_flags, it may be depending | 25 # Even when a target removes default_sanitizer_flags, it may be depending |
29 # on a library that did not remove default_sanitizer_flags. Thus, we need | 26 # on a library that did not remove default_sanitizer_flags. Thus, we need |
30 # to add the ldflags here as well as in default_sanitizer_flags. | 27 # to add the ldflags here as well as in default_sanitizer_flags. |
31 ":default_sanitizer_ldflags", | 28 ":default_sanitizer_ldflags", |
32 ] | 29 ] |
33 deps = [ | 30 deps = [ |
34 ":options_sources", | 31 ":options_sources", |
35 ] | 32 ] |
36 } | |
37 if (use_afl) { | |
38 deps += [ "//third_party/afl" ] | |
39 } | |
40 } | |
41 | |
42 group("deps_no_options") { | |
43 if (using_sanitizer) { | |
44 public_configs = [ | |
45 # Even when a target removes default_sanitizer_flags, it may be depending | |
46 # on a library that did not remove default_sanitizer_flags. Thus, we need | |
47 # to add the ldflags here as well as in default_sanitizer_flags. | |
48 ":default_sanitizer_ldflags", | |
49 ] | |
50 deps = [] | |
51 public_deps = [] | |
52 | |
53 data = [ | |
54 "//tools/valgrind/asan/", | |
55 ] | |
56 if (is_win) { | 33 if (is_win) { |
57 exe = ".exe" | 34 exe = ".exe" |
58 } else { | 35 } else { |
59 exe = "" | 36 exe = "" |
60 } | 37 } |
61 data += [ "$clang_base_path/bin/llvm-symbolizer${exe}" ] | 38 data = [ |
| 39 "//tools/valgrind/asan/", |
| 40 "$clang_base_path/bin/llvm-symbolizer${exe}", |
| 41 ] |
62 if (is_linux) { | 42 if (is_linux) { |
63 # llvm-symbolizer needs this. | 43 # llvm-symbolizer needs this. |
64 data += [ "$clang_base_path/lib/libstdc++.so.6" ] | 44 data += [ "$clang_base_path/lib/libstdc++.so.6" ] |
65 } | 45 } |
66 | 46 |
67 if (use_prebuilt_instrumented_libraries || | 47 if (use_prebuilt_instrumented_libraries || |
68 use_locally_built_instrumented_libraries) { | 48 use_locally_built_instrumented_libraries) { |
69 deps += [ "//third_party/instrumented_libraries:deps" ] | 49 deps += [ "//third_party/instrumented_libraries:deps" ] |
70 } | 50 } |
71 if (use_custom_libcxx) { | |
72 public_deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ] | |
73 data += [ "$root_out_dir/libc++.so" ] | |
74 } | |
75 | 51 |
76 # ASAN is supported on iOS but the runtime library depends on the compiler | 52 # ASAN is supported on iOS but the runtime library depends on the compiler |
77 # used (Chromium version of clang versus Xcode version of clang). Only copy | 53 # used (Chromium version of clang versus Xcode version of clang). Only copy |
78 # the ASAN runtime on iOS if building with Chromium clang. | 54 # the ASAN runtime on iOS if building with Chromium clang. |
79 if (is_win || is_mac || (is_ios && !use_xcode_clang)) { | 55 if (is_win || is_mac || (is_ios && !use_xcode_clang)) { |
80 data_deps = [ | 56 data_deps = [ |
81 ":copy_asan_runtime", | 57 ":copy_asan_runtime", |
82 ] | 58 ] |
83 } | 59 } |
84 if (is_mac || (is_ios && !use_xcode_clang)) { | 60 if (is_mac || (is_ios && !use_xcode_clang)) { |
85 public_deps += [ ":asan_runtime_bundle_data" ] | 61 public_deps = [ |
| 62 ":asan_runtime_bundle_data", |
| 63 ] |
86 } | 64 } |
87 } | 65 } |
88 } | 66 } |
89 | 67 |
90 if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) { | 68 if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) { |
91 if (is_mac) { | 69 if (is_mac) { |
92 _clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib" | 70 _clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib" |
93 } else if (is_ios) { | 71 } else if (is_ios) { |
94 _clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib" | 72 _clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib" |
95 } else if (is_win && target_cpu == "x86") { | 73 } else if (is_win && target_cpu == "x86") { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 "clang_rt.asan_dynamic-i386.lib", | 246 "clang_rt.asan_dynamic-i386.lib", |
269 "clang_rt.asan_dynamic_runtime_thunk-i386.lib", | 247 "clang_rt.asan_dynamic_runtime_thunk-i386.lib", |
270 ] | 248 ] |
271 } | 249 } |
272 } | 250 } |
273 } | 251 } |
274 } | 252 } |
275 | 253 |
276 config("common_sanitizer_flags") { | 254 config("common_sanitizer_flags") { |
277 cflags = [] | 255 cflags = [] |
278 cflags_cc = [] | |
279 | 256 |
280 # Sanitizers need line table info for stack traces. They don't need type info | 257 # Sanitizers need line table info for stack traces. They don't need type info |
281 # or variable info, so we can leave that out to speed up the build (unless | 258 # or variable info, so we can leave that out to speed up the build (unless |
282 # it's explicitly asked for by setting |sanitizer_keep_symbols| to true). | 259 # it's explicitly asked for by setting |sanitizer_keep_symbols| to true). |
283 if (using_sanitizer) { | 260 if (using_sanitizer) { |
284 assert(is_clang, "sanitizers only supported with clang") | 261 assert(is_clang, "sanitizers only supported with clang") |
285 if (!sanitizer_keep_symbols) { | 262 if (!sanitizer_keep_symbols) { |
286 cflags += [ "-gline-tables-only" ] | 263 cflags += [ "-gline-tables-only" ] |
287 } | 264 } |
288 | 265 |
289 cflags += [ | 266 cflags += [ |
290 # Column info in debug data confuses Visual Studio's debugger, so don't | 267 # Column info in debug data confuses Visual Studio's debugger, so don't |
291 # use this by default. However, clusterfuzz needs it for good attribution | 268 # use this by default. However, clusterfuzz needs it for good attribution |
292 # of reports to CLs, so turn it on there. | 269 # of reports to CLs, so turn it on there. |
293 "-gcolumn-info", | 270 "-gcolumn-info", |
294 ] | 271 ] |
295 } | 272 } |
296 | 273 |
297 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, | 274 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, |
298 # MemorySanitizer and non-official CFI builds. | 275 # MemorySanitizer and non-official CFI builds. |
299 if (using_sanitizer || (is_cfi && !is_official_build)) { | 276 if (using_sanitizer || (is_cfi && !is_official_build)) { |
300 if (is_posix) { | 277 if (is_posix) { |
301 cflags += [ "-fno-omit-frame-pointer" ] | 278 cflags += [ "-fno-omit-frame-pointer" ] |
302 } else { | 279 } else { |
303 cflags += [ "/Oy-" ] | 280 cflags += [ "/Oy-" ] |
304 } | 281 } |
305 } | 282 } |
| 283 } |
306 | 284 |
| 285 # TODO(thomasanderson): Move this out of build/config/sanitizers. |
| 286 config("libcxx_flags") { |
307 if (use_custom_libcxx) { | 287 if (use_custom_libcxx) { |
308 prefix = "//buildtools/third_party" | 288 prefix = "//buildtools/third_party" |
309 include = "trunk/include" | 289 include = "trunk/include" |
310 cflags_cc += [ | 290 cflags_cc = [ |
311 "-nostdinc++", | 291 "-nostdinc++", |
312 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir), | 292 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir), |
313 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir), | 293 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir), |
314 ] | 294 ] |
315 } | 295 } |
316 } | 296 } |
317 | 297 |
318 config("asan_flags") { | 298 config("asan_flags") { |
319 cflags = [] | 299 cflags = [] |
320 if (is_asan) { | 300 if (is_asan) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 531 } |
552 | 532 |
553 config("fuzzing_build_mode") { | 533 config("fuzzing_build_mode") { |
554 if (use_libfuzzer || use_afl) { | 534 if (use_libfuzzer || use_afl) { |
555 defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ] | 535 defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ] |
556 } | 536 } |
557 } | 537 } |
558 | 538 |
559 all_sanitizer_configs = [ | 539 all_sanitizer_configs = [ |
560 ":common_sanitizer_flags", | 540 ":common_sanitizer_flags", |
| 541 ":libcxx_flags", |
561 ":coverage_flags", | 542 ":coverage_flags", |
562 ":default_sanitizer_ldflags", | 543 ":default_sanitizer_ldflags", |
563 ":asan_flags", | 544 ":asan_flags", |
564 ":cfi_flags", | 545 ":cfi_flags", |
565 ":lsan_flags", | 546 ":lsan_flags", |
566 ":msan_flags", | 547 ":msan_flags", |
567 ":tsan_flags", | 548 ":tsan_flags", |
568 ":ubsan_flags", | 549 ":ubsan_flags", |
569 ":ubsan_no_recover", | 550 ":ubsan_no_recover", |
570 ":ubsan_null_flags", | 551 ":ubsan_null_flags", |
(...skipping 18 matching lines...) Expand all Loading... |
589 # This allows to selectively disable ubsan_vptr, when needed. In particular, | 570 # This allows to selectively disable ubsan_vptr, when needed. In particular, |
590 # if some third_party code is required to be compiled without rtti, which | 571 # if some third_party code is required to be compiled without rtti, which |
591 # is a requirement for ubsan_vptr. | 572 # is a requirement for ubsan_vptr. |
592 config("default_sanitizer_flags_but_ubsan_vptr") { | 573 config("default_sanitizer_flags_but_ubsan_vptr") { |
593 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] | 574 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] |
594 } | 575 } |
595 | 576 |
596 config("default_sanitizer_flags_but_coverage") { | 577 config("default_sanitizer_flags_but_coverage") { |
597 configs = all_sanitizer_configs - [ ":coverage_flags" ] | 578 configs = all_sanitizer_configs - [ ":coverage_flags" ] |
598 } | 579 } |
OLD | NEW |