Commit 14a926ac authored by inglorion's avatar inglorion Committed by Commit Bot

Add gn arg use_goma_thin_lto to enable ThinLTO code generation on Goma

This adds a gn arg, use_goma_thin_lto. When true, this enables a
linker wrapper which causes ThinLTO code generation to be distributed
using Goma. This can be used to reduce build time compared to a
non-distributed ThinLTO build. The new gn arg allows this feature
to be controlled by the build configuration, allowing distributed
ThinLTO to be rolled out gradually. The arg defaults to false.

R=akhuang,gbiv,hans,rnk,thakis

Bug: 877722
Change-Id: Ibe4dac1669b297e8cb865dcfd3fe512f8f0cdf60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067858
Commit-Queue: Bob Haarman <inglorion@chromium.org>
Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744473}
parent 389c3a67
...@@ -74,6 +74,9 @@ declare_args() { ...@@ -74,6 +74,9 @@ declare_args() {
(target_os == "chromeos" && (target_os == "chromeos" &&
is_chromeos_device && !is_android))) is_chromeos_device && !is_android)))
# Performs ThinLTO code generation on Goma.
use_goma_thin_lto = false
# Limit the number of jobs (threads/processes) the linker is allowed # Limit the number of jobs (threads/processes) the linker is allowed
# to use (for linkers that support this). # to use (for linkers that support this).
max_jobs_per_link = 8 max_jobs_per_link = 8
...@@ -101,6 +104,9 @@ declare_args() { ...@@ -101,6 +104,9 @@ declare_args() {
} }
assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO") assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO")
assert(
!use_goma_thin_lto || (use_goma && use_thin_lto),
"use_goma_thin_lto requires both use_goma and use_thin_lto to be enabled")
# If true, optimize for size. Does not affect windows builds. # If true, optimize for size. Does not affect windows builds.
# Linux & Mac favor speed over size. # Linux & Mac favor speed over size.
......
...@@ -157,14 +157,25 @@ template("gcc_toolchain") { ...@@ -157,14 +157,25 @@ template("gcc_toolchain") {
# But if needs_gomacc_path_arg is set in a Chrome OS build, the toolchain # But if needs_gomacc_path_arg is set in a Chrome OS build, the toolchain
# wrapper will have picked up gomacc via cmd-line arg. So need to prepend # wrapper will have picked up gomacc via cmd-line arg. So need to prepend
# gomacc in that case. # gomacc in that case.
goma_path = "$goma_dir/gomacc"
if (toolchain_uses_goma && if (toolchain_uses_goma &&
(!defined(invoker_toolchain_args.needs_gomacc_path_arg) || (!defined(invoker_toolchain_args.needs_gomacc_path_arg) ||
!invoker_toolchain_args.needs_gomacc_path_arg)) { !invoker_toolchain_args.needs_gomacc_path_arg)) {
goma_path = "$goma_dir/gomacc"
compiler_prefix = "${goma_path} " compiler_prefix = "${goma_path} "
} else { } else {
compiler_prefix = "${toolchain_cc_wrapper} " compiler_prefix = "${toolchain_cc_wrapper} "
} }
if (use_goma_thin_lto && toolchain_uses_goma) {
# goma_ld.py uses autoninja in an attempt to set a reasonable
# number of jobs, but this results in too low a value on
# Chrome OS builders. So we pass in an explicit value.
goma_ld =
rebase_path("//tools/clang/scripts/goma_ld.py", root_build_dir) +
" --gomacc ${goma_path} --jobs 100 -- "
} else {
goma_ld = ""
not_needed([ "goma_path" ])
}
# Create a distinct variable for "asm", since coverage runs pass a bunch of # Create a distinct variable for "asm", since coverage runs pass a bunch of
# flags to clang/clang++ that are nonsensical on assembler runs. # flags to clang/clang++ that are nonsensical on assembler runs.
...@@ -215,7 +226,7 @@ template("gcc_toolchain") { ...@@ -215,7 +226,7 @@ template("gcc_toolchain") {
cxx = compiler_prefix + invoker.cxx cxx = compiler_prefix + invoker.cxx
asm = asm_prefix + invoker.cc asm = asm_prefix + invoker.cc
ar = invoker.ar ar = invoker.ar
ld = invoker.ld ld = "$goma_ld${invoker.ld}"
if (defined(invoker.readelf)) { if (defined(invoker.readelf)) {
readelf = invoker.readelf readelf = invoker.readelf
} else { } else {
......
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