1*6777b538SAndroid Build Coastguard Worker# Copyright 2015 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Workerimport("//build/config/c++/c++.gni") 6*6777b538SAndroid Build Coastguard Workerimport("//build/config/cast.gni") 7*6777b538SAndroid Build Coastguard Workerimport("//build/config/chrome_build.gni") 8*6777b538SAndroid Build Coastguard Workerimport("//build/config/chromeos/args.gni") 9*6777b538SAndroid Build Coastguard Workerimport("//build/config/chromeos/ui_mode.gni") 10*6777b538SAndroid Build Coastguard Workerimport("//build/config/compiler/pgo/pgo.gni") 11*6777b538SAndroid Build Coastguard Workerimport("//build/config/cronet/config.gni") 12*6777b538SAndroid Build Coastguard Workerimport("//build/config/sanitizers/sanitizers.gni") 13*6777b538SAndroid Build Coastguard Workerimport("//build/toolchain/cc_wrapper.gni") 14*6777b538SAndroid Build Coastguard Workerimport("//build/toolchain/goma.gni") 15*6777b538SAndroid Build Coastguard Workerimport("//build/toolchain/toolchain.gni") 16*6777b538SAndroid Build Coastguard Workerimport("//build_overrides/build.gni") 17*6777b538SAndroid Build Coastguard Worker 18*6777b538SAndroid Build Coastguard Workerif (is_android) { 19*6777b538SAndroid Build Coastguard Worker import("//build/config/android/abi.gni") 20*6777b538SAndroid Build Coastguard Worker} 21*6777b538SAndroid Build Coastguard Workerif (current_cpu == "arm" || current_cpu == "arm64") { 22*6777b538SAndroid Build Coastguard Worker import("//build/config/arm.gni") 23*6777b538SAndroid Build Coastguard Worker} 24*6777b538SAndroid Build Coastguard Worker 25*6777b538SAndroid Build Coastguard Workerif (is_apple) { 26*6777b538SAndroid Build Coastguard Worker import("//build/config/apple/symbols.gni") 27*6777b538SAndroid Build Coastguard Worker} 28*6777b538SAndroid Build Coastguard Worker 29*6777b538SAndroid Build Coastguard Workerif (is_ios) { 30*6777b538SAndroid Build Coastguard Worker import("//build/config/ios/config.gni") 31*6777b538SAndroid Build Coastguard Worker} 32*6777b538SAndroid Build Coastguard Worker 33*6777b538SAndroid Build Coastguard Workerdeclare_args() { 34*6777b538SAndroid Build Coastguard Worker # Set to true to use lld, the LLVM linker. 35*6777b538SAndroid Build Coastguard Worker # In late bring-up on macOS (see docs/mac_lld.md). 36*6777b538SAndroid Build Coastguard Worker # Tentatively used on iOS. 37*6777b538SAndroid Build Coastguard Worker # The default linker everywhere else. 38*6777b538SAndroid Build Coastguard Worker use_lld = is_clang && current_os != "zos" 39*6777b538SAndroid Build Coastguard Worker 40*6777b538SAndroid Build Coastguard Worker # If true, optimize for size. 41*6777b538SAndroid Build Coastguard Worker # Default to favoring speed over size for platforms not listed below. 42*6777b538SAndroid Build Coastguard Worker optimize_for_size = !is_high_end_android && (is_android || is_castos) 43*6777b538SAndroid Build Coastguard Worker} 44*6777b538SAndroid Build Coastguard Worker 45*6777b538SAndroid Build Coastguard Workerdeclare_args() { 46*6777b538SAndroid Build Coastguard Worker # Default to warnings as errors for default workflow, where we catch 47*6777b538SAndroid Build Coastguard Worker # warnings with known toolchains. Allow overriding this e.g. for Chromium 48*6777b538SAndroid Build Coastguard Worker # builds on Linux that could use a different version of the compiler. 49*6777b538SAndroid Build Coastguard Worker # With GCC, warnings in no-Chromium code are always not treated as errors. 50*6777b538SAndroid Build Coastguard Worker treat_warnings_as_errors = true 51*6777b538SAndroid Build Coastguard Worker 52*6777b538SAndroid Build Coastguard Worker # How many symbols to include in the build. This affects the performance of 53*6777b538SAndroid Build Coastguard Worker # the build since the symbols are large and dealing with them is slow. 54*6777b538SAndroid Build Coastguard Worker # 2 means regular build with symbols. 55*6777b538SAndroid Build Coastguard Worker # 1 means minimal symbols, usually enough for backtraces only. Symbols with 56*6777b538SAndroid Build Coastguard Worker # internal linkage (static functions or those in anonymous namespaces) may not 57*6777b538SAndroid Build Coastguard Worker # appear when using this level. 58*6777b538SAndroid Build Coastguard Worker # 0 means no symbols. 59*6777b538SAndroid Build Coastguard Worker # -1 means auto-set according to debug/release and platform. 60*6777b538SAndroid Build Coastguard Worker symbol_level = -1 61*6777b538SAndroid Build Coastguard Worker 62*6777b538SAndroid Build Coastguard Worker # Android-only: Strip the debug info of libraries within lib.unstripped to 63*6777b538SAndroid Build Coastguard Worker # reduce size. As long as symbol_level > 0, this will still allow stacks to be 64*6777b538SAndroid Build Coastguard Worker # symbolized. 65*6777b538SAndroid Build Coastguard Worker strip_debug_info = false 66*6777b538SAndroid Build Coastguard Worker 67*6777b538SAndroid Build Coastguard Worker # Compile in such a way as to enable profiling of the generated code. For 68*6777b538SAndroid Build Coastguard Worker # example, don't omit the frame pointer and leave in symbols. 69*6777b538SAndroid Build Coastguard Worker enable_profiling = false 70*6777b538SAndroid Build Coastguard Worker 71*6777b538SAndroid Build Coastguard Worker # use_debug_fission: whether to use split DWARF debug info 72*6777b538SAndroid Build Coastguard Worker # files. This can reduce link time significantly, but is incompatible 73*6777b538SAndroid Build Coastguard Worker # with some utilities such as icecc and ccache. Requires gold and 74*6777b538SAndroid Build Coastguard Worker # gcc >= 4.8 or clang. 75*6777b538SAndroid Build Coastguard Worker # http://gcc.gnu.org/wiki/DebugFission 76*6777b538SAndroid Build Coastguard Worker # 77*6777b538SAndroid Build Coastguard Worker # This is a placeholder value indicating that the code below should set 78*6777b538SAndroid Build Coastguard Worker # the default. This is necessary to delay the evaluation of the default 79*6777b538SAndroid Build Coastguard Worker # value expression until after its input values such as use_gold have 80*6777b538SAndroid Build Coastguard Worker # been set, e.g. by a toolchain_args() block. 81*6777b538SAndroid Build Coastguard Worker use_debug_fission = "default" 82*6777b538SAndroid Build Coastguard Worker 83*6777b538SAndroid Build Coastguard Worker # Enables support for ThinLTO, which links 3x-10x faster than full LTO. See 84*6777b538SAndroid Build Coastguard Worker # also http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html 85*6777b538SAndroid Build Coastguard Worker # Use it by default on official-optimized android and Chrome OS builds, but 86*6777b538SAndroid Build Coastguard Worker # not ARC or linux-chromeos since it's been seen to not play nicely with 87*6777b538SAndroid Build Coastguard Worker # Chrome's clang. crbug.com/1033839 88*6777b538SAndroid Build Coastguard Worker # Disabled in iOS cronet builds since build step cronet_static_complete 89*6777b538SAndroid Build Coastguard Worker # wants to build a .a file consumable by external clients, and they won't 90*6777b538SAndroid Build Coastguard Worker # have the same LLVM revisions as us, making bitcode useless to them. 91*6777b538SAndroid Build Coastguard Worker use_thin_lto = 92*6777b538SAndroid Build Coastguard Worker is_cfi || (is_clang && is_official_build && chrome_pgo_phase != 1 && 93*6777b538SAndroid Build Coastguard Worker (is_linux || is_win || is_mac || 94*6777b538SAndroid Build Coastguard Worker (is_ios && use_lld && !is_cronet_build) || 95*6777b538SAndroid Build Coastguard Worker (is_android && target_os != "chromeos") || 96*6777b538SAndroid Build Coastguard Worker (is_chromeos && is_chromeos_device))) 97*6777b538SAndroid Build Coastguard Worker 98*6777b538SAndroid Build Coastguard Worker # Whether we're using a sample profile collected on an architecture different 99*6777b538SAndroid Build Coastguard Worker # than the one we're compiling for. 100*6777b538SAndroid Build Coastguard Worker # 101*6777b538SAndroid Build Coastguard Worker # It's currently not possible to collect AFDO profiles on anything but 102*6777b538SAndroid Build Coastguard Worker # x86{,_64}. 103*6777b538SAndroid Build Coastguard Worker using_mismatched_sample_profile = current_cpu != "x64" && current_cpu != "x86" 104*6777b538SAndroid Build Coastguard Worker 105*6777b538SAndroid Build Coastguard Worker # Whether an error should be raised on attempts to make debug builds with 106*6777b538SAndroid Build Coastguard Worker # is_component_build=false. Very large debug symbols can have unwanted side 107*6777b538SAndroid Build Coastguard Worker # effects so this is enforced by default for chromium. 108*6777b538SAndroid Build Coastguard Worker forbid_non_component_debug_builds = build_with_chromium 109*6777b538SAndroid Build Coastguard Worker 110*6777b538SAndroid Build Coastguard Worker # Exclude unwind tables by default for official builds as unwinding can be 111*6777b538SAndroid Build Coastguard Worker # done from stack dumps produced by Crashpad at a later time "offline" in the 112*6777b538SAndroid Build Coastguard Worker # crash server. Since this increases binary size, we don't recommend including 113*6777b538SAndroid Build Coastguard Worker # them in shipping builds. 114*6777b538SAndroid Build Coastguard Worker # For unofficial (e.g. development) builds and non-Chrome branded (e.g. Cronet 115*6777b538SAndroid Build Coastguard Worker # which doesn't use Crashpad, crbug.com/479283) builds it's useful to be able 116*6777b538SAndroid Build Coastguard Worker # to unwind at runtime. 117*6777b538SAndroid Build Coastguard Worker # Include the unwind tables on Android even for official builds, as otherwise 118*6777b538SAndroid Build Coastguard Worker # the crash dumps generated by Android's debuggerd are largely useless, and 119*6777b538SAndroid Build Coastguard Worker # having this additional mechanism to understand issues is particularly helpful 120*6777b538SAndroid Build Coastguard Worker # to WebView. 121*6777b538SAndroid Build Coastguard Worker exclude_unwind_tables = is_official_build && !is_android 122*6777b538SAndroid Build Coastguard Worker 123*6777b538SAndroid Build Coastguard Worker # Where to redirect clang crash diagnoses 124*6777b538SAndroid Build Coastguard Worker clang_diagnostic_dir = 125*6777b538SAndroid Build Coastguard Worker rebase_path("//tools/clang/crashreports", root_build_dir) 126*6777b538SAndroid Build Coastguard Worker 127*6777b538SAndroid Build Coastguard Worker # Mark binaries as compatible with Shadow Stack of Control-flow Enforcement 128*6777b538SAndroid Build Coastguard Worker # Technology (CET). If Windows version and hardware supports the feature and 129*6777b538SAndroid Build Coastguard Worker # it's enabled by OS then additional validation of return address will be 130*6777b538SAndroid Build Coastguard Worker # performed as mitigation against Return-oriented programming (ROP). 131*6777b538SAndroid Build Coastguard Worker # https://chromium.googlesource.com/chromium/src/+/main/docs/design/sandbox.md#cet-shadow-stack 132*6777b538SAndroid Build Coastguard Worker enable_cet_shadow_stack = target_cpu == "x64" 133*6777b538SAndroid Build Coastguard Worker 134*6777b538SAndroid Build Coastguard Worker # Set to true to enable using the ML inliner in LLVM. This currently only 135*6777b538SAndroid Build Coastguard Worker # enables the ML inliner when targeting Android for a size-optimized build. 136*6777b538SAndroid Build Coastguard Worker # Currently the ML inliner is only supported on linux hosts. 137*6777b538SAndroid Build Coastguard Worker use_ml_inliner = host_os == "linux" && is_android && optimize_for_size && 138*6777b538SAndroid Build Coastguard Worker !llvm_android_mainline # https://crbug.com/1468680 139*6777b538SAndroid Build Coastguard Worker 140*6777b538SAndroid Build Coastguard Worker # Set to true to use the android unwinder V2 implementation. 141*6777b538SAndroid Build Coastguard Worker use_android_unwinder_v2 = true 142*6777b538SAndroid Build Coastguard Worker 143*6777b538SAndroid Build Coastguard Worker # Whether we should consider the profile we're using to be accurate. Accurate 144*6777b538SAndroid Build Coastguard Worker # profiles have the benefit of (potentially substantial) binary size 145*6777b538SAndroid Build Coastguard Worker # reductions, by instructing the compiler to optimize cold and uncovered 146*6777b538SAndroid Build Coastguard Worker # functions heavily for size. This often comes at the cost of performance. 147*6777b538SAndroid Build Coastguard Worker sample_profile_is_accurate = optimize_for_size 148*6777b538SAndroid Build Coastguard Worker 149*6777b538SAndroid Build Coastguard Worker # Use offsets rather than pointers in vtables in order to reduce the number of 150*6777b538SAndroid Build Coastguard Worker # relocations. This is safe to enable only when all C++ code is built with the 151*6777b538SAndroid Build Coastguard Worker # flag set to the same value. 152*6777b538SAndroid Build Coastguard Worker use_relative_vtables_abi = is_android && current_cpu == "arm64" && 153*6777b538SAndroid Build Coastguard Worker use_custom_libcxx && !is_component_build 154*6777b538SAndroid Build Coastguard Worker} 155*6777b538SAndroid Build Coastguard Worker 156*6777b538SAndroid Build Coastguard Worker# To try out this combination, delete this assert. 157*6777b538SAndroid Build Coastguard Workerassert( 158*6777b538SAndroid Build Coastguard Worker !use_relative_vtables_abi || !is_cfi, 159*6777b538SAndroid Build Coastguard Worker "is_cfi=true is known to conflict with use_relative_vtables_abi=true.\n" + 160*6777b538SAndroid Build Coastguard Worker "See https://bugs.chromium.org/p/chromium/issues/detail?id=1375035#c53") 161*6777b538SAndroid Build Coastguard Worker 162*6777b538SAndroid Build Coastguard Workerassert(!is_cfi || use_thin_lto, "CFI requires ThinLTO") 163*6777b538SAndroid Build Coastguard Workerassert(!enable_profiling || !is_component_build, 164*6777b538SAndroid Build Coastguard Worker "Cannot profile component builds (crbug.com/1199271).") 165*6777b538SAndroid Build Coastguard Worker 166*6777b538SAndroid Build Coastguard Workerif (use_thin_lto && is_debug) { 167*6777b538SAndroid Build Coastguard Worker print("WARNING: ThinLTO (use_thin_lto=true) doesn't work with debug" + 168*6777b538SAndroid Build Coastguard Worker " (is_debug=true) build.") 169*6777b538SAndroid Build Coastguard Worker} 170*6777b538SAndroid Build Coastguard Worker 171*6777b538SAndroid Build Coastguard Worker# Determine whether to enable or disable frame pointers, based on the platform 172*6777b538SAndroid Build Coastguard Worker# and build arguments. 173*6777b538SAndroid Build Coastguard Workerif (is_chromeos) { 174*6777b538SAndroid Build Coastguard Worker # ChromeOS generally prefers frame pointers, to support CWP. 175*6777b538SAndroid Build Coastguard Worker # However, Clang does not currently generate usable frame pointers in ARM 176*6777b538SAndroid Build Coastguard Worker # 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them 177*6777b538SAndroid Build Coastguard Worker # there to avoid the unnecessary overhead. 178*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = current_cpu != "arm" 179*6777b538SAndroid Build Coastguard Worker} else if (is_apple || is_linux) { 180*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = true 181*6777b538SAndroid Build Coastguard Worker} else if (is_win) { 182*6777b538SAndroid Build Coastguard Worker # 64-bit Windows ABI doesn't support frame pointers. 183*6777b538SAndroid Build Coastguard Worker # NOTE: This setting is actually not used in the BUILD.gn for Windows, 184*6777b538SAndroid Build Coastguard Worker # but it still reflects correctly that we don't emit frame pointers on x64. 185*6777b538SAndroid Build Coastguard Worker if (current_cpu == "x64") { 186*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = false 187*6777b538SAndroid Build Coastguard Worker } else { 188*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = true 189*6777b538SAndroid Build Coastguard Worker } 190*6777b538SAndroid Build Coastguard Worker} else if (is_android) { 191*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = 192*6777b538SAndroid Build Coastguard Worker enable_profiling || 193*6777b538SAndroid Build Coastguard Worker # Ensure that stacks from arm64 crash dumps are usable (crbug.com/391706). 194*6777b538SAndroid Build Coastguard Worker current_cpu == "arm64" || 195*6777b538SAndroid Build Coastguard Worker # For x86 Android, unwind tables are huge without frame pointers 196*6777b538SAndroid Build Coastguard Worker # (crbug.com/762629). Enabling frame pointers grows the code size slightly 197*6777b538SAndroid Build Coastguard Worker # but overall shrinks binaries considerably by avoiding huge unwind 198*6777b538SAndroid Build Coastguard Worker # tables. 199*6777b538SAndroid Build Coastguard Worker (current_cpu == "x86" && !exclude_unwind_tables && optimize_for_size) || 200*6777b538SAndroid Build Coastguard Worker using_sanitizer 201*6777b538SAndroid Build Coastguard Worker} else if (is_fuchsia) { 202*6777b538SAndroid Build Coastguard Worker # Fuchsia on arm64 could use shadow call stack for unwinding. 203*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = current_cpu != "arm64" 204*6777b538SAndroid Build Coastguard Worker} else { 205*6777b538SAndroid Build Coastguard Worker # Explicitly ask for frame pointers, otherwise stacks may be missing for 206*6777b538SAndroid Build Coastguard Worker # sanitizer and profiling builds. 207*6777b538SAndroid Build Coastguard Worker enable_frame_pointers = using_sanitizer || enable_profiling || is_debug 208*6777b538SAndroid Build Coastguard Worker} 209*6777b538SAndroid Build Coastguard Worker 210*6777b538SAndroid Build Coastguard Worker# In general assume that if we have frame pointers then we can use them to 211*6777b538SAndroid Build Coastguard Worker# unwind the stack. However, this requires that they are enabled by default for 212*6777b538SAndroid Build Coastguard Worker# most translation units, that they are emitted correctly, and that the 213*6777b538SAndroid Build Coastguard Worker# compiler or platform provides a way to access them. 214*6777b538SAndroid Build Coastguard Workercan_unwind_with_frame_pointers = enable_frame_pointers 215*6777b538SAndroid Build Coastguard Workerif (current_cpu == "arm" && arm_use_thumb) { 216*6777b538SAndroid Build Coastguard Worker # We cannot currently unwind ARM Thumb frame pointers correctly. 217*6777b538SAndroid Build Coastguard Worker # See https://bugs.llvm.org/show_bug.cgi?id=18505 218*6777b538SAndroid Build Coastguard Worker can_unwind_with_frame_pointers = false 219*6777b538SAndroid Build Coastguard Worker} else if (is_win) { 220*6777b538SAndroid Build Coastguard Worker # Windows 32-bit does provide frame pointers, but the compiler does not 221*6777b538SAndroid Build Coastguard Worker # provide intrinsics to access them, so we don't use them. 222*6777b538SAndroid Build Coastguard Worker can_unwind_with_frame_pointers = false 223*6777b538SAndroid Build Coastguard Worker} 224*6777b538SAndroid Build Coastguard Worker 225*6777b538SAndroid Build Coastguard Workerassert(!can_unwind_with_frame_pointers || enable_frame_pointers) 226*6777b538SAndroid Build Coastguard Worker 227*6777b538SAndroid Build Coastguard Worker# Unwinding with CFI table is only possible on static library builds and 228*6777b538SAndroid Build Coastguard Worker# requried only when frame pointers are not enabled. 229*6777b538SAndroid Build Coastguard Workercan_unwind_with_cfi_table = is_android && !is_component_build && 230*6777b538SAndroid Build Coastguard Worker !enable_frame_pointers && current_cpu == "arm" 231*6777b538SAndroid Build Coastguard Worker 232*6777b538SAndroid Build Coastguard Worker# Whether or not cfi table should be enabled on arm. 233*6777b538SAndroid Build Coastguard Worker# TODO(crbug.com/1090409): Replace can_unwind_with_cfi_table with this once 234*6777b538SAndroid Build Coastguard Worker# sampling profiler is enabled on android. 235*6777b538SAndroid Build Coastguard Workerenable_arm_cfi_table = is_android && !is_component_build && current_cpu == "arm" 236*6777b538SAndroid Build Coastguard Worker 237*6777b538SAndroid Build Coastguard Workerdeclare_args() { 238*6777b538SAndroid Build Coastguard Worker # Whether to use the gold linker from binutils instead of lld or bfd. 239*6777b538SAndroid Build Coastguard Worker use_gold = !use_lld && !(is_castos && 240*6777b538SAndroid Build Coastguard Worker (current_cpu == "arm" || current_cpu == "mipsel")) && 241*6777b538SAndroid Build Coastguard Worker (((is_linux || is_chromeos_lacros) && 242*6777b538SAndroid Build Coastguard Worker (current_cpu == "x64" || current_cpu == "x86" || 243*6777b538SAndroid Build Coastguard Worker current_cpu == "arm" || current_cpu == "arm64" || 244*6777b538SAndroid Build Coastguard Worker current_cpu == "mipsel" || current_cpu == "mips64el")) || 245*6777b538SAndroid Build Coastguard Worker (is_android && (current_cpu == "x86" || current_cpu == "x64" || 246*6777b538SAndroid Build Coastguard Worker current_cpu == "arm" || current_cpu == "arm64" || 247*6777b538SAndroid Build Coastguard Worker current_cpu == "riscv64"))) 248*6777b538SAndroid Build Coastguard Worker} 249*6777b538SAndroid Build Coastguard Worker 250*6777b538SAndroid Build Coastguard Worker# Use relative paths for debug info. This is important to make the build 251*6777b538SAndroid Build Coastguard Worker# results independent of the checkout and build directory names, which 252*6777b538SAndroid Build Coastguard Worker# in turn is important for goma compile hit rate. 253*6777b538SAndroid Build Coastguard Worker# Setting this to true may make it harder to debug binaries on Linux, see 254*6777b538SAndroid Build Coastguard Worker# https://chromium.googlesource.com/chromium/src/+/main/docs/linux/debugging.md#Source-level-debug-with-fdebug_compilation_dir 255*6777b538SAndroid Build Coastguard Worker# It's not clear if the crash server will correctly handle dSYMs with relative 256*6777b538SAndroid Build Coastguard Worker# paths, so we disable this feature for official benefit. The main benefit is 257*6777b538SAndroid Build Coastguard Worker# deterministic builds to reduce compile times, so this is less relevant for 258*6777b538SAndroid Build Coastguard Worker# official builders. 259*6777b538SAndroid Build Coastguard Workerstrip_absolute_paths_from_debug_symbols_default = 260*6777b538SAndroid Build Coastguard Worker is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux || 261*6777b538SAndroid Build Coastguard Worker is_chromeos || (is_apple && !enable_dsyms) 262*6777b538SAndroid Build Coastguard Worker 263*6777b538SAndroid Build Coastguard Worker# If the platform uses stripped absolute paths by default, then we don't expose 264*6777b538SAndroid Build Coastguard Worker# it as a configuration option. If this is causing problems, please file a bug. 265*6777b538SAndroid Build Coastguard Workerif (strip_absolute_paths_from_debug_symbols_default) { 266*6777b538SAndroid Build Coastguard Worker strip_absolute_paths_from_debug_symbols = true 267*6777b538SAndroid Build Coastguard Worker} else { 268*6777b538SAndroid Build Coastguard Worker declare_args() { 269*6777b538SAndroid Build Coastguard Worker strip_absolute_paths_from_debug_symbols = false 270*6777b538SAndroid Build Coastguard Worker } 271*6777b538SAndroid Build Coastguard Worker} 272*6777b538SAndroid Build Coastguard Worker 273*6777b538SAndroid Build Coastguard Worker# If it wasn't manually set, then default use_debug_fission to false. 274*6777b538SAndroid Build Coastguard Workerassert( 275*6777b538SAndroid Build Coastguard Worker use_debug_fission == "default" || use_debug_fission || !use_debug_fission, 276*6777b538SAndroid Build Coastguard Worker "Invalid use_debug_fission.") 277*6777b538SAndroid Build Coastguard Workerif (use_debug_fission == "default") { 278*6777b538SAndroid Build Coastguard Worker use_debug_fission = is_debug && !is_android && !is_fuchsia && !is_apple && 279*6777b538SAndroid Build Coastguard Worker !is_win && (use_gold || use_lld) && cc_wrapper == "" 280*6777b538SAndroid Build Coastguard Worker} 281*6777b538SAndroid Build Coastguard Worker 282*6777b538SAndroid Build Coastguard Worker# If it wasn't manually set, set to an appropriate default. 283*6777b538SAndroid Build Coastguard Workerassert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level") 284*6777b538SAndroid Build Coastguard Workerif (symbol_level == -1) { 285*6777b538SAndroid Build Coastguard Worker if (is_android && !is_component_build && !use_debug_fission) { 286*6777b538SAndroid Build Coastguard Worker # Prefer faster & smaller release builds. 287*6777b538SAndroid Build Coastguard Worker symbol_level = 1 288*6777b538SAndroid Build Coastguard Worker } else if (is_chromeos_device) { 289*6777b538SAndroid Build Coastguard Worker # Use lower symbol level in Simple Chrome build for faster link time. 290*6777b538SAndroid Build Coastguard Worker # For Simple Chrome, this should take precedence over is_official_build, 291*6777b538SAndroid Build Coastguard Worker # turned on by --internal. 292*6777b538SAndroid Build Coastguard Worker if ((target_cpu == "x64" || target_cpu == "x86") && !is_debug) { 293*6777b538SAndroid Build Coastguard Worker # For release x86/x64 build, specify symbol_level=0 for faster link time. 294*6777b538SAndroid Build Coastguard Worker # x86/x64 shows backtraces with symbol_level=0 (arm requires 295*6777b538SAndroid Build Coastguard Worker # symbol_level=1). 296*6777b538SAndroid Build Coastguard Worker symbol_level = 0 297*6777b538SAndroid Build Coastguard Worker } else { 298*6777b538SAndroid Build Coastguard Worker symbol_level = 1 299*6777b538SAndroid Build Coastguard Worker } 300*6777b538SAndroid Build Coastguard Worker } else if (using_sanitizer) { 301*6777b538SAndroid Build Coastguard Worker # Sanitizers need line table info for stack traces. They don't need type 302*6777b538SAndroid Build Coastguard Worker # info or variable info, so we can leave that out to speed up the build. 303*6777b538SAndroid Build Coastguard Worker # Sanitizers also require symbols for filename suppressions to work. 304*6777b538SAndroid Build Coastguard Worker symbol_level = 1 305*6777b538SAndroid Build Coastguard Worker } else if ((!is_nacl && !is_linux && !is_chromeos && !is_fuchsia && 306*6777b538SAndroid Build Coastguard Worker current_os != "aix") || is_debug || is_official_build || 307*6777b538SAndroid Build Coastguard Worker is_castos || is_cast_android) { 308*6777b538SAndroid Build Coastguard Worker # Linux builds slower by having symbols as part of the target binary, 309*6777b538SAndroid Build Coastguard Worker # whereas Mac and Windows have them separate, so in Release Linux, default 310*6777b538SAndroid Build Coastguard Worker # them off, but keep them on for Official builds and Chromecast builds. 311*6777b538SAndroid Build Coastguard Worker symbol_level = 2 312*6777b538SAndroid Build Coastguard Worker } else { 313*6777b538SAndroid Build Coastguard Worker symbol_level = 0 314*6777b538SAndroid Build Coastguard Worker } 315*6777b538SAndroid Build Coastguard Worker} 316*6777b538SAndroid Build Coastguard Worker 317*6777b538SAndroid Build Coastguard Worker# Split dwarf works only for symbol_level == 2. 318*6777b538SAndroid Build Coastguard Workeruse_debug_fission = use_debug_fission && symbol_level == 2 319*6777b538SAndroid Build Coastguard Worker 320*6777b538SAndroid Build Coastguard Worker# Non-component debug builds with symbol_level = 2 are an undesirable (very slow 321*6777b538SAndroid Build Coastguard Worker# build times, almost two-minute link times) combination. This is only checked 322*6777b538SAndroid Build Coastguard Worker# when current_toolchain == default_toolchain because the is_component_build 323*6777b538SAndroid Build Coastguard Worker# flag is set to false in various components of the build (like nacl) and we 324*6777b538SAndroid Build Coastguard Worker# don't want to assert on those. 325*6777b538SAndroid Build Coastguard Worker# iOS does not support component builds so add an exception for this platform. 326*6777b538SAndroid Build Coastguard Worker# Windows supports huge PDBs so this combination is allowed for those who don't 327*6777b538SAndroid Build Coastguard Worker# mind long build times. 328*6777b538SAndroid Build Coastguard Workerif (forbid_non_component_debug_builds) { 329*6777b538SAndroid Build Coastguard Worker assert( 330*6777b538SAndroid Build Coastguard Worker symbol_level != 2 || current_toolchain != default_toolchain || 331*6777b538SAndroid Build Coastguard Worker is_component_build || !is_debug || is_ios || use_debug_fission || 332*6777b538SAndroid Build Coastguard Worker host_os == "win", 333*6777b538SAndroid Build Coastguard Worker "Can't do non-component debug builds at symbol_level=2 without use_debug_fission=true") 334*6777b538SAndroid Build Coastguard Worker} 335*6777b538SAndroid Build Coastguard Worker 336*6777b538SAndroid Build Coastguard Worker# TODO(crbug.com/1341436) For Windows, to assemble lzma_sdk's assembly files, 337*6777b538SAndroid Build Coastguard Worker# ml64.exe needs to be utilized as llvm-ml cannot yet assemble it. Once llvm-ml 338*6777b538SAndroid Build Coastguard Worker# is able to assemble lzma_sdk assembly files, remove this. 339*6777b538SAndroid Build Coastguard Worker# LzmaDecOpt.asm only works on x64 and not x86. 340*6777b538SAndroid Build Coastguard Worker# https://sourceforge.net/p/sevenzip/discussion/45797/thread/768932e9dd/?limit=25#0d6c 341*6777b538SAndroid Build Coastguard Workerdisable_llvm_ml = host_os == "win" && target_cpu == "x64" && !is_msan 342