Upstream-Status: Inappropriate Signed-off-by: Maksim Sisov --- From ab74e60870e8f515c5b94f90d9b0741492950de6 Mon Sep 17 00:00:00 2001 From: Maksim Sisov Date: Wed, 15 Sep 2021 14:29:03 +0300 Subject: [PATCH] limit number of LTO jobs. --thinlto-jobs accepts "all" only since llvm 13. Dunfell branch uses quite old llvm that doesn't support this keyword. Thus, use the previously used number of threads. --- build/config/compiler/BUILD.gn | 12 ++++++------ build/config/compiler/compiler.gni | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 219a2be0e1a1f..ae42271d99e49 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -664,7 +664,7 @@ config("compiler") { if (is_win) { ldflags += [ - "/opt:lldltojobs=all", + "/opt:lldltojobs=" + max_jobs_per_link, "-mllvm:-import-instr-limit=$import_instr_limit", "/lldltocache:" + rebase_path("$root_out_dir/thinlto-cache", root_build_dir), @@ -677,11 +677,11 @@ config("compiler") { # usage in crbug.com/1038040. Note this will increase build time in # Chrome OS. - # In ThinLTO builds, we run at most one link process at a time, - # and let it use all cores. - # TODO(thakis): Check if '=0' (that is, number of cores, instead - # of "all" which means number of hardware threads) is faster. - ldflags += [ "-Wl,--thinlto-jobs=all" ] + # Limit the parallelism to avoid too aggressive competition between + # linker jobs. This is still suboptimal to a potential dynamic + # resource allocation scheme, but should be good enough. + ldflags += [ "-Wl,--thinlto-jobs=" + max_jobs_per_link ] + if (is_mac) { ldflags += [ "-Wl,-cache_path_lto," + diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni index 932d4dff2cf81..20d8773d27525 100644 --- a/build/config/compiler/compiler.gni +++ b/build/config/compiler/compiler.gni @@ -80,6 +80,11 @@ declare_args() { # If true, use Goma for ThinLTO code generation where applicable. use_goma_thin_lto = false + # Limit the number of jobs (threads/processes) the linker is allowed + # to use (for linkers that support this). + # Upstream chromium uses "all" keyword that is available since llvm 13. + max_jobs_per_link = 8 + # Whether we're using a sample profile collected on an architecture different # than the one we're compiling for. # -- 2.25.1