15f9996aaSopenharmony_ci# Copyright 2016 The Chromium Authors. All rights reserved. 25f9996aaSopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 35f9996aaSopenharmony_ci# found in the LICENSE file. 45f9996aaSopenharmony_ci 55f9996aaSopenharmony_ci# This file should only be imported from files that define toolchains. 65f9996aaSopenharmony_ci# There's no way to enforce this exactly, but all toolchains are processed 75f9996aaSopenharmony_ci# in the context of the default_toolchain, so we can at least check for that. 85f9996aaSopenharmony_ciassert(current_toolchain == default_toolchain) 95f9996aaSopenharmony_ci 105f9996aaSopenharmony_ciimport("//build/config/compiler/compiler.gni") 115f9996aaSopenharmony_ciimport("//build/config/sanitizers/sanitizers.gni") 125f9996aaSopenharmony_ciimport("//build/toolchain/toolchain.gni") 135f9996aaSopenharmony_ci 145f9996aaSopenharmony_cideclare_args() { 155f9996aaSopenharmony_ci # Limit the number of concurrent links; we often want to run fewer 165f9996aaSopenharmony_ci # links at once than we do compiles, because linking is memory-intensive. 175f9996aaSopenharmony_ci # The default to use varies by platform and by the amount of memory 185f9996aaSopenharmony_ci # available, so we call out to a script to get the right value. 195f9996aaSopenharmony_ci concurrent_links = -1 205f9996aaSopenharmony_ci} 215f9996aaSopenharmony_ci 225f9996aaSopenharmony_ciif (concurrent_links == -1) { 235f9996aaSopenharmony_ci if (use_thin_lto) { 245f9996aaSopenharmony_ci _args = [ 255f9996aaSopenharmony_ci "--mem_per_link_gb=10", 265f9996aaSopenharmony_ci "--reserve_mem_gb=10", 275f9996aaSopenharmony_ci ] 285f9996aaSopenharmony_ci } else if (use_sanitizer_coverage || use_fuzzing_engine) { 295f9996aaSopenharmony_ci # Sanitizer coverage instrumentation increases linker memory consumption 305f9996aaSopenharmony_ci # significantly. 315f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=16" ] 325f9996aaSopenharmony_ci } else if (is_win && symbol_level == 1 && !is_debug) { 335f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=3" ] 345f9996aaSopenharmony_ci } else if (is_win) { 355f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=5" ] 365f9996aaSopenharmony_ci } else if (is_mac) { 375f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=4" ] 385f9996aaSopenharmony_ci } else if (is_ohos && !is_component_build && symbol_level == 2) { 395f9996aaSopenharmony_ci # Full debug symbols require large memory for link. 405f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=25" ] 415f9996aaSopenharmony_ci } else if (is_ohos && !is_debug && !using_sanitizer && symbol_level < 2) { 425f9996aaSopenharmony_ci # Increase the number of concurrent links for release bots. Debug builds 435f9996aaSopenharmony_ci # make heavier use of ProGuard, and so should not be raised. Sanitizers also 445f9996aaSopenharmony_ci # increase the memory overhead. 455f9996aaSopenharmony_ci if (symbol_level == 1) { 465f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=6" ] 475f9996aaSopenharmony_ci } else { 485f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=4" ] 495f9996aaSopenharmony_ci } 505f9996aaSopenharmony_ci } else if (is_linux && !is_chromeos && symbol_level == 0) { 515f9996aaSopenharmony_ci # Memory consumption on link without debug symbols is low on linux. 525f9996aaSopenharmony_ci _args = [ "--mem_per_link_gb=3" ] 535f9996aaSopenharmony_ci } else { 545f9996aaSopenharmony_ci _args = [] 555f9996aaSopenharmony_ci } 565f9996aaSopenharmony_ci 575f9996aaSopenharmony_ci concurrent_links = exec_script("get_concurrent_links.py", _args, "value") 585f9996aaSopenharmony_ci} 59