arm.gni 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # Copyright 2014 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/chromeos/ui_mode.gni")
  5. import("//build/config/v8_target_cpu.gni")
  6. # These are primarily relevant in current_cpu == "arm" contexts, where
  7. # ARM code is being compiled. But they can also be relevant in the
  8. # other contexts when the code will change its behavior based on the
  9. # cpu it wants to generate code for.
  10. if (current_cpu == "arm" || v8_current_cpu == "arm") {
  11. declare_args() {
  12. # Version of the ARM processor when compiling on ARM. Ignored on non-ARM
  13. # platforms.
  14. arm_version = 7
  15. # The ARM architecture. This will be a string like "armv6" or "armv7-a".
  16. # An empty string means to use the default for the arm_version.
  17. arm_arch = ""
  18. # The ARM floating point hardware. This will be a string like "neon" or
  19. # "vfpv3". An empty string means to use the default for the arm_version.
  20. arm_fpu = ""
  21. # The ARM variant-specific tuning mode. This will be a string like "armv6"
  22. # or "cortex-a15". An empty string means to use the default for the
  23. # arm_version.
  24. arm_tune = ""
  25. # Whether to use the neon FPU instruction set or not.
  26. arm_use_neon = ""
  27. # Whether to enable optional NEON code paths.
  28. arm_optionally_use_neon = false
  29. # Thumb is a reduced instruction set available on some ARM processors that
  30. # has increased code density.
  31. arm_use_thumb = true
  32. }
  33. # For lacros build, we use ARM v8 by default.
  34. if (is_chromeos_lacros && arm_arch == "") {
  35. arm_version = 8
  36. arm_arch = "armv8-a+crc"
  37. }
  38. if (current_os == "android" || target_os == "android") {
  39. arm_float_abi = "softfp"
  40. } else {
  41. declare_args() {
  42. # The ARM floating point mode. This is either the string "hard", "soft",
  43. # or "softfp". An empty string means to use the default one for the
  44. # arm_version.
  45. arm_float_abi = ""
  46. }
  47. }
  48. assert(arm_float_abi == "" || arm_float_abi == "hard" ||
  49. arm_float_abi == "soft" || arm_float_abi == "softfp")
  50. if (arm_use_neon == "") {
  51. if (current_os == "linux" && target_cpu != v8_target_cpu) {
  52. # Don't use neon on V8 simulator builds as a default.
  53. arm_use_neon = false
  54. } else {
  55. arm_use_neon = true
  56. }
  57. }
  58. if (arm_version == 6) {
  59. if (arm_arch == "") {
  60. # v8 can still with version 6 but only with the armv6k extension.
  61. arm_arch = "armv6k"
  62. }
  63. if (arm_tune != "") {
  64. arm_tune = ""
  65. }
  66. if (arm_float_abi == "") {
  67. arm_float_abi = "softfp"
  68. }
  69. if (arm_fpu == "") {
  70. arm_fpu = "vfp"
  71. }
  72. arm_use_thumb = false
  73. arm_use_neon = false
  74. } else if (arm_version == 7) {
  75. if (arm_arch == "") {
  76. arm_arch = "armv7-a"
  77. }
  78. if (arm_float_abi == "") {
  79. if (current_os == "linux" && target_cpu != v8_target_cpu) {
  80. # Default to the same as Android for V8 simulator builds.
  81. arm_float_abi = "softfp"
  82. } else {
  83. arm_float_abi = "hard"
  84. }
  85. }
  86. if (arm_fpu == "") {
  87. if (arm_use_neon) {
  88. arm_fpu = "neon"
  89. } else {
  90. arm_fpu = "vfpv3-d16"
  91. }
  92. }
  93. } else if (arm_version == 8) {
  94. if (arm_arch == "") {
  95. arm_arch = "armv8-a"
  96. }
  97. if (arm_tune == "") {
  98. arm_tune = "generic-armv8-a"
  99. }
  100. if (arm_float_abi == "") {
  101. arm_float_abi = "hard"
  102. }
  103. if (arm_fpu == "") {
  104. if (arm_use_neon) {
  105. arm_fpu = "neon"
  106. } else {
  107. arm_fpu = "vfpv3-d16"
  108. }
  109. }
  110. }
  111. } else if (current_cpu == "arm64" || v8_current_cpu == "arm64") {
  112. # arm64 supports only "hard".
  113. arm_float_abi = "hard"
  114. arm_use_neon = true
  115. declare_args() {
  116. # Enables the new Armv8 branch protection features. Valid strings are:
  117. # - "pac": Enables Pointer Authentication Code (PAC, featured in Armv8.3)
  118. # - "standard": Enables both PAC and Branch Target Identification (Armv8.5).
  119. # - "none": No branch protection.
  120. arm_control_flow_integrity = "standard"
  121. # TODO(cavalcantii): enable the feature for the following OSes next.
  122. if (is_mac || is_chromeos || is_fuchsia || is_win ||
  123. target_cpu != "arm64") {
  124. # target_cpu != "arm64" covers some cases (e.g. the ChromeOS x64 MSAN
  125. # build) where the target platform is x64, but V8 is configured to use
  126. # the arm64 simulator. Pointer authentication doesn't work properly
  127. # in this mode (yet).
  128. arm_control_flow_integrity = "none"
  129. }
  130. }
  131. assert(arm_control_flow_integrity == "none" ||
  132. arm_control_flow_integrity == "standard" ||
  133. arm_control_flow_integrity == "pac",
  134. "Invalid branch protection option")
  135. }