Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: build/config/sanitizers/BUILD.gn

Issue 1839763006: Add support for the Windows ASan configuration to the gn build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, revert unintended update.py changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/config/win/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 if (use_prebuilt_instrumented_libraries) { 26 if (use_prebuilt_instrumented_libraries) {
27 deps += [ "//third_party/instrumented_libraries:deps" ] 27 deps += [ "//third_party/instrumented_libraries:deps" ]
28 } 28 }
29 if (use_custom_libcxx) { 29 if (use_custom_libcxx) {
30 deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ] 30 deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ]
31 } 31 }
32 } 32 }
33 } 33 }
34 34
35 config("sanitizer_options_link_helper") { 35 config("sanitizer_options_link_helper") {
36 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] 36 if (!is_win) {
37 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]
38 }
37 } 39 }
38 40
39 source_set("options_sources") { 41 source_set("options_sources") {
40 visibility = [ 42 visibility = [
41 ":deps", 43 ":deps",
42 "//:gn_visibility", 44 "//:gn_visibility",
43 ] 45 ]
44 sources = [ 46 sources = [
45 "//build/sanitizers/sanitizer_options.cc", 47 "//build/sanitizers/sanitizer_options.cc",
46 ] 48 ]
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 # removes this config, executables & shared libraries should still depend on 142 # removes this config, executables & shared libraries should still depend on
141 # :deps if any of their dependencies have not opted out of sanitizers. 143 # :deps if any of their dependencies have not opted out of sanitizers.
142 config("default_sanitizer_flags") { 144 config("default_sanitizer_flags") {
143 cflags = [] 145 cflags = []
144 cflags_cc = [] 146 cflags_cc = []
145 defines = [] 147 defines = []
146 configs = [ ":default_sanitizer_ldflags" ] 148 configs = [ ":default_sanitizer_ldflags" ]
147 149
148 # Sanitizers need line table info for stack traces. They don't need type info 150 # Sanitizers need line table info for stack traces. They don't need type info
149 # or variable info, so we can leave that out to speed up the build. 151 # or variable info, so we can leave that out to speed up the build.
150 if (is_clang && using_sanitizer) { 152 if (using_sanitizer) {
153 assert(is_clang, "sanitizers only supported with clang")
151 cflags += [ "-gline-tables-only" ] 154 cflags += [ "-gline-tables-only" ]
152 } 155 }
153 156
154 # Only works on Posix-like platforms. 157 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer,
155 # FIXME: this is not true, remove the conditional. 158 # MemorySanitizer and non-official CFI builds.
156 if (is_posix) { 159 if (using_sanitizer || (is_lto && !is_official_build)) {
157 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, 160 if (is_posix) {
158 # MemorySanitizer and non-official CFI builds.
159 if (using_sanitizer || (is_lto && !is_official_build)) {
160 cflags += [ "-fno-omit-frame-pointer" ] 161 cflags += [ "-fno-omit-frame-pointer" ]
162 } else {
163 cflags += [ "/Oy-" ]
161 } 164 }
162 if (is_asan) { 165 }
163 asan_blacklist_path = 166 if (is_asan) {
164 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) 167 cflags += [ "-fsanitize=address" ]
168 if (is_win) {
169 cflags += [ "-fsanitize-blacklist=" +
170 rebase_path("//tools/memory/asan/blacklist_win.txt",
171 root_build_dir) ]
172 } else {
173 # TODO(rnk): Remove this as discussed in http://crbug.com/427202.
174 cflags +=
175 [ "-fsanitize-blacklist=" +
176 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) ]
177 }
178 if (is_android) {
179 # Android build relies on -Wl,--gc-sections removing unreachable code.
180 # ASan instrumentation for globals inhibits this and results in a
181 # library with unresolvable relocations.
182 # TODO(eugenis): find a way to reenable this.
165 cflags += [ 183 cflags += [
166 "-fsanitize=address", 184 "-mllvm",
167 "-fsanitize-blacklist=$asan_blacklist_path", 185 "-asan-globals=0",
168 ] 186 ]
169 if (is_android) { 187 } else if (is_mac) {
170 # Android build relies on -Wl,--gc-sections removing unreachable code. 188 # http://crbug.com/352073
171 # ASan instrumentation for globals inhibits this and results in a 189 cflags += [
172 # library with unresolvable relocations. 190 "-mllvm",
173 # TODO(eugenis): find a way to reenable this. 191 "-asan-globals=0",
174 cflags += [ 192 ]
175 "-mllvm", 193 libs = [ "clang_rt.asan_osx_dynamic" ]
176 "-asan-globals=0", 194
195 # TODO(GYP): deal with mac_bundles.
196 } else if (is_win) {
197 assert(target_cpu == "x86", "WinASan is 32-bit only currently")
198 if (is_component_build) {
199 libs = [
200 "clang_rt.asan_dynamic-i386.lib",
201 "clang_rt.asan_dynamic_runtime_thunk-i386.lib",
177 ] 202 ]
178 } else if (is_mac) { 203 } else {
179 # http://crbug.com/352073 204 # TODO(rnk): DLLs in the non-component build should link against
180 cflags += [ 205 # clang_rt.asan_dll_thunk-i386.lib instead.
181 "-mllvm", 206 libs = [ "clang_rt.asan-i386.lib" ]
182 "-asan-globals=0",
183 ]
184 # TODO(GYP): deal with mac_bundles.
185 } 207 }
186 } 208 }
187 if (is_lsan) { 209 }
188 cflags += [ "-fsanitize=leak" ] 210 if (is_lsan) {
189 } 211 cflags += [ "-fsanitize=leak" ]
190 if (is_tsan) { 212 }
191 tsan_blacklist_path = 213 if (is_tsan) {
192 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) 214 assert(is_linux, "tsan only supported on linux x86_64")
215 tsan_blacklist_path =
216 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
217 cflags += [
218 "-fsanitize=thread",
219 "-fsanitize-blacklist=$tsan_blacklist_path",
220 ]
221 }
222 if (is_msan) {
223 assert(is_linux, "msan only supported on linux x86_64")
224 msan_blacklist_path =
225 rebase_path("//tools/msan/blacklist.txt", root_build_dir)
226 cflags += [
227 "-fsanitize=memory",
228 "-fsanitize-memory-track-origins=$msan_track_origins",
229 "-fsanitize-blacklist=$msan_blacklist_path",
230 ]
231 }
232 if (is_ubsan) {
233 ubsan_blacklist_path =
234 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
235 cflags += [
236 # Yasm dies with an "Illegal instruction" error when bounds checking is
237 # enabled. See http://crbug.com/489901
238 # "-fsanitize=bounds",
239 "-fsanitize=float-divide-by-zero",
240 "-fsanitize=integer-divide-by-zero",
241 "-fsanitize=null",
242 "-fsanitize=object-size",
243 "-fsanitize=return",
244 "-fsanitize=returns-nonnull-attribute",
245 "-fsanitize=shift-exponent",
246 "-fsanitize=signed-integer-overflow",
247 "-fsanitize=unreachable",
248 "-fsanitize=vla-bound",
249 "-fsanitize-blacklist=$ubsan_blacklist_path",
250 ]
251
252 # Chromecast ubsan builds fail to compile with these
253 # experimental flags, so only add them to non-chromecast ubsan builds.
254 if (!is_chromecast) {
193 cflags += [ 255 cflags += [
194 "-fsanitize=thread", 256 # Employ the experimental PBQP register allocator to avoid slow
195 "-fsanitize-blacklist=$tsan_blacklist_path", 257 # compilation on files with too many basic blocks.
258 # See http://crbug.com/426271.
259 "-mllvm",
260 "-regalloc=pbqp",
261
262 # Speculatively use coalescing to slightly improve the code generated
263 # by PBQP regallocator. May increase compile time.
264 "-mllvm",
265 "-pbqp-coalescing",
196 ] 266 ]
197 } 267 }
198 if (is_msan) { 268 }
199 msan_blacklist_path = 269 if (is_ubsan_vptr) {
200 rebase_path("//tools/msan/blacklist.txt", root_build_dir) 270 ubsan_vptr_blacklist_path =
271 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
272 cflags += [
273 "-fsanitize=vptr",
274 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
275 ]
276 }
277 if (is_ubsan_security) {
278 ubsan_blacklist_path =
279 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
280 cflags += [
281 "-fsanitize=signed-integer-overflow",
282 "-fsanitize-blacklist=$ubsan_blacklist_path",
283 ]
284 }
285 if (is_lto && !is_nacl) {
286 cflags += [ "-flto" ]
287
288 if (is_cfi) {
289 cfi_blacklist_path =
290 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
201 cflags += [ 291 cflags += [
202 "-fsanitize=memory", 292 "-fsanitize=cfi-vcall",
203 "-fsanitize-memory-track-origins=$msan_track_origins", 293 "-fsanitize=cfi-derived-cast",
204 "-fsanitize-blacklist=$msan_blacklist_path", 294 "-fsanitize=cfi-unrelated-cast",
295 "-fsanitize-blacklist=$cfi_blacklist_path",
205 ] 296 ]
206 } 297 }
207 if (is_ubsan) { 298
208 ubsan_blacklist_path = 299 if (use_cfi_diag) {
209 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
210 cflags += [ 300 cflags += [
211 # Yasm dies with an "Illegal instruction" error when bounds checking is 301 "-fno-sanitize-trap=cfi",
212 # enabled. See http://crbug.com/489901 302 "-fsanitize-recover=cfi",
213 # "-fsanitize=bounds", 303 "-fno-inline-functions",
214 "-fsanitize=float-divide-by-zero", 304 "-fno-inline",
215 "-fsanitize=integer-divide-by-zero", 305 "-fno-omit-frame-pointer",
216 "-fsanitize=null", 306 "-O1",
217 "-fsanitize=object-size",
218 "-fsanitize=return",
219 "-fsanitize=returns-nonnull-attribute",
220 "-fsanitize=shift-exponent",
221 "-fsanitize=signed-integer-overflow",
222 "-fsanitize=unreachable",
223 "-fsanitize=vla-bound",
224 "-fsanitize-blacklist=$ubsan_blacklist_path",
225 ] 307 ]
308 } else {
309 defines += [ "CFI_ENFORCEMENT" ]
310 }
311 }
226 312
227 # Chromecast ubsan builds fail to compile with these 313 if (use_custom_libcxx) {
228 # experimental flags, so only add them to non-chromecast ubsan builds. 314 prefix = "//buildtools/third_party"
229 if (!is_chromecast) { 315 include = "trunk/include"
230 cflags += [ 316 cflags_cc += [
231 # Employ the experimental PBQP register allocator to avoid slow 317 "-nostdinc++",
232 # compilation on files with too many basic blocks. 318 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
233 # See http://crbug.com/426271. 319 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
234 "-mllvm", 320 ]
235 "-regalloc=pbqp",
236
237 # Speculatively use coalescing to slightly improve the code generated
238 # by PBQP regallocator. May increase compile time.
239 "-mllvm",
240 "-pbqp-coalescing",
241 ]
242 }
243 }
244 if (is_ubsan_vptr) {
245 ubsan_vptr_blacklist_path =
246 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
247 cflags += [
248 "-fsanitize=vptr",
249 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
250 ]
251 }
252 if (is_ubsan_security) {
253 ubsan_blacklist_path =
254 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
255 cflags += [
256 "-fsanitize=signed-integer-overflow",
257 "-fsanitize-blacklist=$ubsan_blacklist_path",
258 ]
259 }
260 if (is_lto && !is_nacl) {
261 cflags += [ "-flto" ]
262
263 if (is_cfi) {
264 cfi_blacklist_path =
265 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
266 cflags += [
267 "-fsanitize=cfi-vcall",
268 "-fsanitize=cfi-derived-cast",
269 "-fsanitize=cfi-unrelated-cast",
270 "-fsanitize-blacklist=$cfi_blacklist_path",
271 ]
272 }
273
274 if (use_cfi_diag) {
275 cflags += [
276 "-fno-sanitize-trap=cfi",
277 "-fsanitize-recover=cfi",
278 "-fno-inline-functions",
279 "-fno-inline",
280 "-fno-omit-frame-pointer",
281 "-O1",
282 ]
283 } else {
284 defines += [ "CFI_ENFORCEMENT" ]
285 }
286 }
287
288 if (use_custom_libcxx) {
289 prefix = "//buildtools/third_party"
290 include = "trunk/include"
291 cflags_cc += [
292 "-nostdinc++",
293 "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
294 "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
295 ]
296 }
297 } 321 }
298 } 322 }
299 323
300 config("default_sanitizer_coverage_flags") { 324 config("default_sanitizer_coverage_flags") {
301 cflags = [] 325 cflags = []
302 326
303 if (use_sanitizer_coverage) { 327 if (use_sanitizer_coverage) {
304 # FIXME: make this configurable. 328 # FIXME: make this configurable.
305 cflags += [ 329 cflags += [
306 "-fsanitize-coverage=edge,indirect-calls,8bit-counters", 330 "-fsanitize-coverage=edge,indirect-calls,8bit-counters",
307 "-mllvm", 331 "-mllvm",
308 "-sanitizer-coverage-prune-blocks=1", 332 "-sanitizer-coverage-prune-blocks=1",
309 ] 333 ]
310 } 334 }
311 } 335 }
OLDNEW
« no previous file with comments | « no previous file | build/config/win/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698