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

Unified Diff: build/config/compiler/BUILD.gn

Issue 682843002: Adds ability to build for asan with gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/config/allocator.gni ('k') | build/config/sanitizers/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/compiler/BUILD.gn
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index ba44d1a3ffb293b4e2a156e9f898f2b31a946dad..b80fa16a684dcda2b2c925923b406cff2c9932f0 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -45,6 +45,9 @@ config("default_include_dirs") {
]
}
+# TODO(GYP): is_ubsan, is_ubsan_vptr
+using_sanitizer = is_asan || is_lsan || is_tsan || is_msan
+
# compiler ---------------------------------------------------------------------
#
# Base compiler configuration.
@@ -103,6 +106,22 @@ config("compiler") {
# TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
ldflags += [ "-Wl,--fatal-warnings" ]
}
+
+ # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
+ # MemorySanitizer
+ if (using_sanitizer) {
+ cflags += [
+ "-fno-omit-frame-pointer",
+ "-gline-tables-only",
+ ]
+ }
+ if (is_asan) {
+ cflags += [ "-fsanitize=address" ]
+ if (is_mac) {
+ cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073
+ # TODO(GYP): deal with mac_bundles.
+ }
+ }
}
if (is_clang && is_debug) {
@@ -814,9 +833,9 @@ if (is_win) {
common_optimize_on_ldflags = []
if (is_android) {
- common_optimize_on_cflags += [
- "-fomit-frame-pointer",
- ]
+ if (!using_sanitizer) {
+ common_optimize_on_cflags += [ "-fomit-frame-pointer" ]
+ }
common_optimize_on_ldflags += [
# Warn in case of text relocations.
"-Wl,--warn-shared-textrel",
@@ -874,10 +893,12 @@ config("no_optimize") {
# much even when optimization is disabled to get the binary size down.
cflags = [
"-Os",
- "-fomit-frame-pointer",
"-fdata-sections",
"-ffunction-sections",
]
+ if (!using_sanitizer) {
+ cflags += [ "-fomit-frame-pointer" ]
+ }
ldflags = common_optimize_on_ldflags
} else {
cflags = [ "-O0" ]
« no previous file with comments | « build/config/allocator.gni ('k') | build/config/sanitizers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698