xref: /aosp_15_r20/external/angle/build/config/v8_target_cpu.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2016 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/sanitizers/sanitizers.gni")
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
8*8975f5c5SAndroid Build Coastguard Worker  # This arg is used when we want to tell the JIT-generating v8 code
9*8975f5c5SAndroid Build Coastguard Worker  # that we want to have it generate for an architecture that is different
10*8975f5c5SAndroid Build Coastguard Worker  # than the architecture that v8 will actually run on; we then run the
11*8975f5c5SAndroid Build Coastguard Worker  # code under an emulator. For example, we might run v8 on x86, but
12*8975f5c5SAndroid Build Coastguard Worker  # generate arm code and run that under emulation.
13*8975f5c5SAndroid Build Coastguard Worker  #
14*8975f5c5SAndroid Build Coastguard Worker  # This arg is defined here rather than in the v8 project because we want
15*8975f5c5SAndroid Build Coastguard Worker  # some of the common architecture-specific args (like arm_float_abi or
16*8975f5c5SAndroid Build Coastguard Worker  # mips_arch_variant) to be set to their defaults either if the current_cpu
17*8975f5c5SAndroid Build Coastguard Worker  # applies *or* if the v8_current_cpu applies.
18*8975f5c5SAndroid Build Coastguard Worker  #
19*8975f5c5SAndroid Build Coastguard Worker  # As described below, you can also specify the v8_target_cpu to use
20*8975f5c5SAndroid Build Coastguard Worker  # indirectly by specifying a `custom_toolchain` that contains v8_$cpu in the
21*8975f5c5SAndroid Build Coastguard Worker  # name after the normal toolchain.
22*8975f5c5SAndroid Build Coastguard Worker  #
23*8975f5c5SAndroid Build Coastguard Worker  # For example, `gn gen --args="custom_toolchain=...:clang_x64_v8_arm64"`
24*8975f5c5SAndroid Build Coastguard Worker  # is equivalent to setting --args=`v8_target_cpu="arm64"`. Setting
25*8975f5c5SAndroid Build Coastguard Worker  # `custom_toolchain` is more verbose but makes the toolchain that is
26*8975f5c5SAndroid Build Coastguard Worker  # (effectively) being used explicit.
27*8975f5c5SAndroid Build Coastguard Worker  #
28*8975f5c5SAndroid Build Coastguard Worker  # v8_target_cpu can only be used to target one architecture in a build,
29*8975f5c5SAndroid Build Coastguard Worker  # so if you wish to build multiple copies of v8 that are targeting
30*8975f5c5SAndroid Build Coastguard Worker  # different architectures, you will need to do something more
31*8975f5c5SAndroid Build Coastguard Worker  # complicated involving multiple toolchains along the lines of
32*8975f5c5SAndroid Build Coastguard Worker  # custom_toolchain, above.
33*8975f5c5SAndroid Build Coastguard Worker  v8_target_cpu = ""
34*8975f5c5SAndroid Build Coastguard Worker}
35*8975f5c5SAndroid Build Coastguard Worker
36*8975f5c5SAndroid Build Coastguard Workerif (v8_target_cpu == "") {
37*8975f5c5SAndroid Build Coastguard Worker  if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64") {
38*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "arm64"
39*8975f5c5SAndroid Build Coastguard Worker  } else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm") {
40*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "arm"
41*8975f5c5SAndroid Build Coastguard Worker  } else if (current_toolchain ==
42*8975f5c5SAndroid Build Coastguard Worker             "//build/toolchain/linux:clang_x86_v8_mips64el") {
43*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "mips64el"
44*8975f5c5SAndroid Build Coastguard Worker  } else if (current_toolchain ==
45*8975f5c5SAndroid Build Coastguard Worker             "//build/toolchain/linux:clang_x86_v8_mipsel") {
46*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "mipsel"
47*8975f5c5SAndroid Build Coastguard Worker  } else if (current_toolchain ==
48*8975f5c5SAndroid Build Coastguard Worker             "//build/toolchain/linux:clang_x64_v8_riscv64") {
49*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "riscv64"
50*8975f5c5SAndroid Build Coastguard Worker  } else if (is_msan) {
51*8975f5c5SAndroid Build Coastguard Worker    # If we're running under a sanitizer, if we configure v8 to generate
52*8975f5c5SAndroid Build Coastguard Worker    # code that will be run under a simulator, then the generated code
53*8975f5c5SAndroid Build Coastguard Worker    # also gets the benefits of the sanitizer.
54*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = "arm64"
55*8975f5c5SAndroid Build Coastguard Worker  } else {
56*8975f5c5SAndroid Build Coastguard Worker    v8_target_cpu = target_cpu
57*8975f5c5SAndroid Build Coastguard Worker  }
58*8975f5c5SAndroid Build Coastguard Worker}
59*8975f5c5SAndroid Build Coastguard Worker
60*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
61*8975f5c5SAndroid Build Coastguard Worker  # This argument is declared here so that it can be overridden in toolchains.
62*8975f5c5SAndroid Build Coastguard Worker  # It should never be explicitly set by the user.
63*8975f5c5SAndroid Build Coastguard Worker  v8_current_cpu = v8_target_cpu
64*8975f5c5SAndroid Build Coastguard Worker}
65