xref: /aosp_15_r20/external/angle/build/toolchain/mac/BUILD.gn (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# Copyright 2021 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/mac/mac_sdk.gni")
6import("//build/config/v8_target_cpu.gni")
7import("//build/toolchain/apple/toolchain.gni")
8import("//build_overrides/build.gni")
9
10# Specialisation of the apple_toolchain template to declare the toolchain
11# and its tools to build target for macOS platform.
12template("mac_toolchain") {
13  assert(defined(invoker.toolchain_args),
14         "Toolchains must declare toolchain_args")
15
16  apple_toolchain(target_name) {
17    forward_variables_from(invoker, "*", [ "toolchain_args" ])
18
19    bin_path = mac_bin_path
20
21    toolchain_args = {
22      forward_variables_from(invoker.toolchain_args, "*")
23      current_os = "mac"
24
25      if (target_os == "ios") {
26        # Use LLD for the host part of a chrome/ios build.
27        use_lld = true
28
29        # Override `is_component_build` for the host toolchain.
30        # See https://crbug.com/gn/286 for details why this is
31        # required.
32        is_component_build = is_debug
33
34        # Defined in //base, would trigger a warning if the build doesn't depend
35        # on it.
36        if (build_with_chromium) {
37          # cronet disable this because it targets 32-bit,
38          # enable it unconditionally for the host toolchain.
39          use_allocator_shim = true
40        }
41
42        # TODO(crbug.com/40534102): the use_sanitizer_coverage arg is currently
43        # not supported by the Chromium mac_clang_x64 toolchain on iOS
44        # distribution.
45        use_sanitizer_coverage = false
46
47        # iOS supports being build with or without blink, but macOS requires
48        # it to be enabled, even if iOS build force disable it in args.gn.
49        use_blink = true
50      }
51    }
52  }
53}
54
55mac_toolchain("clang_arm") {
56  toolchain_args = {
57    current_cpu = "arm"
58  }
59}
60
61mac_toolchain("clang_arm64") {
62  toolchain_args = {
63    current_cpu = "arm64"
64  }
65}
66
67mac_toolchain("clang_x64") {
68  toolchain_args = {
69    current_cpu = "x64"
70  }
71}
72
73mac_toolchain("clang_x86") {
74  toolchain_args = {
75    current_cpu = "x86"
76  }
77}
78
79mac_toolchain("clang_x86_v8_arm") {
80  toolchain_args = {
81    current_cpu = "x86"
82    v8_current_cpu = "arm"
83  }
84}
85
86mac_toolchain("clang_x86_v8_mipsel") {
87  toolchain_args = {
88    current_cpu = "x86"
89    v8_current_cpu = "mipsel"
90  }
91}
92
93mac_toolchain("clang_x64_v8_arm64") {
94  toolchain_args = {
95    current_cpu = "x64"
96    v8_current_cpu = "arm64"
97  }
98}
99
100mac_toolchain("clang_x64_v8_mips64el") {
101  toolchain_args = {
102    current_cpu = "x64"
103    v8_current_cpu = "mips64el"
104  }
105}
106
107mac_toolchain("clang_arm64_v8_x64") {
108  toolchain_args = {
109    current_cpu = "arm64"
110    v8_current_cpu = "x64"
111  }
112}
113
114# Needed to run v8 on the host during a arm64 -> x86_64 cross-build
115mac_toolchain("clang_arm64_v8_arm64") {
116  toolchain_args = {
117    current_cpu = "arm64"
118    v8_current_cpu = "arm64"
119  }
120}
121