forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-02-17 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Upstream-Status: Inappropriate
 
Signed-off-by: Maksim Sisov <msisov@igalia.com>
---
From ab74e60870e8f515c5b94f90d9b0741492950de6 Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
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