Skip to content

Commit 57d859e

Browse files
Ben WagnerSkia Commit-Bot
authored andcommitted
Create a gn link pool which is disabled by default.
The oss-fuzz build of Skia seems to have difficulty when it does too many linker steps at a time. Ninja will generally not launch new build steps if the load is too high, but the oss-fuzz builder machines are slow enough that the load doesn't seem to rise fast enough to prevent too many linkers from be started at a time. By default this change does not request a linker pool at all and the user must request one by setting the link_pool_depth. Negative values disable the linker pool, zero sets the number to the number of cpus, and positive values set the pool size. This should allow for some experimentation while testing what pool size is appropriate for the fuzz builders while not changing current default behavior. Bug: oss-fuzz:23438,oss-fuzz:24345 Change-Id: Iba62adac3bea4d968441aa08e33918b5ae962c7b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306646 Reviewed-by: Kevin Lubick <kjlubick@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
1 parent e34b282 commit 57d859e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

gn/toolchain/BUILD.gn

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ declare_args() {
4040
# slowest steps in a build, so we don't want to limit too much. Use the number
4141
# of CPUs as a default.
4242
dlsymutil_pool_depth = exec_script("num_cpus.py", [], "value")
43+
44+
# Too many linkers running at once causes issues for some builders. Allow
45+
# such builders to limit the number of concurrent link steps.
46+
# link_pool_depth < 0 means no pool, 0 means cpu count, > 0 sets pool size.
47+
link_pool_depth = -1
4348
}
4449

4550
# For 'shell' see https://ninja-build.org/manual.html#ref_rule_command
@@ -55,6 +60,15 @@ if (current_toolchain == default_toolchain) {
5560
pool("dsymutil_pool") {
5661
depth = dlsymutil_pool_depth
5762
}
63+
if (0 <= link_pool_depth) {
64+
pool("link_pool") {
65+
if (link_pool_depth == 0) {
66+
depth = exec_script("num_cpus.py", [], "value")
67+
} else {
68+
depth = link_pool_depth
69+
}
70+
}
71+
}
5872
}
5973

6074
toolchain("msvc") {
@@ -147,6 +161,9 @@ toolchain("msvc") {
147161
# inputs_newline works around a fixed per-line buffer size in the linker.
148162
rspfile_content = "{{inputs_newline}}"
149163
description = "link {{output}}"
164+
if (0 <= link_pool_depth) {
165+
pool = ":link_pool($default_toolchain)"
166+
}
150167
}
151168

152169
tool("solink") {
@@ -177,6 +194,9 @@ toolchain("msvc") {
177194
# inputs_newline works around a fixed per-line buffer size in the linker.
178195
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
179196
description = "link {{output}}"
197+
if (0 <= link_pool_depth) {
198+
pool = ":link_pool($default_toolchain)"
199+
}
180200
}
181201

182202
tool("link") {
@@ -192,6 +212,9 @@ toolchain("msvc") {
192212
# inputs_newline works around a fixed per-line buffer size in the linker.
193213
rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
194214
description = "link {{output}}"
215+
if (0 <= link_pool_depth) {
216+
pool = ":link_pool($default_toolchain)"
217+
}
195218
}
196219

197220
tool("stamp") {
@@ -278,6 +301,9 @@ template("gcc_like_toolchain") {
278301
default_output_extension = ".a"
279302
output_prefix = "lib"
280303
description = "link {{output}}"
304+
if (0 <= link_pool_depth) {
305+
pool = ":link_pool($default_toolchain)"
306+
}
281307
}
282308

283309
tool("solink") {
@@ -309,6 +335,9 @@ template("gcc_like_toolchain") {
309335
output_prefix = "lib"
310336
default_output_extension = ".so"
311337
description = "link {{output}}"
338+
if (0 <= link_pool_depth) {
339+
pool = ":link_pool($default_toolchain)"
340+
}
312341
}
313342

314343
tool("link") {
@@ -332,6 +361,9 @@ template("gcc_like_toolchain") {
332361

333362
outputs = [ "$exe_name" ]
334363
description = "link {{output}}"
364+
if (0 <= link_pool_depth) {
365+
pool = ":link_pool($default_toolchain)"
366+
}
335367
}
336368

337369
tool("stamp") {

0 commit comments

Comments
 (0)