Index: build/config/v8_target_cpu.gni |
diff --git a/build/config/v8_target_cpu.gni b/build/config/v8_target_cpu.gni |
index 32e53c198820aa658e8a55d1f5c78f91049d1072..6a7c1a3774751a28f126b317c9c3dd03af43ec37 100644 |
--- a/build/config/v8_target_cpu.gni |
+++ b/build/config/v8_target_cpu.gni |
@@ -14,20 +14,44 @@ declare_args() { |
# This arg is defined here rather than in the v8 project because we want |
# some of the common architecture-specific args (like arm_float_abi or |
# mips_arch_variant) to be set to their defaults either if the current_cpu |
- # applies *or* if the v8_target_cpu applies. |
+ # applies *or* if the v8_current_cpu applies. |
# |
- # TODO(crbug.com/620527) - rework this whole approach so that it isn't |
- # v8-specific. |
+ # As described below, you can also specify the v8_target_cpu to use |
+ # indirectly by specifying a `custom_toolchain` that contains v8_$cpu in the |
+ # name after the normal toolchain. |
+ # |
+ # For example, `gn gen --args="custom_toolchain=...:clang_x64_v8_arm64"` |
+ # is equivalent to setting --args=`v8_target_cpu="arm64"`. Setting |
+ # `custom_toolchain` is more verbose but makes the toolchain that is |
+ # (effectively) being used explicit. |
+ # |
+ # v8_target_cpu can only be used to target one architecture in a build, |
+ # so if you wish to build multiple copies of v8 that are targetting |
+ # different architectures, you will need to do something more |
+ # complicated involving multiple toolchains along the lines of |
+ # custom_toolchain, above. |
v8_target_cpu = "" |
} |
if (v8_target_cpu == "") { |
- if (is_msan) { |
- # Running the V8-generated code on an ARM simulator is a powerful hack that |
- # allows the tool to see the memory accesses from JITted code. Without this |
- # flag, JS code causes false positive reports from MSan. |
+ if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64" || |
+ current_toolchain == "//build/toolchain/linux:x64_v8_arm64") { |
+ v8_target_cpu = "arm64" |
+ } else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm" || |
+ current_toolchain == "//build/toolchain/linux:x86_v8_arm") { |
+ v8_target_cpu = "arm" |
+ } else if (is_msan) { |
+ # If we're running under a sanitizer, if we configure v8 to generate |
+ # code that will be run under a simulator, then the generated code |
+ # also gets the benefits of the sanitizer. |
v8_target_cpu = "arm64" |
} else { |
v8_target_cpu = target_cpu |
} |
} |
+ |
+declare_args() { |
+ # This argument is declared here so that it can be overridden in toolchains. |
+ # It should never be explicitly set by the user. |
+ v8_current_cpu = v8_target_cpu |
+} |