diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/libwebrtc/build/toolchain/concurrent_links.gni | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/build/toolchain/concurrent_links.gni')
-rw-r--r-- | third_party/libwebrtc/build/toolchain/concurrent_links.gni | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/toolchain/concurrent_links.gni b/third_party/libwebrtc/build/toolchain/concurrent_links.gni new file mode 100644 index 0000000000..c0342256a6 --- /dev/null +++ b/third_party/libwebrtc/build/toolchain/concurrent_links.gni @@ -0,0 +1,106 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file should only be imported from files that define toolchains. +# There's no way to enforce this exactly, but all toolchains are processed +# in the context of the default_toolchain, so we can at least check for that. +assert(current_toolchain == default_toolchain) + +import("//build/config/android/config.gni") +import("//build/config/apple/symbols.gni") +import("//build/config/chromeos/ui_mode.gni") +import("//build/config/compiler/compiler.gni") +import("//build/config/coverage/coverage.gni") +import("//build/config/sanitizers/sanitizers.gni") +import("//build/toolchain/toolchain.gni") + +declare_args() { + # Limit the number of concurrent links; we often want to run fewer + # links at once than we do compiles, because linking is memory-intensive. + # The default to use varies by platform and by the amount of memory + # available, so we call out to a script to get the right value. + concurrent_links = -1 +} + +if (concurrent_links == -1) { + if (use_thin_lto) { + _args = [ "--reserve_mem_gb=10" ] + if (use_goma_thin_lto) { + _args += [ "--thin-lto=goma" ] + } else { + _args += [ "--thin-lto=local" ] + } + if (is_win) { + # Based on measurements of linking chrome.dll and chrome_child.dll, plus + # a little padding to account for future growth. + _args += [ "--mem_per_link_gb=45" ] + } else { + _args += [ "--mem_per_link_gb=16" ] + } + } else if ((use_clang_coverage && + # When coverage_instrumentation_input_file is not empty it means + # we're only instrumenting changed files and not using a lot of + # memory. Likewise, when it's empty we're building everything with + # coverage, which requires more memory. + coverage_instrumentation_input_file == "") || + use_sanitizer_coverage || use_fuzzing_engine) { + # Full sanitizer coverage instrumentation increases linker memory consumption + # significantly. + _args = [ "--mem_per_link_gb=16" ] + } else if (is_win && symbol_level == 1 && !is_debug && is_component_build) { + _args = [ "--mem_per_link_gb=3" ] + } else if (is_win) { + _args = [ "--mem_per_link_gb=6" ] + } else if (is_mac) { + if (enable_dsyms) { + _args = [ "--mem_per_link_gb=12" ] + } else { + _args = [ "--mem_per_link_gb=4" ] + } + } else if (is_android && !is_component_build && symbol_level == 2) { + # Full debug symbols require large memory for link. + _args = [ "--mem_per_link_gb=25" ] + } else if (is_android && !is_debug && !using_sanitizer && is_java_debug && + disable_android_lint && symbol_level < 2) { + if (symbol_level == 1) { + _args = [ "--mem_per_link_gb=6" ] + } else { + _args = [ "--mem_per_link_gb=4" ] + } + } else if ((is_linux || is_chromeos_lacros) && symbol_level == 0) { + # Memory consumption on link without debug symbols is low on linux. + _args = [ "--mem_per_link_gb=3" ] + } else { + _args = [] + } + + # For Android builds, we also need to be wary of: + # * ProGuard / R8 + # * Android Lint + # These both have a peak usage of < 2GB, but that is still large enough for + # them to need to use a pool since they both typically happen at the + # same time as linking. + if (is_android) { + _args += [ "--secondary_mem_per_link=2" ] + } + + # TODO(crbug.com/617429) Pass more build configuration info to the script + # so that we can compute better values. + _command_dict = exec_script("get_concurrent_links.py", _args, "scope") + + concurrent_links = _command_dict.primary_pool_size + concurrent_links_logs = _command_dict.explanation + + if (_command_dict.secondary_pool_size >= concurrent_links) { + # Have R8 / Lint share the link pool unless we would safely get more + # concurrency out of using a separate one. + # On low-RAM machines, this allows an apk's native library to link at the + # same time as its java is optimized with R8. + java_cmd_pool_size = _command_dict.secondary_pool_size + } +} else { + assert(!use_thin_lto, "can't explicitly set concurrent_links with thinlto") + concurrent_links_logs = + [ "concurrent_links set by GN arg (value=$concurrent_links)" ] +} |