Chromium Code Reviews| Index: build/config/sanitizers/BUILD.gn |
| diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn |
| index f3469e2098dbf029b3a60cece61eede689504026..9e38105baf189136dba78123b8e19451edca1323 100644 |
| --- a/build/config/sanitizers/BUILD.gn |
| +++ b/build/config/sanitizers/BUILD.gn |
| @@ -36,7 +36,7 @@ group("deps") { |
| } |
| config("sanitizer_options_link_helper") { |
| - if (!is_mac) { |
| + if (!is_mac && !is_win) { |
| ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] |
| } |
| } |
| @@ -152,157 +152,170 @@ config("default_sanitizer_flags") { |
| # Sanitizers need line table info for stack traces. They don't need type info |
| # or variable info, so we can leave that out to speed up the build. |
| - if (is_clang && using_sanitizer) { |
| + if (using_sanitizer) { |
| + assert(is_clang, "sanitizers only supported with clang") |
| cflags += [ "-gline-tables-only" ] |
| } |
| - # Only works on Posix-like platforms. |
| - # FIXME: this is not true, remove the conditional. |
| - if (is_posix) { |
| - # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, |
| - # MemorySanitizer and non-official CFI builds. |
| - if (using_sanitizer || (is_lto && !is_official_build)) { |
| + # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, |
| + # MemorySanitizer and non-official CFI builds. |
| + if (using_sanitizer || (is_lto && !is_official_build)) { |
| + if (is_posix) { |
| cflags += [ "-fno-omit-frame-pointer" ] |
| + } else { |
| + cflags += [ "/Oy-" ] |
| } |
| - if (is_asan) { |
| - asan_blacklist_path = |
| - rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) |
| - cflags += [ |
| - "-fsanitize=address", |
| - "-fsanitize-blacklist=$asan_blacklist_path", |
|
Nico
2016/03/31 02:09:32
It looks like the only reason we don't pass this i
Reid Kleckner
2016/03/31 16:39:15
The blacklist file is empty, though. I think we sh
Nico
2016/03/31 16:53:54
Ok, but that shouldn't be in a "asan in gn for Win
|
| - ] |
| - if (is_android) { |
| - # Android build relies on -Wl,--gc-sections removing unreachable code. |
| - # ASan instrumentation for globals inhibits this and results in a |
| - # library with unresolvable relocations. |
| - # TODO(eugenis): find a way to reenable this. |
| - cflags += [ |
| - "-mllvm", |
| - "-asan-globals=0", |
| - ] |
| - } else if (is_mac) { |
| - # http://crbug.com/352073 |
| - cflags += [ |
| - "-mllvm", |
| - "-asan-globals=0", |
| - ] |
| - # TODO(GYP): deal with mac_bundles. |
| - } |
| - } |
| - if (is_lsan) { |
| - cflags += [ "-fsanitize=leak" ] |
| - } |
| - if (is_tsan) { |
| - tsan_blacklist_path = |
| - rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) |
| - cflags += [ |
| - "-fsanitize=thread", |
| - "-fsanitize-blacklist=$tsan_blacklist_path", |
| - ] |
| - } |
| - if (is_msan) { |
| - msan_blacklist_path = |
| - rebase_path("//tools/msan/blacklist.txt", root_build_dir) |
| + } |
| + if (is_asan) { |
| + cflags += [ "-fsanitize=address" ] |
| + if (is_android) { |
| + # Android build relies on -Wl,--gc-sections removing unreachable code. |
| + # ASan instrumentation for globals inhibits this and results in a |
| + # library with unresolvable relocations. |
| + # TODO(eugenis): find a way to reenable this. |
| cflags += [ |
| - "-fsanitize=memory", |
| - "-fsanitize-memory-track-origins=$msan_track_origins", |
| - "-fsanitize-blacklist=$msan_blacklist_path", |
| + "-mllvm", |
| + "-asan-globals=0", |
| ] |
| - } |
| - if (is_ubsan) { |
| - ubsan_blacklist_path = |
| - rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) |
| + } else if (is_mac) { |
| + # http://crbug.com/352073 |
| cflags += [ |
| - # Yasm dies with an "Illegal instruction" error when bounds checking is |
| - # enabled. See http://crbug.com/489901 |
| - # "-fsanitize=bounds", |
| - "-fsanitize=float-divide-by-zero", |
| - "-fsanitize=integer-divide-by-zero", |
| - "-fsanitize=null", |
| - "-fsanitize=object-size", |
| - "-fsanitize=return", |
| - "-fsanitize=returns-nonnull-attribute", |
| - "-fsanitize=shift-exponent", |
| - "-fsanitize=signed-integer-overflow", |
| - "-fsanitize=unreachable", |
| - "-fsanitize=vla-bound", |
| - "-fsanitize-blacklist=$ubsan_blacklist_path", |
| + "-mllvm", |
| + "-asan-globals=0", |
| ] |
| + libs = [ "clang_rt.asan_osx_dynamic" ] |
| - # Chromecast ubsan builds fail to compile with these |
| - # experimental flags, so only add them to non-chromecast ubsan builds. |
| - if (!is_chromecast) { |
| - cflags += [ |
| - # Employ the experimental PBQP register allocator to avoid slow |
| - # compilation on files with too many basic blocks. |
| - # See http://crbug.com/426271. |
| - "-mllvm", |
| - "-regalloc=pbqp", |
| + # TODO(GYP): deal with mac_bundles. |
| + } else if (is_win) { |
| + assert(target_cpu == "x86", "WinASan is 32-bit only currently") |
| - # Speculatively use coalescing to slightly improve the code generated |
| - # by PBQP regallocator. May increase compile time. |
| - "-mllvm", |
| - "-pbqp-coalescing", |
| + # We still need a blacklist on Windows. |
| + cflags += [ "-fsanitize-blacklist=" + |
| + rebase_path("//tools/memory/asan/blacklist_win.txt", |
| + root_build_dir) ] |
| + if (is_component_build) { |
| + libs = [ |
| + "clang_rt.asan_dynamic-i386.lib", |
| + "clang_rt.asan_dynamic_runtime_thunk-i386.lib", |
| ] |
| + } else { |
| + # TODO(rnk): DLLs in the non-component build should link against |
| + # clang_rt.asan_dll_thunk-i386.lib instead. |
|
Nico
2016/03/31 02:09:32
Dirk: is there some easy way in gn to check "is th
Dirk Pranke
2016/03/31 02:28:39
Nope.
However, if what you want is some settings
Reid Kleckner
2016/03/31 16:39:15
Yep, I figured the logic would have to move. Anywa
|
| + libs = [ "clang_rt.asan-i386.lib" ] |
| } |
| } |
| - if (is_ubsan_vptr) { |
| - ubsan_vptr_blacklist_path = |
| - rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) |
| + } |
| + if (is_lsan) { |
| + cflags += [ "-fsanitize=leak" ] |
| + } |
| + if (is_tsan) { |
| + assert(is_linux, "tsan only supported on linux x86_64") |
| + tsan_blacklist_path = |
| + rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) |
| + cflags += [ |
| + "-fsanitize=thread", |
| + "-fsanitize-blacklist=$tsan_blacklist_path", |
| + ] |
| + } |
| + if (is_msan) { |
| + assert(is_linux, "msan only supported on linux x86_64") |
| + msan_blacklist_path = |
| + rebase_path("//tools/msan/blacklist.txt", root_build_dir) |
| + cflags += [ |
| + "-fsanitize=memory", |
| + "-fsanitize-memory-track-origins=$msan_track_origins", |
| + "-fsanitize-blacklist=$msan_blacklist_path", |
| + ] |
| + } |
| + if (is_ubsan) { |
| + ubsan_blacklist_path = |
| + rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) |
| + cflags += [ |
| + # Yasm dies with an "Illegal instruction" error when bounds checking is |
| + # enabled. See http://crbug.com/489901 |
| + # "-fsanitize=bounds", |
| + "-fsanitize=float-divide-by-zero", |
| + "-fsanitize=integer-divide-by-zero", |
| + "-fsanitize=null", |
| + "-fsanitize=object-size", |
| + "-fsanitize=return", |
| + "-fsanitize=returns-nonnull-attribute", |
| + "-fsanitize=shift-exponent", |
| + "-fsanitize=signed-integer-overflow", |
| + "-fsanitize=unreachable", |
| + "-fsanitize=vla-bound", |
| + "-fsanitize-blacklist=$ubsan_blacklist_path", |
| + ] |
| + |
| + # Chromecast ubsan builds fail to compile with these |
| + # experimental flags, so only add them to non-chromecast ubsan builds. |
|
Nico
2016/03/31 02:09:32
Huh? (not your code, only talking to myself)
|
| + if (!is_chromecast) { |
| cflags += [ |
| - "-fsanitize=vptr", |
| - "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", |
| + # Employ the experimental PBQP register allocator to avoid slow |
| + # compilation on files with too many basic blocks. |
| + # See http://crbug.com/426271. |
| + "-mllvm", |
| + "-regalloc=pbqp", |
| + |
| + # Speculatively use coalescing to slightly improve the code generated |
| + # by PBQP regallocator. May increase compile time. |
| + "-mllvm", |
| + "-pbqp-coalescing", |
| ] |
| } |
| - if (is_ubsan_security) { |
| - ubsan_blacklist_path = |
| - rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) |
| + } |
| + if (is_ubsan_vptr) { |
| + ubsan_vptr_blacklist_path = |
| + rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir) |
| + cflags += [ |
| + "-fsanitize=vptr", |
| + "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", |
| + ] |
| + } |
| + if (is_ubsan_security) { |
| + ubsan_blacklist_path = |
| + rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) |
| + cflags += [ |
| + "-fsanitize=signed-integer-overflow", |
| + "-fsanitize-blacklist=$ubsan_blacklist_path", |
| + ] |
| + } |
| + if (is_lto && !is_nacl) { |
| + cflags += [ "-flto" ] |
| + |
| + if (is_cfi) { |
| + cfi_blacklist_path = |
| + rebase_path("//tools/cfi/blacklist.txt", root_build_dir) |
| cflags += [ |
| - "-fsanitize=signed-integer-overflow", |
| - "-fsanitize-blacklist=$ubsan_blacklist_path", |
| + "-fsanitize=cfi-vcall", |
| + "-fsanitize=cfi-derived-cast", |
| + "-fsanitize=cfi-unrelated-cast", |
| + "-fsanitize-blacklist=$cfi_blacklist_path", |
| ] |
| } |
| - if (is_lto && !is_nacl) { |
| - cflags += [ "-flto" ] |
| - if (is_cfi) { |
| - cfi_blacklist_path = |
| - rebase_path("//tools/cfi/blacklist.txt", root_build_dir) |
| - cflags += [ |
| - "-fsanitize=cfi-vcall", |
| - "-fsanitize=cfi-derived-cast", |
| - "-fsanitize=cfi-unrelated-cast", |
| - "-fsanitize-blacklist=$cfi_blacklist_path", |
| - ] |
| - } |
| - |
| - if (use_cfi_diag) { |
| - cflags += [ |
| - "-fno-sanitize-trap=cfi", |
| - "-fsanitize-recover=cfi", |
| - "-fno-inline-functions", |
| - "-fno-inline", |
| - "-fno-omit-frame-pointer", |
| - "-O1", |
| - ] |
| - } else { |
| - defines += [ "CFI_ENFORCEMENT" ] |
| - } |
| - } |
| - |
| - if (use_custom_libcxx) { |
| - prefix = "//buildtools/third_party" |
| - include = "trunk/include" |
| - cflags_cc += [ |
| - "-nostdinc++", |
| - "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir), |
| - "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir), |
| + if (use_cfi_diag) { |
| + cflags += [ |
| + "-fno-sanitize-trap=cfi", |
| + "-fsanitize-recover=cfi", |
| + "-fno-inline-functions", |
| + "-fno-inline", |
| + "-fno-omit-frame-pointer", |
| + "-O1", |
| ] |
| + } else { |
| + defines += [ "CFI_ENFORCEMENT" ] |
| } |
| } |
| - if (is_mac && is_asan) { |
| - libs = [ "clang_rt.asan_osx_dynamic" ] |
| + if (use_custom_libcxx) { |
| + prefix = "//buildtools/third_party" |
| + include = "trunk/include" |
| + cflags_cc += [ |
| + "-nostdinc++", |
| + "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir), |
| + "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir), |
| + ] |
| } |
| } |