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

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

Issue 2580313002: Make sanitizer suppressions and blacklists fully configurable. (Closed)
Patch Set: Made the example paths different from the actual defaults Created 4 years 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_overrides/build.gni » ('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_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")
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 sources = [ 160 sources = [
161 "//build/sanitizers/sanitizer_options.cc", 161 "//build/sanitizers/sanitizer_options.cc",
162 ] 162 ]
163 163
164 # Don't compile this target with any sanitizer code. It can be called from 164 # Don't compile this target with any sanitizer code. It can be called from
165 # the sanitizer runtimes, so instrumenting these functions could cause 165 # the sanitizer runtimes, so instrumenting these functions could cause
166 # recursive calls into the runtime if there is an error. 166 # recursive calls into the runtime if there is an error.
167 configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] 167 configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
168 168
169 if (is_asan) { 169 if (is_asan) {
170 if (!defined(asan_suppressions_file)) {
171 asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
172 }
170 sources += [ asan_suppressions_file ] 173 sources += [ asan_suppressions_file ]
171 } 174 }
172 175
173 if (is_lsan) { 176 if (is_lsan) {
177 if (!defined(lsan_suppressions_file)) {
178 lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
179 }
174 sources += [ lsan_suppressions_file ] 180 sources += [ lsan_suppressions_file ]
175 } 181 }
176 182
177 if (is_tsan) { 183 if (is_tsan) {
184 if (!defined(tsan_suppressions_file)) {
185 tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
186 }
178 sources += [ tsan_suppressions_file ] 187 sources += [ tsan_suppressions_file ]
179 } 188 }
180 } 189 }
181 190
182 # Applies linker flags necessary when either :deps or :default_sanitizer_flags 191 # Applies linker flags necessary when either :deps or :default_sanitizer_flags
183 # are used. 192 # are used.
184 config("default_sanitizer_ldflags") { 193 config("default_sanitizer_ldflags") {
185 visibility = [ 194 visibility = [
186 ":default_sanitizer_flags", 195 ":default_sanitizer_flags",
187 ":deps", 196 ":deps",
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 cflags = [] 309 cflags = []
301 if (is_asan) { 310 if (is_asan) {
302 cflags += [ "-fsanitize=address" ] 311 cflags += [ "-fsanitize=address" ]
303 if (!asan_globals) { 312 if (!asan_globals) {
304 cflags += [ 313 cflags += [
305 "-mllvm", 314 "-mllvm",
306 "-asan-globals=0", 315 "-asan-globals=0",
307 ] 316 ]
308 } 317 }
309 if (is_win) { 318 if (is_win) {
310 cflags += [ "-fsanitize-blacklist=" + 319 if (!defined(asan_win_blacklist_path)) {
311 rebase_path("//tools/memory/asan/blacklist_win.txt", 320 asan_win_blacklist_path =
312 root_build_dir) ] 321 rebase_path("//tools/memory/asan/blacklist_win.txt", root_build_dir)
322 }
323 cflags += [ "-fsanitize-blacklist=$asan_win_blacklist_path" ]
313 } else { 324 } else {
314 # TODO(rnk): Remove this as discussed in http://crbug.com/427202. 325 # TODO(rnk): Remove this as discussed in http://crbug.com/427202.
315 cflags += 326 if (!defined(asan_blacklist_path)) {
316 [ "-fsanitize-blacklist=" + 327 asan_blacklist_path =
317 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) ] 328 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir)
329 }
330 cflags += [ "-fsanitize-blacklist=$asan_blacklist_path" ]
318 } 331 }
319 } 332 }
320 } 333 }
321 334
322 config("link_executable") { 335 config("link_executable") {
323 if (is_asan && is_win && !is_component_build) { 336 if (is_asan && is_win && !is_component_build) {
324 if (target_cpu == "x64") { 337 if (target_cpu == "x64") {
325 # Windows 64-bit. TODO(etienneb): Remove the assert when this is ready. 338 # Windows 64-bit. TODO(etienneb): Remove the assert when this is ready.
326 assert(false, "win/asan does not work in 64-bit yet") 339 assert(false, "win/asan does not work in 64-bit yet")
327 libs = [ "clang_rt.asan-x86_64.lib" ] 340 libs = [ "clang_rt.asan-x86_64.lib" ]
(...skipping 13 matching lines...) Expand all
341 } else { 354 } else {
342 assert(target_cpu == "x86", "WinASan unsupported architecture") 355 assert(target_cpu == "x86", "WinASan unsupported architecture")
343 libs = [ "clang_rt.asan_dll_thunk-i386.lib" ] 356 libs = [ "clang_rt.asan_dll_thunk-i386.lib" ]
344 } 357 }
345 } 358 }
346 } 359 }
347 360
348 config("cfi_flags") { 361 config("cfi_flags") {
349 cflags = [] 362 cflags = []
350 if (is_cfi && !is_nacl) { 363 if (is_cfi && !is_nacl) {
351 cfi_blacklist_path = 364 if (!defined(cfi_blacklist_path)) {
352 rebase_path("//tools/cfi/blacklist.txt", root_build_dir) 365 cfi_blacklist_path =
366 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
367 }
353 cflags += [ 368 cflags += [
354 "-fsanitize=cfi-vcall", 369 "-fsanitize=cfi-vcall",
355 "-fsanitize-blacklist=$cfi_blacklist_path", 370 "-fsanitize-blacklist=$cfi_blacklist_path",
356 ] 371 ]
357 372
358 if (use_cfi_cast) { 373 if (use_cfi_cast) {
359 cflags += [ 374 cflags += [
360 "-fsanitize=cfi-derived-cast", 375 "-fsanitize=cfi-derived-cast",
361 "-fsanitize=cfi-unrelated-cast", 376 "-fsanitize=cfi-unrelated-cast",
362 ] 377 ]
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 414
400 config("lsan_flags") { 415 config("lsan_flags") {
401 if (is_lsan) { 416 if (is_lsan) {
402 cflags = [ "-fsanitize=leak" ] 417 cflags = [ "-fsanitize=leak" ]
403 } 418 }
404 } 419 }
405 420
406 config("msan_flags") { 421 config("msan_flags") {
407 if (is_msan) { 422 if (is_msan) {
408 assert(is_linux, "msan only supported on linux x86_64") 423 assert(is_linux, "msan only supported on linux x86_64")
409 msan_blacklist_path = 424 if (!defined(msan_blacklist_path)) {
410 rebase_path("//tools/msan/blacklist.txt", root_build_dir) 425 msan_blacklist_path =
426 rebase_path("//tools/msan/blacklist.txt", root_build_dir)
427 }
411 cflags = [ 428 cflags = [
412 "-fsanitize=memory", 429 "-fsanitize=memory",
413 "-fsanitize-memory-track-origins=$msan_track_origins", 430 "-fsanitize-memory-track-origins=$msan_track_origins",
414 "-fsanitize-blacklist=$msan_blacklist_path", 431 "-fsanitize-blacklist=$msan_blacklist_path",
415 ] 432 ]
416 } 433 }
417 } 434 }
418 435
419 config("tsan_flags") { 436 config("tsan_flags") {
420 if (is_tsan) { 437 if (is_tsan) {
421 assert(is_linux, "tsan only supported on linux x86_64") 438 assert(is_linux, "tsan only supported on linux x86_64")
422 tsan_blacklist_path = 439 if (!defined(tsan_blacklist_path)) {
423 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) 440 tsan_blacklist_path =
441 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
442 }
424 cflags = [ 443 cflags = [
425 "-fsanitize=thread", 444 "-fsanitize=thread",
426 "-fsanitize-blacklist=$tsan_blacklist_path", 445 "-fsanitize-blacklist=$tsan_blacklist_path",
427 ] 446 ]
428 } 447 }
429 } 448 }
430 449
431 # UBSan is still in bring-up. Chrome builds with is_ubsan=true, but if you 450 # UBSan is still in bring-up. Chrome builds with is_ubsan=true, but if you
432 # set is_ubsan=true is_ubsan_no_recover = true, then many tests are still 451 # set is_ubsan=true is_ubsan_no_recover = true, then many tests are still
433 # failing. 452 # failing.
434 config("ubsan_flags") { 453 config("ubsan_flags") {
435 cflags = [] 454 cflags = []
436 if (is_ubsan) { 455 if (is_ubsan) {
437 ubsan_blacklist_path = 456 if (!defined(ubsan_blacklist_path)) {
438 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) 457 ubsan_blacklist_path =
458 rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
459 }
439 cflags += [ 460 cflags += [
440 # Yasm dies with an "Illegal instruction" error when bounds checking is 461 # Yasm dies with an "Illegal instruction" error when bounds checking is
441 # enabled. See http://crbug.com/489901 462 # enabled. See http://crbug.com/489901
442 # "-fsanitize=bounds", 463 # "-fsanitize=bounds",
443 "-fsanitize=float-divide-by-zero", 464 "-fsanitize=float-divide-by-zero",
444 "-fsanitize=float-cast-overflow", 465 "-fsanitize=float-cast-overflow",
445 "-fsanitize=integer-divide-by-zero", 466 "-fsanitize=integer-divide-by-zero",
446 "-fsanitize=null", 467 "-fsanitize=null",
447 "-fsanitize=object-size", 468 "-fsanitize=object-size",
448 "-fsanitize=return", 469 "-fsanitize=return",
(...skipping 25 matching lines...) Expand all
474 } 495 }
475 496
476 config("ubsan_no_recover") { 497 config("ubsan_no_recover") {
477 if (is_ubsan_no_recover) { 498 if (is_ubsan_no_recover) {
478 cflags = [ "-fno-sanitize-recover=undefined" ] 499 cflags = [ "-fno-sanitize-recover=undefined" ]
479 } 500 }
480 } 501 }
481 502
482 config("ubsan_security_flags") { 503 config("ubsan_security_flags") {
483 if (is_ubsan_security) { 504 if (is_ubsan_security) {
484 ubsan_security_blacklist_path = 505 if (!defined(ubsan_security_blacklist_path)) {
485 rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir) 506 ubsan_security_blacklist_path =
507 rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir)
508 }
486 cflags = [ 509 cflags = [
487 "-fsanitize=signed-integer-overflow,shift,vptr,function,vla-bound", 510 "-fsanitize=signed-integer-overflow,shift,vptr,function,vla-bound",
488 "-fsanitize-blacklist=$ubsan_security_blacklist_path", 511 "-fsanitize-blacklist=$ubsan_security_blacklist_path",
489 ] 512 ]
490 } 513 }
491 } 514 }
492 515
493 config("ubsan_null_flags") { 516 config("ubsan_null_flags") {
494 if (is_ubsan_null) { 517 if (is_ubsan_null) {
495 cflags = [ "-fsanitize=null" ] 518 cflags = [ "-fsanitize=null" ]
496 } 519 }
497 } 520 }
498 521
499 config("ubsan_vptr_flags") { 522 config("ubsan_vptr_flags") {
500 if (is_ubsan_vptr) { 523 if (is_ubsan_vptr) {
501 ubsan_vptr_blacklist_path = 524 if (!defined(ubsan_vptr_blacklist_path)) {
502 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) 525 ubsan_vptr_blacklist_path =
526 rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
527 }
503 cflags = [ 528 cflags = [
504 "-fsanitize=vptr", 529 "-fsanitize=vptr",
505 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", 530 "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
506 ] 531 ]
507 } 532 }
508 } 533 }
509 534
510 all_sanitizer_configs = [ 535 all_sanitizer_configs = [
511 ":common_sanitizer_flags", 536 ":common_sanitizer_flags",
512 ":coverage_flags", 537 ":coverage_flags",
(...skipping 26 matching lines...) Expand all
539 # This allows to selectively disable ubsan_vptr, when needed. In particular, 564 # This allows to selectively disable ubsan_vptr, when needed. In particular,
540 # if some third_party code is required to be compiled without rtti, which 565 # if some third_party code is required to be compiled without rtti, which
541 # is a requirement for ubsan_vptr. 566 # is a requirement for ubsan_vptr.
542 config("default_sanitizer_flags_but_ubsan_vptr") { 567 config("default_sanitizer_flags_but_ubsan_vptr") {
543 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] 568 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ]
544 } 569 }
545 570
546 config("default_sanitizer_flags_but_coverage") { 571 config("default_sanitizer_flags_but_coverage") {
547 configs = all_sanitizer_configs - [ ":coverage_flags" ] 572 configs = all_sanitizer_configs - [ ":coverage_flags" ]
548 } 573 }
OLDNEW
« no previous file with comments | « no previous file | build_overrides/build.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698