1# Copyright 2014 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/chromeos/ui_mode.gni") 6import("//build/config/v8_target_cpu.gni") 7 8# These are primarily relevant in current_cpu == "arm" contexts, where 9# ARM code is being compiled. But they can also be relevant in the 10# other contexts when the code will change its behavior based on the 11# cpu it wants to generate code for. 12if (current_cpu == "arm" || v8_current_cpu == "arm") { 13 declare_args() { 14 # Version of the ARM processor when compiling on ARM. Ignored on non-ARM 15 # platforms. 16 arm_version = 7 17 18 # The ARM architecture. This will be a string like "armv6" or "armv7-a". 19 # An empty string means to use the default for the arm_version. 20 arm_arch = "" 21 22 # The ARM floating point hardware. This will be a string like "neon" or 23 # "vfpv3". An empty string means to use the default for the arm_version. 24 arm_fpu = "" 25 26 # The ARM variant-specific tuning mode. This will be a string like "armv6" 27 # or "cortex-a15". An empty string means to use the default for the 28 # arm_version. 29 arm_tune = "" 30 31 # Whether to use the neon FPU instruction set or not. 32 arm_use_neon = "" 33 34 # Whether to enable optional NEON code paths. 35 arm_optionally_use_neon = false 36 37 # Thumb is a reduced instruction set available on some ARM processors that 38 # has increased code density. 39 arm_use_thumb = true 40 } 41 42 if (current_os == "android" || target_os == "android") { 43 arm_float_abi = "softfp" 44 } else { 45 declare_args() { 46 # The ARM floating point mode. This is either the string "hard", "soft", 47 # or "softfp". An empty string means to use the default one for the 48 # arm_version. 49 arm_float_abi = "" 50 } 51 } 52 assert(arm_float_abi == "" || arm_float_abi == "hard" || 53 arm_float_abi == "soft" || arm_float_abi == "softfp") 54 55 if (arm_use_neon == "") { 56 if (current_os == "linux" && target_cpu != v8_target_cpu) { 57 # Don't use neon on V8 simulator builds as a default. 58 arm_use_neon = false 59 } else { 60 arm_use_neon = true 61 } 62 } 63 64 if (arm_version == 6) { 65 if (arm_arch == "") { 66 # v8 can still with version 6 but only with the armv6k extension. 67 arm_arch = "armv6k" 68 } 69 if (arm_tune != "") { 70 arm_tune = "" 71 } 72 if (arm_float_abi == "") { 73 arm_float_abi = "softfp" 74 } 75 if (arm_fpu == "") { 76 arm_fpu = "vfp" 77 } 78 arm_use_thumb = false 79 arm_use_neon = false 80 } else if (arm_version == 7) { 81 if (arm_arch == "") { 82 arm_arch = "armv7-a" 83 } 84 85 if (arm_float_abi == "") { 86 if (current_os == "linux" && target_cpu != v8_target_cpu) { 87 # Default to the same as Android for V8 simulator builds. 88 arm_float_abi = "softfp" 89 } else { 90 arm_float_abi = "hard" 91 } 92 } 93 94 if (arm_fpu == "") { 95 if (arm_use_neon) { 96 arm_fpu = "neon" 97 } else { 98 arm_fpu = "vfpv3-d16" 99 } 100 } 101 } else if (arm_version == 8) { 102 if (arm_arch == "") { 103 arm_arch = "armv8-a" 104 } 105 if (arm_tune == "") { 106 arm_tune = "generic-armv8-a" 107 } 108 109 if (arm_float_abi == "") { 110 arm_float_abi = "hard" 111 } 112 113 if (arm_fpu == "") { 114 if (arm_use_neon) { 115 arm_fpu = "neon" 116 } else { 117 arm_fpu = "vfpv3-d16" 118 } 119 } 120 } 121} else if (current_cpu == "arm64" || v8_current_cpu == "arm64") { 122 # arm64 supports only "hard". 123 arm_float_abi = "hard" 124 arm_use_neon = true 125 declare_args() { 126 # Enables the new Armv8 branch protection features. Valid strings are: 127 # - "pac": Enables Pointer Authentication Code (PAC, featured in Armv8.3) 128 # - "standard": Enables both PAC and Branch Target Identification (Armv8.5). 129 # - "none": No branch protection. 130 arm_control_flow_integrity = "none" 131 132 if ((is_android || is_linux) && target_cpu == "arm64") { 133 # Enable PAC and BTI on AArch64 Linux/Android systems. 134 # target_cpu == "arm64" filters out some cases (e.g. the ChromeOS x64 135 # MSAN build) where the target platform is x64, but V8 is configured to 136 # use the arm64 simulator. 137 arm_control_flow_integrity = "standard" 138 } 139 140 if (host_os == "mac" && host_cpu == "arm64") { 141 # Disable ARM integrity flow or build 142 # will fail because of this issue 143 # https://groups.google.com/g/v8-users/c/rykJ2F9RIcc/m/QKpWNoeJDgAJ 144 arm_control_flow_integrity = "none" 145 } 146 } 147 assert(arm_control_flow_integrity == "none" || 148 arm_control_flow_integrity == "standard" || 149 arm_control_flow_integrity == "pac", 150 "Invalid branch protection option") 151} 152