summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authoramistry <amistry@chromium.org>2015-09-29 17:18:32 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-30 00:31:38 +0000
commite4309543a4dcca98d54ae0ae44cb2eaa3f287c95 (patch)
tree03c0f5bd1a9fbcfb2a99fe81633fc32999fa3c1d /build
parentb8cc9ba3b9d0b8478bfd5d63130dfcfc69fbe6e6 (diff)
downloadchromium_src-e4309543a4dcca98d54ae0ae44cb2eaa3f287c95.zip
chromium_src-e4309543a4dcca98d54ae0ae44cb2eaa3f287c95.tar.gz
chromium_src-e4309543a4dcca98d54ae0ae44cb2eaa3f287c95.tar.bz2
Add Undefined Behaviour sanitizer support to GN.
BUG=527515 Review URL: https://codereview.chromium.org/1379503002 Cr-Commit-Position: refs/heads/master@{#351447}
Diffstat (limited to 'build')
-rw-r--r--build/config/BUILD.gn3
-rw-r--r--build/config/compiler/BUILD.gn2
-rw-r--r--build/config/compiler/compiler.gni2
-rw-r--r--build/config/sanitizers/BUILD.gn36
-rw-r--r--build/config/sanitizers/sanitizers.gni10
-rw-r--r--build/toolchain/gcc_toolchain.gni1
6 files changed, 48 insertions, 6 deletions
diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
index c8da546..39f79e6 100644
--- a/build/config/BUILD.gn
+++ b/build/config/BUILD.gn
@@ -168,6 +168,9 @@ config("feature_flags") {
if (is_msan) {
defines += [ "MEMORY_SANITIZER" ]
}
+ if (is_ubsan) {
+ defines += [ "UNDEFINED_SANITIZER" ]
+ }
if (enable_webrtc) {
defines += [ "ENABLE_WEBRTC=1" ]
}
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 1a7b68b..ef8fbd4 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -415,7 +415,7 @@ config("compiler") {
#"-Wl,--thread-count=4",
]
- if (!is_asan && !is_msan && !is_lsan && !is_tsan) {
+ if (!using_sanitizer) {
# TODO(brettw) common.gypi has this only for target toolset.
ldflags += [ "-Wl,--icf=all" ]
}
diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
index d5db930..7018247 100644
--- a/build/config/compiler/compiler.gni
+++ b/build/config/compiler/compiler.gni
@@ -21,7 +21,7 @@ if (symbol_level == -1) {
# Mac and Windows have them separate, so in Release Linux, default them off.
if (is_debug || !is_linux) {
symbol_level = 2
- } else if (is_asan || is_lsan || is_tsan || is_msan) {
+ } else if (using_sanitizer) {
# Sanitizers require symbols for filename suppressions to work.
symbol_level = 1
} else {
diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn
index 65bdbe4..c06e4e7 100644
--- a/build/config/sanitizers/BUILD.gn
+++ b/build/config/sanitizers/BUILD.gn
@@ -8,7 +8,7 @@ import("//build/config/sanitizers/sanitizers.gni")
# shared_libraries. Unconditionally depend upon this target as it is empty if
# |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false.
group("deps") {
- if (is_asan || is_lsan || is_tsan || is_msan) {
+ if (is_asan || is_lsan || is_tsan || is_msan || is_ubsan) {
public_configs = [ ":sanitizer_options_link_helper" ]
deps = [
":options_sources",
@@ -37,6 +37,9 @@ config("sanitizer_options_link_helper") {
if (is_msan) {
ldflags += [ "-fsanitize=memory" ]
}
+ if (is_ubsan) {
+ ldflags += [ "-fsanitize=undefined" ]
+ }
}
source_set("options_sources") {
@@ -119,6 +122,37 @@ config("default_sanitizer_flags") {
"-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",
+
+ # 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_cfi && !is_nacl) {
cfi_blacklist_path =
rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
diff --git a/build/config/sanitizers/sanitizers.gni b/build/config/sanitizers/sanitizers.gni
index 1aa212d..84348da 100644
--- a/build/config/sanitizers/sanitizers.gni
+++ b/build/config/sanitizers/sanitizers.gni
@@ -15,10 +15,14 @@ declare_args() {
# Compile for Thread Sanitizer to find threading bugs.
is_tsan = false
+ # Compile for Undefined Behaviour Sanitizer to find various types of
+ # undefined behaviour.
+ is_ubsan = false
+
# Use libc++ (buildtools/third_party/libc++ and
# buildtools/third_party/libc++abi) instead of stdlibc++ as standard library.
# This is intended to be used for instrumented builds.
- use_custom_libcxx = (is_asan && is_linux) || is_tsan || is_msan
+ use_custom_libcxx = (is_asan && is_linux) || is_tsan || is_msan || is_ubsan
# Track where uninitialized memory originates from. From fastest to slowest:
# 0 - no tracking, 1 - track only the initial allocation site, 2 - track the
@@ -45,7 +49,7 @@ declare_args() {
}
# TODO(GYP) bug 527515: is_ubsan, is_ubsan_vptr
-using_sanitizer = is_asan || is_lsan || is_tsan || is_msan
+using_sanitizer = is_asan || is_lsan || is_tsan || is_msan || is_ubsan
assert(!using_sanitizer || is_clang,
"Sanitizers (is_*san) require setting is_clang = true in 'gn args'")
@@ -63,5 +67,5 @@ assert(!using_sanitizer || is_clang,
# unsupported or unadvisable configurations.
#
# For one-off testing, just comment this assertion out.
-assert(!is_debug || !(is_msan || is_lsan || is_tsan),
+assert(!is_debug || !(is_msan || is_lsan || is_tsan || is_ubsan),
"Sanitizers should generally be used in release (set is_debug=false).")
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni
index 3871b3f..042a836 100644
--- a/build/toolchain/gcc_toolchain.gni
+++ b/build/toolchain/gcc_toolchain.gni
@@ -353,6 +353,7 @@ template("gcc_toolchain") {
is_msan = false
is_syzyasan = false
is_tsan = false
+ is_ubsan = false
}
}