Index: build/common.gypi |
diff --git a/build/common.gypi b/build/common.gypi |
index 8f9cb381cfe09b36f4bbf64e5e6957d620e4cd05..ad0261cf5480ed6bda6e3a81515e2b25e75f9cb2 100644 |
--- a/build/common.gypi |
+++ b/build/common.gypi |
@@ -387,10 +387,13 @@ |
# -fsanitize=address only works with clang, but asan=1 implies clang=1 |
# See https://sites.google.com/a/chromium.org/dev/developers/testing/addresssanitizer |
'asan%': 0, |
+ 'asan_blacklist%': '<(PRODUCT_DIR)/../../tools/memory/asan/blacklist.txt', |
# Enable coverage gathering instrumentation in ASan. This flag also |
# controls coverage granularity (1 for function-level coverage, 2 for |
# block-level coverage). |
'asan_coverage%': 0, |
+ # Enable intra-object-overflow detection in ASan (experimental). |
+ 'asan_field_padding%': 0, |
# Enable Chromium overrides of the default configurations for various |
# dynamic tools (like ASan). |
@@ -637,6 +640,16 @@ |
# compiler. Always do this by default. |
'host_clang%': 1, |
+ # Variables to control Link-Time Optimizations (LTO). |
+ # Note: the variables must *not* be enabled at the same time. |
+ # In this case LTO would 'merge' the optimization flags |
+ # at link-time which would lead to all code be optimized with -O2. |
+ # Enable LTO on the code compiled with -Os. |
+ # See crbug.com/407544 |
+ 'use_lto%': 0, |
+ # Enable LTO on code compiled with -O2. |
+ 'use_lto_o2%': 0, |
+ |
'conditions': [ |
# A flag for POSIX platforms |
['OS=="win"', { |
@@ -1110,7 +1123,9 @@ |
'clang_use_chrome_plugins%': '<(clang_use_chrome_plugins)', |
'mac_want_real_dsym%': '<(mac_want_real_dsym)', |
'asan%': '<(asan)', |
+ 'asan_blacklist%': '<(asan_blacklist)', |
'asan_coverage%': '<(asan_coverage)', |
+ 'asan_field_padding%': '<(asan_field_padding)', |
'use_sanitizer_options%': '<(use_sanitizer_options)', |
'syzyasan%': '<(syzyasan)', |
'syzygy_optimize%': '<(syzygy_optimize)', |
@@ -1185,6 +1200,8 @@ |
'proprietary_codecs%': '<(proprietary_codecs)', |
'use_goma%': '<(use_goma)', |
'gomadir%': '<(gomadir)', |
+ 'use_lto%': '<(use_lto)', |
+ 'use_lto_o2%': '<(use_lto_o2)', |
'video_hole%': '<(video_hole)', |
'enable_load_completion_hacks%': '<(enable_load_completion_hacks)', |
'support_pre_M6_history_database%': '<(support_pre_M6_history_database)', |
@@ -2313,6 +2330,11 @@ |
}, { |
'use_seccomp_bpf%': 0, |
}], |
+ # Set component build with LTO until all tests pass. |
+ # This also reduces link time. |
+ ['use_lto==1', { |
+ 'component%': "shared_library", |
+ }], |
], |
# older history files use fts2 instead of fts3 |
@@ -3755,6 +3777,13 @@ |
'cflags': [ |
'-march=<(arm_arch)', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-march=<(arm_arch)', |
+ ], |
+ }], |
+ ], |
}], |
['clang==1 and OS!="android"', { |
'cflags': [ |
@@ -3767,21 +3796,49 @@ |
'cflags': [ |
'-mtune=<(arm_tune)', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-mtune=<(arm_tune)', |
+ ], |
+ }], |
+ ], |
}], |
['arm_fpu!=""', { |
'cflags': [ |
'-mfpu=<(arm_fpu)', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-mfpu=<(arm_fpu)', |
+ ], |
+ }], |
+ ], |
}], |
['arm_float_abi!=""', { |
'cflags': [ |
'-mfloat-abi=<(arm_float_abi)', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-mfloat-abi=<(arm_float_abi)', |
+ ], |
+ }], |
+ ], |
}], |
['arm_thumb==1', { |
'cflags': [ |
'-mthumb', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-mthumb', |
+ ], |
+ }], |
+ ], |
}], |
['OS=="android"', { |
# Most of the following flags are derived from what Android |
@@ -4060,6 +4117,7 @@ |
['_toolset=="target"', { |
'cflags': [ |
'-fsanitize=address', |
+ '-fsanitize-blacklist=<(asan_blacklist)', |
], |
'ldflags': [ |
'-fsanitize=address', |
@@ -4121,6 +4179,15 @@ |
}], |
], |
}], |
+ ['asan_field_padding!=0', { |
+ 'target_conditions': [ |
+ ['_toolset=="target"', { |
+ 'cflags': [ |
+ '-fsanitize-address-field-padding=<(asan_field_padding)', |
+ ], |
+ }], |
+ ], |
+ }], |
['lsan==1', { |
'target_conditions': [ |
['_toolset=="target"', { |
@@ -5685,6 +5752,29 @@ |
['CXX.host_wrapper', '<(gomadir)/gomacc'], |
], |
}], |
+ ['use_lto==1', { |
+ 'target_defaults': { |
+ 'target_conditions': [ |
+ ['_toolset=="target"', { |
+ 'cflags': [ |
+ '-flto', |
+ '-ffat-lto-objects', |
+ ], |
+ }], |
+ ], |
+ }, |
+ }], |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'target_defaults': { |
+ 'target_conditions': [ |
+ ['_toolset=="target"', { |
+ 'ldflags': [ |
+ '-flto=32', |
+ ], |
+ }], |
+ ], |
+ }, |
+ }], |
], |
'xcode_settings': { |
# DON'T ADD ANYTHING NEW TO THIS BLOCK UNLESS YOU REALLY REALLY NEED IT! |