1From b8384ef181084c630d0073dcb81dfd338da40c42 Mon Sep 17 00:00:00 2001 2From: Maksim Sisov <msisov@igalia.com> 3Date: Wed, 15 Sep 2021 14:29:03 +0300 4Subject: [PATCH] limit number of LTO jobs. 5 6--thinlto-jobs accepts "all" only since llvm 13. Dunfell 7branch uses quite old llvm that doesn't support this keyword. 8Thus, use the previously used number of threads. 9 10Upstream-Status: Inappropriate 11 12Signed-off-by: Maksim Sisov <msisov@igalia.com> 13 14--- 15 build/config/compiler/BUILD.gn | 12 ++++++------ 16 build/config/compiler/compiler.gni | 5 +++++ 17 2 files changed, 11 insertions(+), 6 deletions(-) 18 19diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn 20index ef3285ae74e1b..a704f0f485e4e 100644 21--- a/build/config/compiler/BUILD.gn 22+++ b/build/config/compiler/BUILD.gn 23@@ -683,7 +683,7 @@ config("compiler") { 24 25 if (is_win) { 26 ldflags += [ 27- "/opt:lldltojobs=all", 28+ "/opt:lldltojobs=" + max_jobs_per_link, 29 "-mllvm:-import-instr-limit=$import_instr_limit", 30 "/lldltocache:" + 31 rebase_path("$root_out_dir/thinlto-cache", root_build_dir), 32@@ -696,11 +696,11 @@ config("compiler") { 33 # usage in crbug.com/1038040. Note this will increase build time in 34 # Chrome OS. 35 36- # In ThinLTO builds, we run at most one link process at a time, 37- # and let it use all cores. 38- # TODO(thakis): Check if '=0' (that is, number of cores, instead 39- # of "all" which means number of hardware threads) is faster. 40- ldflags += [ "-Wl,--thinlto-jobs=all" ] 41+ # Limit the parallelism to avoid too aggressive competition between 42+ # linker jobs. This is still suboptimal to a potential dynamic 43+ # resource allocation scheme, but should be good enough. 44+ ldflags += [ "-Wl,--thinlto-jobs=" + max_jobs_per_link ] 45+ 46 if (is_apple) { 47 _object_path_suffix = "" 48 if (is_ios) { 49diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni 50index 4738ee80d307c..7a43b1113a495 100644 51--- a/build/config/compiler/compiler.gni 52+++ b/build/config/compiler/compiler.gni 53@@ -99,6 +99,11 @@ declare_args() { 54 # If true, use Goma for ThinLTO code generation where applicable. 55 use_goma_thin_lto = false 56 57+ # Limit the number of jobs (threads/processes) the linker is allowed 58+ # to use (for linkers that support this). 59+ # Upstream chromium uses "all" keyword that is available since llvm 13. 60+ max_jobs_per_link = 8 61+ 62 # Whether we're using a sample profile collected on an architecture different 63 # than the one we're compiling for. 64 # 65