v8_target_cpu.gni 2.7 KB

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