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