Commit 4ff3eb61 authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Commit Bot

Reland^2 "build: Enable ThinLTO in official Android builds."

This relands commit 748ac91e.

Includes workaround for LTO bug exposed by orderfile generation:
add -Wl,-u,__cyg_profile_func_enter_bare to ldflags. A fix for the
bug is under review: https://reviews.llvm.org/D50017

Original change's description:
> Reland "build: Enable ThinLTO in official Android builds."
>
> This relands commit 1ba5d611.
>
> Fixes chromeos build issue by checking whether we have a secondary
> toolchain before comparing it with the current toolchain.
>
> Original change's description:
> > build: Enable ThinLTO in official Android builds.
> >
> > With this change we start building Chromium with ThinLTO when targeting
> > Android. In 64-bit Monochrome builds, the 32-bit binary is also built
> > with ThinLTO. This change is expected to reduce code size significantly
> > (in local measurements it reduced the size of MonochromePublic.apk by 2.3MB)
> > and is a prerequisite for enabling control flow integrity in official
> > builds.
> >
> > Note that although this change enables ThinLTO, it does not enable
> > the cross-TU optimizations normally associated with LTO. Enabling
> > cross-TU optimizations is a separate project.
> >
> > On my local machine (a Lenovo P920) libmonochrome.so link times increase
> > as follows:
> >
> >          before  after (first link)  after (incremental links)
> > 32-bit    18s          140s                     50s
> > 64-bit    13s          107s                     41s
> >
> > All known blockers have now been fixed. This CL is likely to uncover
> > unknown blockers.
> >
> > Bug: 469376
> > Change-Id: I8981e17abd50bc5ca00440e0d74dda878c911749
> > Reviewed-on: https://chromium-review.googlesource.com/1150870
> > Commit-Queue: Peter Collingbourne <pcc@chromium.org>
> > Reviewed-by: Nico Weber <thakis@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#578195}
>
> Bug: 469376, 868426
> Change-Id: Ie46ba0db0ac68130bc600415777de5c813b28ebd
> Reviewed-on: https://chromium-review.googlesource.com/1153612
> Reviewed-by: Dirk Pranke <dpranke@chromium.org>
> Commit-Queue: Peter Collingbourne <pcc@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#578854}

Bug: 469376, 867878
Change-Id: Iae4cc698b5955df5ae1970c71646fa05fca61109
Reviewed-on: https://chromium-review.googlesource.com/1155977Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579308}
parent 202eb7f8
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/android/config.gni") import("//build/config/android/config.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/c++/c++.gni") import("//build/config/c++/c++.gni")
import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sanitizers/sanitizers.gni")
...@@ -204,5 +205,10 @@ config("lld_pack_relocations") { ...@@ -204,5 +205,10 @@ config("lld_pack_relocations") {
config("default_orderfile_instrumentation") { config("default_orderfile_instrumentation") {
if (use_order_profiling) { if (use_order_profiling) {
cflags = [ "-finstrument-function-entry-bare" ] cflags = [ "-finstrument-function-entry-bare" ]
if (use_thin_lto) {
# TODO(pcc): This should not be necessary. Remove once
# https://reviews.llvm.org/D50017 lands and gets rolled in.
ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ]
}
} }
} }
...@@ -592,7 +592,10 @@ config("compiler") { ...@@ -592,7 +592,10 @@ config("compiler") {
# example by disabling the optimize configuration. # example by disabling the optimize configuration.
# TODO(pcc): Make this conditional on is_official_build rather than on gn # TODO(pcc): Make this conditional on is_official_build rather than on gn
# flags for specific features. # flags for specific features.
if (!is_debug && use_thin_lto && current_toolchain == default_toolchain) { if (!is_debug && use_thin_lto &&
(current_toolchain == default_toolchain ||
(is_android && defined(android_secondary_abi_toolchain) &&
current_toolchain == android_secondary_abi_toolchain))) {
assert(use_lld || target_os == "chromeos", assert(use_lld || target_os == "chromeos",
"gold plugin only supported with ChromeOS") "gold plugin only supported with ChromeOS")
......
...@@ -43,7 +43,7 @@ declare_args() { ...@@ -43,7 +43,7 @@ declare_args() {
# Enables support for ThinLTO, which links 3x-10x faster than full LTO. See # Enables support for ThinLTO, which links 3x-10x faster than full LTO. See
# also http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html # also http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html
use_thin_lto = is_cfi use_thin_lto = is_cfi || (is_android && is_official_build)
# Tell VS to create a PDB that references information in .obj files rather # Tell VS to create a PDB that references information in .obj files rather
# than copying it all. This should improve linker performance. mspdbcmf.exe # than copying it all. This should improve linker performance. mspdbcmf.exe
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment