OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/sanitizers/sanitizers.gni") | 5 import("//build/config/sanitizers/sanitizers.gni") |
6 | 6 |
7 declare_args() { | 7 declare_args() { |
8 # This arg is used when we want to tell the JIT-generating v8 code | 8 # This arg is used when we want to tell the JIT-generating v8 code |
9 # that we want to have it generate for an architecture that is different | 9 # that we want to have it generate for an architecture that is different |
10 # than the architecture that v8 will actually run on; we then run the | 10 # than the architecture that v8 will actually run on; we then run the |
11 # code under an emulator. For example, we might run v8 on x86, but | 11 # code under an emulator. For example, we might run v8 on x86, but |
12 # generate arm code and run that under emulation. | 12 # generate arm code and run that under emulation. |
13 # | 13 # |
14 # This arg is defined here rather than in the v8 project because we want | 14 # This arg is defined here rather than in the v8 project because we want |
15 # some of the common architecture-specific args (like arm_float_abi or | 15 # some of the common architecture-specific args (like arm_float_abi or |
16 # mips_arch_variant) to be set to their defaults either if the current_cpu | 16 # mips_arch_variant) to be set to their defaults either if the current_cpu |
17 # applies *or* if the v8_target_cpu applies. | 17 # applies *or* if the v8_current_cpu applies. |
18 # | 18 # |
19 # TODO(crbug.com/620527) - rework this whole approach so that it isn't | 19 # As described below, you can also specify the v8_target_cpu to use |
20 # v8-specific. | 20 # indirectly by specifying a `custom_toolchain` that contains v8_$cpu in the |
| 21 # name after the normal toolchain. |
| 22 # |
| 23 # For example, `gn gen --args="custom_toolchain=...:clang_x64_v8_arm64"` |
| 24 # is equivalent to setting --args=`v8_target_cpu="arm64"`. Setting |
| 25 # `custom_toolchain` is more verbose but makes the toolchain that is |
| 26 # (effectively) being used explicit. |
| 27 # |
| 28 # v8_target_cpu can only be used to target one architecture in a build, |
| 29 # so if you wish to build multiple copies of v8 that are targetting |
| 30 # different architectures, you will need to do something more |
| 31 # complicated involving multiple toolchains along the lines of |
| 32 # custom_toolchain, above. |
21 v8_target_cpu = "" | 33 v8_target_cpu = "" |
22 } | 34 } |
23 | 35 |
24 if (v8_target_cpu == "") { | 36 if (v8_target_cpu == "") { |
25 if (is_msan) { | 37 if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64" || |
26 # Running the V8-generated code on an ARM simulator is a powerful hack that | 38 current_toolchain == "//build/toolchain/linux:x64_v8_arm64") { |
27 # allows the tool to see the memory accesses from JITted code. Without this | 39 v8_target_cpu = "arm64" |
28 # flag, JS code causes false positive reports from MSan. | 40 } else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm" || |
| 41 current_toolchain == "//build/toolchain/linux:x86_v8_arm") { |
| 42 v8_target_cpu = "arm" |
| 43 } else if (is_msan) { |
| 44 # If we're running under a sanitizer, if we configure v8 to generate |
| 45 # code that will be run under a simulator, then the generated code |
| 46 # also gets the benefits of the sanitizer. |
29 v8_target_cpu = "arm64" | 47 v8_target_cpu = "arm64" |
30 } else { | 48 } else { |
31 v8_target_cpu = target_cpu | 49 v8_target_cpu = target_cpu |
32 } | 50 } |
33 } | 51 } |
| 52 |
| 53 declare_args() { |
| 54 # This argument is declared here so that it can be overridden in toolchains. |
| 55 # It should never be explicitly set by the user. |
| 56 v8_current_cpu = v8_target_cpu |
| 57 } |
OLD | NEW |