blob: ab72a06a4e6b4883fb6787873a6c77e43af9b9cf [file] [log] [blame]
xingao03d52e22017-11-21 08:20:29 -08001# Copyright 2016 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
aldersondrive644b7d412020-01-10 07:48:15 -080015# This becomes the BUILD file for @local_config_cc// under non-BSD unixes.
jcaterf5c8c0b2018-03-27 07:22:35 -070016
rosica71bc38f2019-02-04 02:39:30 -080017load(":cc_toolchain_config.bzl", "cc_toolchain_config")
rosicabeaba922019-05-20 02:36:26 -070018load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config")
oquenchil96068872019-07-08 07:01:39 -070019load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
rosica71bc38f2019-02-04 02:39:30 -080020
Xavier Bonaventura36116ce2021-04-06 02:23:40 -070021package(default_visibility = ["//visibility:public"])
22
xingaode65ce92017-12-20 07:59:30 -080023licenses(["notice"]) # Apache 2.0
24
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000025cc_library(
26 name = "malloc",
27)
28
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000029filegroup(
30 name = "empty",
31 srcs = [],
32)
33
Damien Martin-Guillerez6dab8152016-05-06 12:44:26 +000034filegroup(
35 name = "cc_wrapper",
36 srcs = ["cc_wrapper.sh"],
37)
38
Ilya Biryukov12471a72017-12-20 05:46:44 -080039filegroup(
40 name = "compiler_deps",
Marcel Hlopko8b0bfaf2019-09-02 08:13:18 -070041 srcs = glob(["extra_tools/**"], allow_empty = True) + [%{cc_compiler_deps}],
Ilya Biryukov12471a72017-12-20 05:46:44 -080042)
43
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000044# This is the entry point for --crosstool_top. Toolchains are found
45# by lopping off the name of --crosstool_top and searching for
46# the "${CPU}" entry in the toolchains attribute.
47cc_toolchain_suite(
48 name = "toolchain",
49 toolchains = {
Nicolas Lopezbcbdb872017-03-28 08:08:50 +000050 "%{name}|%{compiler}": ":cc-compiler-%{name}",
rosica547bf422018-09-06 02:10:02 -070051 "%{name}": ":cc-compiler-%{name}",
Alex Humeskyf787d312016-05-03 21:41:34 +000052 "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
rosica547bf422018-09-06 02:10:02 -070053 "armeabi-v7a": ":cc-compiler-armeabi-v7a",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000054 },
55)
56
57cc_toolchain(
58 name = "cc-compiler-%{name}",
hlopko6bc45282018-10-18 02:17:37 -070059 toolchain_identifier = "%{cc_toolchain_identifier}",
rosica71bc38f2019-02-04 02:39:30 -080060 toolchain_config = ":%{cc_toolchain_identifier}",
Ilya Biryukov12471a72017-12-20 05:46:44 -080061 all_files = ":compiler_deps",
rosica44a961b2019-06-06 00:17:06 -070062 ar_files = ":compiler_deps",
63 as_files = ":compiler_deps",
Ilya Biryukov12471a72017-12-20 05:46:44 -080064 compiler_files = ":compiler_deps",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000065 dwp_files = ":empty",
Ilya Biryukov12471a72017-12-20 05:46:44 -080066 linker_files = ":compiler_deps",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000067 objcopy_files = ":empty",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000068 strip_files = ":empty",
Keith Smileyf08819b2020-11-12 03:13:54 -080069 supports_param_files = 1,
hlopko8b9f7462020-05-26 05:39:52 -070070 module_map = %{modulemap},
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000071)
72
rosica71bc38f2019-02-04 02:39:30 -080073cc_toolchain_config(
74 name = "%{cc_toolchain_identifier}",
75 cpu = "%{target_cpu}",
76 compiler = "%{compiler}",
rosica96500b72019-05-21 03:25:53 -070077 toolchain_identifier = "%{cc_toolchain_identifier}",
78 host_system_name = "%{host_system_name}",
79 target_system_name = "%{target_system_name}",
80 target_libc = "%{target_libc}",
81 abi_version = "%{abi_version}",
82 abi_libc_version = "%{abi_libc_version}",
83 cxx_builtin_include_directories = [%{cxx_builtin_include_directories}],
84 tool_paths = {%{tool_paths}},
85 compile_flags = [%{compile_flags}],
86 opt_compile_flags = [%{opt_compile_flags}],
87 dbg_compile_flags = [%{dbg_compile_flags}],
88 cxx_flags = [%{cxx_flags}],
89 link_flags = [%{link_flags}],
Marcel Hlopkoab9c1f52019-06-19 00:45:58 -070090 link_libs = [%{link_libs}],
rosica96500b72019-05-21 03:25:53 -070091 opt_link_flags = [%{opt_link_flags}],
92 unfiltered_compile_flags = [%{unfiltered_compile_flags}],
93 coverage_compile_flags = [%{coverage_compile_flags}],
94 coverage_link_flags = [%{coverage_link_flags}],
95 supports_start_end_lib = %{supports_start_end_lib},
rosica71bc38f2019-02-04 02:39:30 -080096)
97
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +000098# Android tooling requires a default toolchain for the armeabi-v7a cpu.
99cc_toolchain(
100 name = "cc-compiler-armeabi-v7a",
hlopkoc3fb1db2018-10-09 20:40:58 -0700101 toolchain_identifier = "stub_armeabi-v7a",
rosica71bc38f2019-02-04 02:39:30 -0800102 toolchain_config = ":stub_armeabi-v7a",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +0000103 all_files = ":empty",
Googler28953cb2018-12-05 10:46:00 -0800104 ar_files = ":empty",
105 as_files = ":empty",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +0000106 compiler_files = ":empty",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +0000107 dwp_files = ":empty",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +0000108 linker_files = ":empty",
109 objcopy_files = ":empty",
Damien Martin-Guillerez8fa5ae62016-03-02 16:24:13 +0000110 strip_files = ":empty",
111 supports_param_files = 1,
112)
Cal Peyserf026e142016-12-19 18:16:26 +0000113
rosicabeaba922019-05-20 02:36:26 -0700114armeabi_cc_toolchain_config(name = "stub_armeabi-v7a")