Chromium Code Reviews| 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/config/chrome_build.gni") | 5 import("//build/config/chrome_build.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 | 7 |
| 8 # Contains the dependencies needed for sanitizers to link into executables and | 8 # Contains the dependencies needed for sanitizers to link into executables and |
| 9 # shared_libraries. Unconditionally depend upon this target as it is empty if | 9 # shared_libraries. Unconditionally depend upon this target as it is empty if |
| 10 # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false. | 10 # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false. |
| 11 group("deps") { | 11 group("deps") { |
| 12 if (using_sanitizer) { | 12 if (using_sanitizer) { |
| 13 public_configs = [ ":sanitizer_options_link_helper" ] | 13 public_configs = [ |
| 14 ":sanitizer_options_link_helper", | |
| 15 | |
| 16 # Even when a target removes default_sanitizer_flags, it may be depending | |
| 17 # on a library that did not remove default_sanitizer_flags. Thus, we need | |
| 18 # to add the ldflags here as well as in default_sanitizer_flags. | |
| 19 ":default_sanitizer_ldflags", | |
|
brettw
2016/01/19 20:39:42
Doesn't this mean that if a target removes the def
agrieve
2016/02/02 19:22:31
That's correct, but I think it's desirable and how
brettw
2016/02/02 22:31:17
Okay, you convinced me.
| |
| 20 ] | |
| 14 deps = [ | 21 deps = [ |
| 15 ":options_sources", | 22 ":options_sources", |
| 16 ] | 23 ] |
| 17 | 24 |
| 18 if (use_prebuilt_instrumented_libraries) { | 25 if (use_prebuilt_instrumented_libraries) { |
| 19 deps += [ "//third_party/instrumented_libraries:deps" ] | 26 deps += [ "//third_party/instrumented_libraries:deps" ] |
| 20 } | 27 } |
| 21 if (use_custom_libcxx) { | 28 if (use_custom_libcxx) { |
| 22 deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ] | 29 deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ] |
| 23 } | 30 } |
| 24 } | 31 } |
| 25 } | 32 } |
| 26 | 33 |
| 27 config("sanitizer_options_link_helper") { | 34 config("sanitizer_options_link_helper") { |
| 28 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] | 35 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] |
| 29 if (is_asan) { | |
| 30 ldflags += [ "-fsanitize=address" ] | |
| 31 } | |
| 32 if (is_lsan) { | |
| 33 ldflags += [ "-fsanitize=leak" ] | |
| 34 } | |
| 35 if (is_tsan) { | |
| 36 ldflags += [ "-fsanitize=thread" ] | |
| 37 } | |
| 38 if (is_msan) { | |
| 39 ldflags += [ "-fsanitize=memory" ] | |
| 40 } | |
| 41 if (is_ubsan) { | |
| 42 ldflags += [ "-fsanitize=undefined" ] | |
| 43 } | |
| 44 if (is_ubsan_vptr) { | |
| 45 ldflags += [ "-fsanitize=vptr" ] | |
| 46 } | |
| 47 } | 36 } |
| 48 | 37 |
| 49 source_set("options_sources") { | 38 source_set("options_sources") { |
| 50 visibility = [ | 39 visibility = [ |
| 51 ":deps", | 40 ":deps", |
| 52 "//:gn_visibility", | 41 "//:gn_visibility", |
| 53 ] | 42 ] |
| 54 sources = [ | 43 sources = [ |
| 55 "//build/sanitizers/sanitizer_options.cc", | 44 "//build/sanitizers/sanitizer_options.cc", |
| 56 ] | 45 ] |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 67 | 56 |
| 68 if (is_lsan) { | 57 if (is_lsan) { |
| 69 sources += [ "//build/sanitizers/lsan_suppressions.cc" ] | 58 sources += [ "//build/sanitizers/lsan_suppressions.cc" ] |
| 70 } | 59 } |
| 71 | 60 |
| 72 if (is_tsan) { | 61 if (is_tsan) { |
| 73 sources += [ "//build/sanitizers/tsan_suppressions.cc" ] | 62 sources += [ "//build/sanitizers/tsan_suppressions.cc" ] |
| 74 } | 63 } |
| 75 } | 64 } |
| 76 | 65 |
| 66 config("default_sanitizer_ldflags") { | |
| 67 if (is_posix) { | |
| 68 if (is_asan) { | |
| 69 ldflags = [ "-fsanitize=address" ] | |
| 70 } | |
| 71 if (is_lsan) { | |
| 72 ldflags = [ "-fsanitize=leak" ] | |
| 73 } | |
| 74 if (is_tsan) { | |
| 75 ldflags = [ "-fsanitize=thread" ] | |
| 76 } | |
| 77 if (is_msan) { | |
| 78 ldflags = [ "-fsanitize=memory" ] | |
| 79 } | |
| 80 if (is_ubsan) { | |
| 81 ldflags = [ "-fsanitize=undefined" ] | |
| 82 } | |
| 83 if (is_ubsan_vptr) { | |
| 84 ldflags = [ "-fsanitize=vptr" ] | |
| 85 } | |
| 86 } | |
| 87 } | |
| 88 | |
| 77 # This config is applied by default to all targets. It sets the compiler flags | 89 # This config is applied by default to all targets. It sets the compiler flags |
| 78 # for sanitizer usage, or, if no sanitizer is set, does nothing. | 90 # for sanitizer usage, or, if no sanitizer is set, does nothing. |
| 79 # | 91 # |
| 80 # This needs to be in a separate config so that targets can opt out of | 92 # This needs to be in a separate config so that targets can opt out of |
| 81 # sanitizers if they desire. | 93 # sanitizers if they desire. |
| 82 config("default_sanitizer_flags") { | 94 config("default_sanitizer_flags") { |
| 83 cflags = [] | 95 cflags = [] |
| 84 cflags_cc = [] | 96 cflags_cc = [] |
| 85 ldflags = [] | 97 ldflags = [] |
| 86 defines = [] | 98 defines = [] |
| 99 configs = [ ":default_sanitizer_ldflags" ] | |
|
brettw
2016/01/19 20:39:43
This will cause these ldflags to get duplicated in
agrieve
2016/02/02 19:22:31
Didn't know that, and you obviously know about thi
brettw
2016/02/02 22:31:17
Oh actually this is fine. I misunderstood this and
| |
| 87 | 100 |
| 88 # Only works on Posix-like platforms. | 101 # Only works on Posix-like platforms. |
| 89 # FIXME: this is not true, remove the conditional. | 102 # FIXME: this is not true, remove the conditional. |
| 90 if (is_posix) { | 103 if (is_posix) { |
| 91 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, | 104 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, |
| 92 # MemorySanitizer and non-official CFI builds. | 105 # MemorySanitizer and non-official CFI builds. |
| 93 if (using_sanitizer || (is_cfi && !is_official_build)) { | 106 if (using_sanitizer || (is_cfi && !is_official_build)) { |
| 94 cflags += [ | 107 cflags += [ |
| 95 "-fno-omit-frame-pointer", | 108 "-fno-omit-frame-pointer", |
| 96 "-gline-tables-only", | 109 "-gline-tables-only", |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 | 255 |
| 243 config("default_sanitizer_coverage_flags") { | 256 config("default_sanitizer_coverage_flags") { |
| 244 cflags = [] | 257 cflags = [] |
| 245 | 258 |
| 246 if (use_sanitizer_coverage) { | 259 if (use_sanitizer_coverage) { |
| 247 # FIXME: make this configurable. | 260 # FIXME: make this configurable. |
| 248 cflags += | 261 cflags += |
| 249 [ "-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp" ] | 262 [ "-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp" ] |
| 250 } | 263 } |
| 251 } | 264 } |
| OLD | NEW |