summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/android/disable_lto.gypi20
-rw-r--r--build/android/increase_size_for_speed.gypi16
-rw-r--r--build/common.gypi75
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/chrome_browser_ui.gypi5
-rw-r--r--content/content.gyp3
-rw-r--r--gpu/gpu.gyp8
-rw-r--r--sandbox/linux/sandbox_linux.gypi5
-rw-r--r--skia/skia.gyp4
-rw-r--r--skia/skia_library_opts.gyp7
-rw-r--r--third_party/opus/opus.gyp7
-rw-r--r--third_party/sqlite/sqlite.gyp5
12 files changed, 159 insertions, 1 deletions
diff --git a/build/android/disable_lto.gypi b/build/android/disable_lto.gypi
new file mode 100644
index 0000000..448945c
--- /dev/null
+++ b/build/android/disable_lto.gypi
@@ -0,0 +1,20 @@
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is meant to be included to disable LTO on a target.
+
+{
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['use_lto==1 or use_lto_o2==1', {
+ 'cflags!': [
+ '-flto',
+ '-ffat-lto-objects',
+ ],
+ }],
+ ],
+ }],
+ ],
+}
diff --git a/build/android/increase_size_for_speed.gypi b/build/android/increase_size_for_speed.gypi
index f5f2d62..4081cd7 100644
--- a/build/android/increase_size_for_speed.gypi
+++ b/build/android/increase_size_for_speed.gypi
@@ -18,6 +18,22 @@
'cflags!': ['-Os'],
'cflags': ['-O2'],
}],
+ # Do not merge -Os and -O2 in LTO.
+ # LTO merges all optimization options at link-time. -O2 takes
+ # precedence over -Os. Avoid using LTO simultaneously
+ # on -Os and -O2 parts for that reason.
+ ['use_lto==1', {
+ 'cflags!': [
+ '-flto',
+ '-ffat-lto-objects',
+ ],
+ }],
+ ['use_lto_o2==1', {
+ 'cflags': [
+ '-flto',
+ '-ffat-lto-objects',
+ ],
+ }],
],
}],
],
diff --git a/build/common.gypi b/build/common.gypi
index 8f9cb38..23fe33f 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -637,6 +637,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"', {
@@ -1185,6 +1195,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 +2325,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 +3772,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 +3791,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
@@ -5685,6 +5737,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!
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a36c222..42ca732 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2899,6 +2899,11 @@
'sources': [
'<@(chrome_browser_undo_sources)',
],
+ 'includes': [
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../build/android/disable_lto.gypi',
+ ],
'conditions': [
['OS != "ios"', {
'dependencies': [
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 3718407..2a06e50 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2624,6 +2624,11 @@
'../components/components.gyp:dom_distiller_core',
'../sync/sync.gyp:sync',
],
+ 'includes': [
+ # Disable LTO due to undefined reference
+ # crbug.com/422252
+ '../build/android/disable_lto.gypi',
+ ],
'conditions': [
['OS != "ios"', {
'sources': [
diff --git a/content/content.gyp b/content/content.gyp
index 1b07104..5d843b64 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -150,6 +150,9 @@
'variables': { 'enable_wexit_time_destructors': 1, },
'includes': [
'content_browser.gypi',
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../build/android/disable_lto.gypi',
],
'dependencies': [
'content_common',
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index c152baf..5968dab 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -29,6 +29,11 @@
'sources': [
'<@(gles2_implementation_source_files)',
],
+ 'includes': [
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../build/android/disable_lto.gypi',
+ ],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [4267, ],
},
@@ -479,6 +484,9 @@
'includes': [
'command_buffer_service.gypi',
'../build/android/increase_size_for_speed.gypi',
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../build/android/disable_lto.gypi',
],
'dependencies': [
'command_buffer_common',
diff --git a/sandbox/linux/sandbox_linux.gypi b/sandbox/linux/sandbox_linux.gypi
index 72efda7..20dac8f 100644
--- a/sandbox/linux/sandbox_linux.gypi
+++ b/sandbox/linux/sandbox_linux.gypi
@@ -153,6 +153,11 @@
'defines': [
'SANDBOX_IMPLEMENTATION',
],
+ 'includes': [
+ # Disable LTO due to compiler bug
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57703
+ '../../build/android/disable_lto.gypi',
+ ],
'include_dirs': [
'../..',
],
diff --git a/skia/skia.gyp b/skia/skia.gyp
index c4129db..2d2668a 100644
--- a/skia/skia.gyp
+++ b/skia/skia.gyp
@@ -17,6 +17,10 @@
'skia_library.gypi',
'skia_common.gypi',
'../build/android/increase_size_for_speed.gypi',
+ # Disable LTO due to compiler error
+ # in mems_in_disjoint_alias_sets_p, at alias.c:393
+ # crbug.com/422255
+ '../build/android/disable_lto.gypi',
],
},
],
diff --git a/skia/skia_library_opts.gyp b/skia/skia_library_opts.gyp
index 5413721..6673105 100644
--- a/skia/skia_library_opts.gyp
+++ b/skia/skia_library_opts.gyp
@@ -30,6 +30,10 @@
'includes': [
'skia_common.gypi',
'../build/android/increase_size_for_speed.gypi',
+ # Disable LTO due to compiler error
+ # in mems_in_disjoint_alias_sets_p, at alias.c:393
+ # crbug.com/422255
+ '../build/android/disable_lto.gypi',
],
'include_dirs': [
'../third_party/skia/include/core',
@@ -298,6 +302,9 @@
'includes': [
'skia_common.gypi',
'../build/android/increase_size_for_speed.gypi',
+ # Disable LTO due to Neon issues
+ # crbug.com/408997
+ '../build/android/disable_lto.gypi',
],
'include_dirs': [
'../third_party/skia/include/core',
diff --git a/third_party/opus/opus.gyp b/third_party/opus/opus.gyp
index e6c4bcf..bc25921 100644
--- a/third_party/opus/opus.gyp
+++ b/third_party/opus/opus.gyp
@@ -40,7 +40,12 @@
'src/include',
],
},
- 'includes': ['opus_srcs.gypi', ],
+ 'includes': [
+ 'opus_srcs.gypi',
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../../build/android/disable_lto.gypi',
+ ],
'sources': ['<@(opus_common_sources)'],
'conditions': [
['OS!="win"', {
diff --git a/third_party/sqlite/sqlite.gyp b/third_party/sqlite/sqlite.gyp
index 2f80fc6..26bc36d 100644
--- a/third_party/sqlite/sqlite.gyp
+++ b/third_party/sqlite/sqlite.gyp
@@ -177,6 +177,11 @@
],
}],
],
+ 'includes': [
+ # Disable LTO due to ELF section name out of range
+ # crbug.com/422251
+ '../../build/android/disable_lto.gypi',
+ ],
},
],
'conditions': [