xref: /aosp_15_r20/external/bazelbuild-rules_cc/cc/private/toolchain/BUILD.tpl (revision eed53cd41c5909d05eedc7ad9720bb158fd93452)
1*eed53cd4SHONG Yifan# Copyright 2016 The Bazel Authors. All rights reserved.
2*eed53cd4SHONG Yifan#
3*eed53cd4SHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License");
4*eed53cd4SHONG Yifan# you may not use this file except in compliance with the License.
5*eed53cd4SHONG Yifan# You may obtain a copy of the License at
6*eed53cd4SHONG Yifan#
7*eed53cd4SHONG Yifan#    http://www.apache.org/licenses/LICENSE-2.0
8*eed53cd4SHONG Yifan#
9*eed53cd4SHONG Yifan# Unless required by applicable law or agreed to in writing, software
10*eed53cd4SHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS,
11*eed53cd4SHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*eed53cd4SHONG Yifan# See the License for the specific language governing permissions and
13*eed53cd4SHONG Yifan# limitations under the License.
14*eed53cd4SHONG Yifan
15*eed53cd4SHONG Yifan# This becomes the BUILD file for @local_config_cc// under non-FreeBSD unixes.
16*eed53cd4SHONG Yifan
17*eed53cd4SHONG Yifanpackage(default_visibility = ["//visibility:public"])
18*eed53cd4SHONG Yifan
19*eed53cd4SHONG Yifanload(":cc_toolchain_config.bzl", "cc_toolchain_config")
20*eed53cd4SHONG Yifanload(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config")
21*eed53cd4SHONG Yifanload("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
22*eed53cd4SHONG Yifan
23*eed53cd4SHONG Yifanlicenses(["notice"])  # Apache 2.0
24*eed53cd4SHONG Yifan
25*eed53cd4SHONG Yifancc_library(
26*eed53cd4SHONG Yifan    name = "malloc",
27*eed53cd4SHONG Yifan)
28*eed53cd4SHONG Yifan
29*eed53cd4SHONG Yifanfilegroup(
30*eed53cd4SHONG Yifan    name = "empty",
31*eed53cd4SHONG Yifan    srcs = [],
32*eed53cd4SHONG Yifan)
33*eed53cd4SHONG Yifan
34*eed53cd4SHONG Yifanfilegroup(
35*eed53cd4SHONG Yifan    name = "cc_wrapper",
36*eed53cd4SHONG Yifan    srcs = ["cc_wrapper.sh"],
37*eed53cd4SHONG Yifan)
38*eed53cd4SHONG Yifan
39*eed53cd4SHONG Yifanfilegroup(
40*eed53cd4SHONG Yifan    name = "compiler_deps",
41*eed53cd4SHONG Yifan    srcs = glob(["extra_tools/**"], allow_empty = True) + [%{cc_compiler_deps}],
42*eed53cd4SHONG Yifan)
43*eed53cd4SHONG Yifan
44*eed53cd4SHONG Yifan# This is the entry point for --crosstool_top.  Toolchains are found
45*eed53cd4SHONG Yifan# by lopping off the name of --crosstool_top and searching for
46*eed53cd4SHONG Yifan# the "${CPU}" entry in the toolchains attribute.
47*eed53cd4SHONG Yifancc_toolchain_suite(
48*eed53cd4SHONG Yifan    name = "toolchain",
49*eed53cd4SHONG Yifan    toolchains = {
50*eed53cd4SHONG Yifan        "%{name}|%{compiler}": ":cc-compiler-%{name}",
51*eed53cd4SHONG Yifan        "%{name}": ":cc-compiler-%{name}",
52*eed53cd4SHONG Yifan        "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
53*eed53cd4SHONG Yifan        "armeabi-v7a": ":cc-compiler-armeabi-v7a",
54*eed53cd4SHONG Yifan    },
55*eed53cd4SHONG Yifan)
56*eed53cd4SHONG Yifan
57*eed53cd4SHONG Yifancc_toolchain(
58*eed53cd4SHONG Yifan    name = "cc-compiler-%{name}",
59*eed53cd4SHONG Yifan    toolchain_identifier = "%{cc_toolchain_identifier}",
60*eed53cd4SHONG Yifan    toolchain_config = ":%{cc_toolchain_identifier}",
61*eed53cd4SHONG Yifan    all_files = ":compiler_deps",
62*eed53cd4SHONG Yifan    ar_files = ":compiler_deps",
63*eed53cd4SHONG Yifan    as_files = ":compiler_deps",
64*eed53cd4SHONG Yifan    compiler_files = ":compiler_deps",
65*eed53cd4SHONG Yifan    dwp_files = ":empty",
66*eed53cd4SHONG Yifan    linker_files = ":compiler_deps",
67*eed53cd4SHONG Yifan    objcopy_files = ":empty",
68*eed53cd4SHONG Yifan    strip_files = ":empty",
69*eed53cd4SHONG Yifan    supports_param_files = %{supports_param_files},
70*eed53cd4SHONG Yifan)
71*eed53cd4SHONG Yifan
72*eed53cd4SHONG Yifancc_toolchain_config(
73*eed53cd4SHONG Yifan    name = "%{cc_toolchain_identifier}",
74*eed53cd4SHONG Yifan    cpu = "%{target_cpu}",
75*eed53cd4SHONG Yifan    compiler = "%{compiler}",
76*eed53cd4SHONG Yifan    toolchain_identifier = "%{cc_toolchain_identifier}",
77*eed53cd4SHONG Yifan    host_system_name = "%{host_system_name}",
78*eed53cd4SHONG Yifan    target_system_name = "%{target_system_name}",
79*eed53cd4SHONG Yifan    target_libc = "%{target_libc}",
80*eed53cd4SHONG Yifan    abi_version = "%{abi_version}",
81*eed53cd4SHONG Yifan    abi_libc_version = "%{abi_libc_version}",
82*eed53cd4SHONG Yifan    cxx_builtin_include_directories = [%{cxx_builtin_include_directories}],
83*eed53cd4SHONG Yifan    tool_paths = {%{tool_paths}},
84*eed53cd4SHONG Yifan    compile_flags = [%{compile_flags}],
85*eed53cd4SHONG Yifan    opt_compile_flags = [%{opt_compile_flags}],
86*eed53cd4SHONG Yifan    dbg_compile_flags = [%{dbg_compile_flags}],
87*eed53cd4SHONG Yifan    cxx_flags = [%{cxx_flags}],
88*eed53cd4SHONG Yifan    link_flags = [%{link_flags}],
89*eed53cd4SHONG Yifan    link_libs = [%{link_libs}],
90*eed53cd4SHONG Yifan    opt_link_flags = [%{opt_link_flags}],
91*eed53cd4SHONG Yifan    unfiltered_compile_flags = [%{unfiltered_compile_flags}],
92*eed53cd4SHONG Yifan    coverage_compile_flags = [%{coverage_compile_flags}],
93*eed53cd4SHONG Yifan    coverage_link_flags = [%{coverage_link_flags}],
94*eed53cd4SHONG Yifan    supports_start_end_lib = %{supports_start_end_lib},
95*eed53cd4SHONG Yifan)
96*eed53cd4SHONG Yifan
97*eed53cd4SHONG Yifan# Android tooling requires a default toolchain for the armeabi-v7a cpu.
98*eed53cd4SHONG Yifancc_toolchain(
99*eed53cd4SHONG Yifan    name = "cc-compiler-armeabi-v7a",
100*eed53cd4SHONG Yifan    toolchain_identifier = "stub_armeabi-v7a",
101*eed53cd4SHONG Yifan    toolchain_config = ":stub_armeabi-v7a",
102*eed53cd4SHONG Yifan    all_files = ":empty",
103*eed53cd4SHONG Yifan    ar_files = ":empty",
104*eed53cd4SHONG Yifan    as_files = ":empty",
105*eed53cd4SHONG Yifan    compiler_files = ":empty",
106*eed53cd4SHONG Yifan    dwp_files = ":empty",
107*eed53cd4SHONG Yifan    linker_files = ":empty",
108*eed53cd4SHONG Yifan    objcopy_files = ":empty",
109*eed53cd4SHONG Yifan    strip_files = ":empty",
110*eed53cd4SHONG Yifan    supports_param_files = 1,
111*eed53cd4SHONG Yifan)
112*eed53cd4SHONG Yifan
113*eed53cd4SHONG Yifanarmeabi_cc_toolchain_config(name = "stub_armeabi-v7a")
114