1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159

build / config / arm.gni [blame]

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chromeos/ui_mode.gni")
import("//build/config/v8_target_cpu.gni")

# These are primarily relevant in current_cpu == "arm" contexts, where
# ARM code is being compiled.  But they can also be relevant in the
# other contexts when the code will change its behavior based on the
# cpu it wants to generate code for.
if (current_cpu == "arm" || v8_current_cpu == "arm") {
  declare_args() {
    # Version of the ARM processor when compiling on ARM. Ignored on non-ARM
    # platforms.
    arm_version = 7

    # The ARM architecture. This will be a string like "armv6" or "armv7-a".
    # An empty string means to use the default for the arm_version.
    arm_arch = ""

    # The ARM floating point hardware. This will be a string like "neon" or
    # "vfpv3". An empty string means to use the default for the arm_version.
    arm_fpu = ""

    # The ARM variant-specific tuning mode. This will be a string like "armv6"
    # or "cortex-a15". An empty string means to use the default for the
    # arm_version.
    arm_tune = ""

    # Whether to use the neon FPU instruction set or not.
    arm_use_neon = ""

    # Whether to enable optional NEON code paths.
    arm_optionally_use_neon = false

    # Thumb is a reduced instruction set available on some ARM processors that
    # has increased code density.
    arm_use_thumb = true
  }

  # For lacros build, we use ARM v8 by default.
  if (is_chromeos_lacros && arm_arch == "") {
    # TODO(crbug.com/40276884) Enable i8mm and dotprod instructions for ffmpeg
    # if ever we update to a version of arm that supports these instructions.
    arm_version = 8
    arm_arch = "armv8-a+crc"
  }

  if (current_os == "android" || target_os == "android") {
    arm_float_abi = "softfp"
  } else {
    declare_args() {
      # The ARM floating point mode. This is either the string "hard", "soft",
      # or "softfp". An empty string means to use the default one for the
      # arm_version.
      arm_float_abi = ""
    }
  }
  assert(arm_float_abi == "" || arm_float_abi == "hard" ||
         arm_float_abi == "soft" || arm_float_abi == "softfp")

  if (arm_use_neon == "") {
    if (current_os == "linux" && target_cpu != v8_target_cpu) {
      # Don't use neon on V8 simulator builds as a default.
      arm_use_neon = false
    } else {
      arm_use_neon = true
    }
  }

  if (arm_version == 6) {
    if (arm_arch == "") {
      # v8 can still with version 6 but only with the armv6k extension.
      arm_arch = "armv6k"
    }
    if (arm_tune != "") {
      arm_tune = ""
    }
    if (arm_float_abi == "") {
      arm_float_abi = "softfp"
    }
    if (arm_fpu == "") {
      arm_fpu = "vfp"
    }
    arm_use_thumb = false
    arm_use_neon = false
  } else if (arm_version == 7) {
    if (arm_arch == "") {
      arm_arch = "armv7-a"
    }

    if (arm_float_abi == "") {
      if (current_os == "linux" && target_cpu != v8_target_cpu) {
        # Default to the same as Android for V8 simulator builds.
        arm_float_abi = "softfp"
      } else {
        arm_float_abi = "hard"
      }
    }

    if (arm_fpu == "") {
      if (arm_use_neon) {
        arm_fpu = "neon"
      } else {
        arm_fpu = "vfpv3-d16"
      }
    }
  } else if (arm_version == 8) {
    if (arm_arch == "") {
      arm_arch = "armv8-a"
    }
    if (arm_tune == "") {
      arm_tune = "generic-armv8-a"
    }

    if (arm_float_abi == "") {
      arm_float_abi = "hard"
    }

    if (arm_fpu == "") {
      if (arm_use_neon) {
        arm_fpu = "neon"
      } else {
        arm_fpu = "vfpv3-d16"
      }
    }
  }
} else if (current_cpu == "arm64" || v8_current_cpu == "arm64") {
  # arm64 supports only "hard".
  arm_float_abi = "hard"
  arm_use_neon = true
  declare_args() {
    # Enables the new Armv8 branch protection features. Valid strings are:
    # - "pac": Enables Pointer Authentication Code (PAC, featured in Armv8.3)
    # - "standard": Enables both PAC and Branch Target Identification (Armv8.5).
    # - "none": No branch protection.
    arm_control_flow_integrity = "none"

    if ((is_android || is_linux) && target_cpu == "arm64") {
      # Enable PAC and BTI on AArch64 Linux/Android systems.
      # target_cpu == "arm64" filters out some cases (e.g. the ChromeOS x64
      # MSAN build) where the target platform is x64, but V8 is configured to
      # use the arm64 simulator.
      arm_control_flow_integrity = "standard"
    }

    if (host_os == "mac" && host_cpu == "arm64") {
      # Disable ARM integrity flow or build
      # will fail because of this issue
      # https://groups.google.com/g/v8-users/c/rykJ2F9RIcc/m/QKpWNoeJDgAJ
      arm_control_flow_integrity = "none"
    }
  }
  assert(arm_control_flow_integrity == "none" ||
             arm_control_flow_integrity == "standard" ||
             arm_control_flow_integrity == "pac",
         "Invalid branch protection option")
}