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 # For lacros build, we use ARM v8 by default. 43 if (is_chromeos_lacros && arm_arch == "") { 44 # TODO(crbug.com/1467681) Enable i8mm and dotprod instructions for ffmpeg 45 # if ever we update to a version of arm that supports these instructions. 46 arm_version = 8 47 arm_arch = "armv8-a+crc" 48 } 49 50 if (current_os == "android" || target_os == "android") { 51 arm_float_abi = "softfp" 52 } else { 53 declare_args() { 54 # The ARM floating point mode. This is either the string "hard", "soft", 55 # or "softfp". An empty string means to use the default one for the 56 # arm_version. 57 arm_float_abi = "" 58 } 59 } 60 assert(arm_float_abi == "" || arm_float_abi == "hard" || 61 arm_float_abi == "soft" || arm_float_abi == "softfp") 62 63 if (arm_use_neon == "") { 64 if (current_os == "linux" && target_cpu != v8_target_cpu) { 65 # Don't use neon on V8 simulator builds as a default. 66 arm_use_neon = false 67 } else { 68 arm_use_neon = true 69 } 70 } 71 72 if (arm_version == 6) { 73 if (arm_arch == "") { 74 # v8 can still with version 6 but only with the armv6k extension. 75 arm_arch = "armv6k" 76 } 77 if (arm_tune != "") { 78 arm_tune = "" 79 } 80 if (arm_float_abi == "") { 81 arm_float_abi = "softfp" 82 } 83 if (arm_fpu == "") { 84 arm_fpu = "vfp" 85 } 86 arm_use_thumb = false 87 arm_use_neon = false 88 } else if (arm_version == 7) { 89 if (arm_arch == "") { 90 arm_arch = "armv7-a" 91 } 92 93 if (arm_float_abi == "") { 94 if (current_os == "linux" && target_cpu != v8_target_cpu) { 95 # Default to the same as Android for V8 simulator builds. 96 arm_float_abi = "softfp" 97 } else { 98 arm_float_abi = "hard" 99 } 100 } 101 102 if (arm_fpu == "") { 103 if (arm_use_neon) { 104 arm_fpu = "neon" 105 } else { 106 arm_fpu = "vfpv3-d16" 107 } 108 } 109 } else if (arm_version == 8) { 110 if (arm_arch == "") { 111 arm_arch = "armv8-a" 112 } 113 if (arm_tune == "") { 114 arm_tune = "generic-armv8-a" 115 } 116 117 if (arm_float_abi == "") { 118 arm_float_abi = "hard" 119 } 120 121 if (arm_fpu == "") { 122 if (arm_use_neon) { 123 arm_fpu = "neon" 124 } else { 125 arm_fpu = "vfpv3-d16" 126 } 127 } 128 } 129} else if (current_cpu == "arm64" || v8_current_cpu == "arm64") { 130 # arm64 supports only "hard". 131 arm_float_abi = "hard" 132 arm_use_neon = true 133 declare_args() { 134 # Enables the new Armv8 branch protection features. Valid strings are: 135 # - "pac": Enables Pointer Authentication Code (PAC, featured in Armv8.3) 136 # - "standard": Enables both PAC and Branch Target Identification (Armv8.5). 137 # - "none": No branch protection. 138 arm_control_flow_integrity = "none" 139 140 if ((is_android || is_linux) && target_cpu == "arm64") { 141 # Enable PAC and BTI on AArch64 Linux/Android systems. 142 # target_cpu == "arm64" filters out some cases (e.g. the ChromeOS x64 143 # MSAN build) where the target platform is x64, but V8 is configured to 144 # use the arm64 simulator. 145 arm_control_flow_integrity = "standard" 146 } 147 } 148 assert(arm_control_flow_integrity == "none" || 149 arm_control_flow_integrity == "standard" || 150 arm_control_flow_integrity == "pac", 151 "Invalid branch protection option") 152} 153