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

build / toolchain / mac / BUILD.gn [blame]

# Copyright 2021 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/mac/mac_sdk.gni")
import("//build/config/v8_target_cpu.gni")
import("//build/toolchain/apple/toolchain.gni")
import("//build_overrides/build.gni")

# Specialisation of the apple_toolchain template to declare the toolchain
# and its tools to build target for macOS platform.
template("mac_toolchain") {
  assert(defined(invoker.toolchain_args),
         "Toolchains must declare toolchain_args")

  apple_toolchain(target_name) {
    forward_variables_from(invoker, "*", [ "toolchain_args" ])

    bin_path = mac_bin_path

    toolchain_args = {
      forward_variables_from(invoker.toolchain_args, "*")
      current_os = "mac"

      if (target_os == "ios") {
        # Use LLD for the host part of a chrome/ios build.
        use_lld = true

        # Override `is_component_build` for the host toolchain.
        # See https://crbug.com/gn/286 for details why this is
        # required.
        is_component_build = is_debug

        # Defined in //base, would trigger a warning if the build doesn't depend
        # on it.
        if (build_with_chromium) {
          # cronet disable this because it targets 32-bit,
          # enable it unconditionally for the host toolchain.
          use_allocator_shim = true
        }

        # TODO(crbug.com/40534102): the use_sanitizer_coverage arg is currently
        # not supported by the Chromium mac_clang_x64 toolchain on iOS
        # distribution.
        use_sanitizer_coverage = false

        # iOS supports being build with or without blink, but macOS requires
        # it to be enabled, even if iOS build force disable it in args.gn.
        use_blink = true
      }
    }
  }
}

mac_toolchain("clang_arm") {
  toolchain_args = {
    current_cpu = "arm"
  }
}

mac_toolchain("clang_arm64") {
  toolchain_args = {
    current_cpu = "arm64"
  }
}

mac_toolchain("clang_x64") {
  toolchain_args = {
    current_cpu = "x64"
  }
}

mac_toolchain("clang_x86") {
  toolchain_args = {
    current_cpu = "x86"
  }
}

mac_toolchain("clang_x86_v8_arm") {
  toolchain_args = {
    current_cpu = "x86"
    v8_current_cpu = "arm"
  }
}

mac_toolchain("clang_x86_v8_mipsel") {
  toolchain_args = {
    current_cpu = "x86"
    v8_current_cpu = "mipsel"
  }
}

mac_toolchain("clang_x64_v8_arm64") {
  toolchain_args = {
    current_cpu = "x64"
    v8_current_cpu = "arm64"
  }
}

mac_toolchain("clang_x64_v8_mips64el") {
  toolchain_args = {
    current_cpu = "x64"
    v8_current_cpu = "mips64el"
  }
}

mac_toolchain("clang_arm64_v8_x64") {
  toolchain_args = {
    current_cpu = "arm64"
    v8_current_cpu = "x64"
  }
}

# Needed to run v8 on the host during a arm64 -> x86_64 cross-build
mac_toolchain("clang_arm64_v8_arm64") {
  toolchain_args = {
    current_cpu = "arm64"
    v8_current_cpu = "arm64"
  }
}