Index: build/common.gypi |
diff --git a/build/common.gypi b/build/common.gypi |
index 1aa13d3dc9cbd0a2fe1362e728c9121728bf05c5..8698bb93666c0824d9750d8b585e7e1a699510be 100644 |
--- a/build/common.gypi |
+++ b/build/common.gypi |
@@ -632,6 +632,15 @@ |
# compiler. Always do this by default. |
'host_clang%': 1, |
+ # Link-Time Optimizations |
pasko
2014/10/20 14:12:20
I think it would be clearer if written like this:
Fabrice (no longer in Chrome)
2014/10/22 14:10:41
Done.
|
+ # crbug.com/407544 |
+ 'use_lto%': 0, |
+ # Enable LTO on code compiled with -O2. |
+ # Do not use both options at the same time as that will result with |
+ # the whole code being optimized with -O2 due to the way LTO merges |
+ # optimization flags at link-time. |
+ 'use_lto_o2%': 0, |
+ |
'conditions': [ |
# A flag for POSIX platforms |
['OS=="win"', { |
@@ -1179,6 +1188,8 @@ |
'proprietary_codecs%': '<(proprietary_codecs)', |
'use_goma%': '<(use_goma)', |
'gomadir%': '<(gomadir)', |
+ 'use_lto%': '<(use_lto)', |
+ 'use_lto_o2%': '<use_lto_o2', |
pasko
2014/10/20 14:12:20
parens for consistency please
Fabrice (no longer in Chrome)
2014/10/22 14:10:41
Done.
|
'video_hole%': '<(video_hole)', |
'enable_load_completion_hacks%': '<(enable_load_completion_hacks)', |
'support_pre_M6_history_database%': '<(support_pre_M6_history_database)', |
@@ -2303,6 +2314,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 |
@@ -3745,6 +3761,13 @@ |
'cflags': [ |
'-march=<(arm_arch)', |
], |
+ 'conditions': [ |
+ ['use_lto==1 or use_lto_o2==1', { |
+ 'ldflags': [ |
+ '-march=<(arm_arch)', |
+ ], |
+ }], |
+ ], |
}], |
['clang==1 and OS!="android"', { |
'cflags': [ |
@@ -3757,21 +3780,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 |
@@ -5666,6 +5717,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! |