1# Copyright 2016 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# This file should only be imported from files that define toolchains. 6# There's no way to enforce this exactly, but all toolchains are processed 7# in the context of the default_toolchain, so we can at least check for that. 8assert(current_toolchain == default_toolchain) 9 10import("//build/config/compiler/compiler.gni") 11import("//build/config/sanitizers/sanitizers.gni") 12import("//build/toolchain/toolchain.gni") 13 14declare_args() { 15 # Limit the number of concurrent links; we often want to run fewer 16 # links at once than we do compiles, because linking is memory-intensive. 17 # The default to use varies by platform and by the amount of memory 18 # available, so we call out to a script to get the right value. 19 concurrent_links = -1 20} 21 22if (concurrent_links == -1) { 23 if (use_thin_lto) { 24 _args = [ 25 "--mem_per_link_gb=10", 26 "--reserve_mem_gb=10", 27 ] 28 } else if (use_sanitizer_coverage || use_fuzzing_engine) { 29 # Sanitizer coverage instrumentation increases linker memory consumption 30 # significantly. 31 _args = [ "--mem_per_link_gb=16" ] 32 } else if (is_win && symbol_level == 1 && !is_debug) { 33 _args = [ "--mem_per_link_gb=3" ] 34 } else if (is_win) { 35 _args = [ "--mem_per_link_gb=5" ] 36 } else if (is_mac) { 37 _args = [ "--mem_per_link_gb=4" ] 38 } else if (is_ohos && !is_component_build && symbol_level == 2) { 39 # Full debug symbols require large memory for link. 40 _args = [ "--mem_per_link_gb=25" ] 41 } else if (is_ohos && !is_debug && !using_sanitizer && symbol_level < 2) { 42 # Increase the number of concurrent links for release bots. Debug builds 43 # make heavier use of ProGuard, and so should not be raised. Sanitizers also 44 # increase the memory overhead. 45 if (symbol_level == 1) { 46 _args = [ "--mem_per_link_gb=6" ] 47 } else { 48 _args = [ "--mem_per_link_gb=4" ] 49 } 50 } else if (is_linux && !is_chromeos && symbol_level == 0) { 51 # Memory consumption on link without debug symbols is low on linux. 52 _args = [ "--mem_per_link_gb=3" ] 53 } else { 54 _args = [] 55 } 56 57 concurrent_links = exec_script("get_concurrent_links.py", _args, "value") 58} 59