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/chromecast_build.gni") | 6 import("//build/config/chromecast_build.gni") |
7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
8 | 8 |
9 # Contains the dependencies needed for sanitizers to link into executables and | 9 # Contains the dependencies needed for sanitizers to link into executables and |
10 # shared_libraries. Unconditionally depend upon this target as it is empty if | 10 # shared_libraries. Unconditionally depend upon this target as it is empty if |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 if (is_msan) { | 88 if (is_msan) { |
89 ldflags += [ "-fsanitize=memory" ] | 89 ldflags += [ "-fsanitize=memory" ] |
90 } | 90 } |
91 if (is_ubsan || is_ubsan_security) { | 91 if (is_ubsan || is_ubsan_security) { |
92 ldflags += [ "-fsanitize=undefined" ] | 92 ldflags += [ "-fsanitize=undefined" ] |
93 } | 93 } |
94 if (is_ubsan_vptr) { | 94 if (is_ubsan_vptr) { |
95 ldflags += [ "-fsanitize=vptr" ] | 95 ldflags += [ "-fsanitize=vptr" ] |
96 } | 96 } |
97 if (is_lto && !is_nacl) { | |
98 ldflags += [ "-flto" ] | |
99 | 97 |
100 # Apply a lower LTO optimization level as the default is too slow. | 98 if (is_cfi && !is_nacl) { |
101 if (is_linux) { | 99 ldflags += [ |
102 ldflags += [ "-Wl,-plugin-opt,O1" ] | 100 "-fsanitize=cfi-vcall", |
103 } else if (is_mac) { | 101 "-fsanitize=cfi-derived-cast", |
104 ldflags += [ "-Wl,-mllvm,-O1" ] | 102 "-fsanitize=cfi-unrelated-cast", |
105 } | 103 ] |
106 | |
107 # Work-around for http://openradar.appspot.com/20356002 | |
108 if (is_mac) { | |
109 ldflags += [ "-Wl,-all_load" ] | |
110 } | |
111 | |
112 # Without this flag, LTO produces a .text section that is larger | |
113 # than the maximum call displacement, preventing the linker from | |
114 # relocating calls (http://llvm.org/PR22999). | |
115 if (current_cpu == "arm") { | |
116 ldflags += [ "-Wl,-plugin-opt,-function-sections" ] | |
117 } | |
118 | |
119 if (is_cfi) { | |
120 ldflags += [ | |
121 "-fsanitize=cfi-vcall", | |
122 "-fsanitize=cfi-derived-cast", | |
123 "-fsanitize=cfi-unrelated-cast", | |
124 ] | |
125 } | |
126 | |
127 if (use_cfi_diag) { | 104 if (use_cfi_diag) { |
128 ldflags += [ | 105 ldflags += [ |
129 "-fno-sanitize-trap=cfi", | 106 "-fno-sanitize-trap=cfi", |
130 "-fsanitize-recover=cfi", | 107 "-fsanitize-recover=cfi", |
131 ] | 108 ] |
132 } | 109 } |
133 } | 110 } |
134 } | 111 } |
135 } | 112 } |
136 | 113 |
(...skipping 12 matching lines...) Expand all Loading... |
149 | 126 |
150 # Sanitizers need line table info for stack traces. They don't need type info | 127 # Sanitizers need line table info for stack traces. They don't need type info |
151 # or variable info, so we can leave that out to speed up the build. | 128 # or variable info, so we can leave that out to speed up the build. |
152 if (using_sanitizer) { | 129 if (using_sanitizer) { |
153 assert(is_clang, "sanitizers only supported with clang") | 130 assert(is_clang, "sanitizers only supported with clang") |
154 cflags += [ "-gline-tables-only" ] | 131 cflags += [ "-gline-tables-only" ] |
155 } | 132 } |
156 | 133 |
157 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, | 134 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, |
158 # MemorySanitizer and non-official CFI builds. | 135 # MemorySanitizer and non-official CFI builds. |
159 if (using_sanitizer || (is_lto && !is_official_build)) { | 136 if (using_sanitizer || (is_cfi && !is_official_build)) { |
160 if (is_posix) { | 137 if (is_posix) { |
161 cflags += [ "-fno-omit-frame-pointer" ] | 138 cflags += [ "-fno-omit-frame-pointer" ] |
162 } else { | 139 } else { |
163 cflags += [ "/Oy-" ] | 140 cflags += [ "/Oy-" ] |
164 } | 141 } |
165 } | 142 } |
166 if (is_asan) { | 143 if (is_asan) { |
167 cflags += [ "-fsanitize=address" ] | 144 cflags += [ "-fsanitize=address" ] |
168 if (is_win) { | 145 if (is_win) { |
169 cflags += [ "-fsanitize-blacklist=" + | 146 cflags += [ "-fsanitize-blacklist=" + |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 ] | 252 ] |
276 } | 253 } |
277 if (is_ubsan_security) { | 254 if (is_ubsan_security) { |
278 ubsan_blacklist_path = | 255 ubsan_blacklist_path = |
279 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) | 256 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) |
280 cflags += [ | 257 cflags += [ |
281 "-fsanitize=signed-integer-overflow", | 258 "-fsanitize=signed-integer-overflow", |
282 "-fsanitize-blacklist=$ubsan_blacklist_path", | 259 "-fsanitize-blacklist=$ubsan_blacklist_path", |
283 ] | 260 ] |
284 } | 261 } |
285 if (is_lto && !is_nacl) { | 262 if (is_cfi && !is_nacl) { |
286 cflags += [ "-flto" ] | 263 cfi_blacklist_path = |
287 | 264 rebase_path("//tools/cfi/blacklist.txt", root_build_dir) |
288 if (is_cfi) { | 265 cflags += [ |
289 cfi_blacklist_path = | 266 "-fsanitize=cfi-vcall", |
290 rebase_path("//tools/cfi/blacklist.txt", root_build_dir) | 267 "-fsanitize=cfi-derived-cast", |
291 cflags += [ | 268 "-fsanitize=cfi-unrelated-cast", |
292 "-fsanitize=cfi-vcall", | 269 "-fsanitize-blacklist=$cfi_blacklist_path", |
293 "-fsanitize=cfi-derived-cast", | 270 ] |
294 "-fsanitize=cfi-unrelated-cast", | |
295 "-fsanitize-blacklist=$cfi_blacklist_path", | |
296 ] | |
297 } | |
298 | 271 |
299 if (use_cfi_diag) { | 272 if (use_cfi_diag) { |
300 cflags += [ | 273 cflags += [ |
301 "-fno-sanitize-trap=cfi", | 274 "-fno-sanitize-trap=cfi", |
302 "-fsanitize-recover=cfi", | 275 "-fsanitize-recover=cfi", |
303 "-fno-inline-functions", | 276 "-fno-inline-functions", |
304 "-fno-inline", | 277 "-fno-inline", |
305 "-fno-omit-frame-pointer", | 278 "-fno-omit-frame-pointer", |
306 "-O1", | 279 "-O1", |
307 ] | 280 ] |
(...skipping 18 matching lines...) Expand all Loading... |
326 | 299 |
327 if (use_sanitizer_coverage) { | 300 if (use_sanitizer_coverage) { |
328 # FIXME: make this configurable. | 301 # FIXME: make this configurable. |
329 cflags += [ | 302 cflags += [ |
330 "-fsanitize-coverage=edge,indirect-calls,8bit-counters", | 303 "-fsanitize-coverage=edge,indirect-calls,8bit-counters", |
331 "-mllvm", | 304 "-mllvm", |
332 "-sanitizer-coverage-prune-blocks=1", | 305 "-sanitizer-coverage-prune-blocks=1", |
333 ] | 306 ] |
334 } | 307 } |
335 } | 308 } |
OLD | NEW |