blob: 5c36559ab3a3cc81fc332d0c68be0c108f3ddc1e [file] [log] [blame]
Austin Schuhda9d0602019-09-15 17:29:38 -07001load(":toolchain_config.bzl", "cc_toolchain_config")
Philipp Schrader33b5e802022-02-06 22:17:41 -08002load(":toolchain_make_variables.bzl", "cc_toolchain_make_variables")
Austin Schuhda9d0602019-09-15 17:29:38 -07003
Philipp Schrader9b1790e2018-03-10 20:21:30 -08004package(default_visibility = ["//visibility:public"])
Brian Silverman12b3fc52015-10-11 19:38:33 -04005
Philipp Schrader33b5e802022-02-06 22:17:41 -08006# Use this instead of @bazel_tools//tools/cpp:current_cc_toolchain.
7# This one supports platforms.
8cc_toolchain_make_variables(name = "cc_toolchain_make_variables")
Austin Schuhc4788d12021-01-23 17:23:37 -08009
Philipp Schraderdada1072020-11-24 11:34:46 -080010[
11 cc_toolchain_config(
12 name = "{}_toolchain_config".format(cpu),
13 cpu = cpu,
14 )
15 for cpu in [
Philipp Schraderdada1072020-11-24 11:34:46 -080016 "cortex-m4f",
17 "cortex-m4f-k22",
Austin Schuh0a96ea32022-01-01 22:29:30 -080018 "rp2040",
Philipp Schraderdada1072020-11-24 11:34:46 -080019 "roborio",
20 ]
Austin Schuhda9d0602019-09-15 17:29:38 -070021]
22
Brian Silverman12b3fc52015-10-11 19:38:33 -040023cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080024 name = "empty_main",
25 srcs = ["empty_main.c"],
Philipp Schraderdada1072020-11-24 11:34:46 -080026 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman63889f92015-11-27 01:33:56 -050027)
28
29cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080030 name = "malloc",
31 deps = select({
32 "//tools:has_asan": [],
33 "//tools:has_tsan": [],
34 "//tools:cpu_cortex_m4f": [],
Austin Schuh0a96ea32022-01-01 22:29:30 -080035 "//tools:cpu_cortex_m0plus": [],
Philipp Schraderdada1072020-11-24 11:34:46 -080036 # TODO(phil): Support this properly.
37 #"//tools:cpu_cortex_m4f_k22": [],
Philipp Schrader9b1790e2018-03-10 20:21:30 -080038 "//conditions:default": ["//third_party/gperftools:tcmalloc"],
39 }),
Brian Silverman12b3fc52015-10-11 19:38:33 -040040)
41
42cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080043 name = "stl",
Philipp Schraderdada1072020-11-24 11:34:46 -080044 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman12b3fc52015-10-11 19:38:33 -040045)
46
47filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080048 name = "empty",
49 srcs = [],
Brian Silverman12b3fc52015-10-11 19:38:33 -040050)
51
Brian Silvermanb466eef2015-11-28 20:33:44 -050052# Compiler inputs given by --copt etc in //tools:bazel.rc.
53filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080054 name = "flags_compiler_inputs",
55 srcs = select({
56 "//tools:has_asan": [
57 "asan-blacklist",
58 ],
59 "//tools:has_ubsan": [
60 "ubsan-blacklist",
61 ],
62 "//conditions:default": [],
63 }),
64)
65
66filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080067 name = "roborio-compiler-files",
68 srcs = [
69 ":flags_compiler_inputs",
70 "//tools/cpp/arm-frc-linux-gnueabi:as",
Ravago Jones16809802021-11-18 20:40:03 -080071 "//tools/cpp/arm-frc-linux-gnueabi:libs",
Philipp Schrader9b1790e2018-03-10 20:21:30 -080072 "//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers",
73 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
74 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070075)
76
77filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080078 name = "roborio_linker_files",
79 srcs = [
80 "//tools/cpp/arm-frc-linux-gnueabi:ar",
81 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
82 "//tools/cpp/arm-frc-linux-gnueabi:ld",
83 "//tools/cpp/arm-frc-linux-gnueabi:libs",
84 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
85 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070086)
Philipp Schrader9b1790e2018-03-10 20:21:30 -080087
Austin Schuh55139fe2015-10-14 23:55:24 -070088filegroup(
Austin Schuhda9d0602019-09-15 17:29:38 -070089 name = "roborio_ar_files",
90 srcs = [
91 "//tools/cpp/arm-frc-linux-gnueabi:ar",
92 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
93 ],
94)
95
96filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080097 name = "roborio_compiler_files",
98 srcs = [
99 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
100 "//tools/cpp/arm-frc-linux-gnueabi:ld",
101 "@arm_frc_linux_gnueabi_repo//:compiler_components",
102 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
103 ],
Austin Schuh55139fe2015-10-14 23:55:24 -0700104)
105
Brian Silverman50b9ac02018-08-12 13:24:10 -0700106filegroup(
107 name = "roborio_strip_files",
108 srcs = [
109 "//tools/cpp/arm-frc-linux-gnueabi:strip",
110 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
111 ],
112)
113
Austin Schuh23da18b2015-10-11 20:52:49 -0700114cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800115 name = "cc-compiler-roborio",
116 all_files = ":roborio-compiler-files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800117 ar_files = ":roborio_ar_files",
118 as_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800119 compiler_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800120 dwp_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800121 linker_files = ":roborio_linker_files",
122 objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
Brian Silverman50b9ac02018-08-12 13:24:10 -0700123 strip_files = ":roborio_strip_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800124 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700125 toolchain_config = ":roborio_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800126 toolchain_identifier = "roborio_linux",
127)
128
129toolchain(
130 name = "cc-toolchain-roborio",
131 exec_compatible_with = [
132 "@platforms//os:linux",
133 "@platforms//cpu:x86_64",
134 ],
135 target_compatible_with = [
136 "@platforms//os:linux",
137 "//tools/platforms/hardware:roborio",
138 ],
139 toolchain = ":cc-compiler-roborio",
140 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Austin Schuh23da18b2015-10-11 20:52:49 -0700141)
Brian Silverman0d57fc82016-01-24 21:02:53 -0500142
143filegroup(
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700144 name = "gcc_arm_none_eabi_none_files",
145 srcs = [
146 "//tools/cpp/gcc_arm_none_eabi:tool-wrappers",
147 "@gcc_arm_none_eabi//:compiler_pieces",
148 ],
149)
150
151filegroup(
152 name = "gcc_arm_none_eabi_compiler_files",
153 srcs = [
154 "//tools/cpp/gcc_arm_none_eabi:as",
155 "//tools/cpp/gcc_arm_none_eabi:gcc",
156 "//tools/cpp/gcc_arm_none_eabi:ld",
Austin Schuhda9d0602019-09-15 17:29:38 -0700157 "@gcc_arm_none_eabi//:compiler_pieces",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700158 ],
159)
160
161filegroup(
162 name = "gcc_arm_none_eabi_linker_files",
163 srcs = [
164 "//motors/core:linkerscripts",
165 "//tools/cpp/gcc_arm_none_eabi:ar",
166 "//tools/cpp/gcc_arm_none_eabi:gcc",
167 "//tools/cpp/gcc_arm_none_eabi:ld",
168 "@gcc_arm_none_eabi//:compiler_pieces",
169 ],
170)
171
Austin Schuhda9d0602019-09-15 17:29:38 -0700172filegroup(
173 name = "gcc_arm_none_eabi_ar_files",
174 srcs = [
175 "//tools/cpp/gcc_arm_none_eabi:ar",
176 "@gcc_arm_none_eabi//:compiler_pieces",
177 ],
178)
179
Brian Silverman8b638692017-06-26 23:10:26 -0700180cc_toolchain(
Austin Schuh0a96ea32022-01-01 22:29:30 -0800181 name = "cc-compiler-rp2040",
182 all_files = ":gcc_arm_none_eabi_none_files",
183 ar_files = ":gcc_arm_none_eabi_ar_files",
184 compiler_files = ":gcc_arm_none_eabi_compiler_files",
185 dwp_files = ":empty",
186 linker_files = ":gcc_arm_none_eabi_linker_files",
187 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
188 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
189 supports_param_files = 1,
190 toolchain_config = ":rp2040_toolchain_config",
191 toolchain_identifier = "rp2040",
192)
193
194toolchain(
195 name = "cc-toolchain-rp2040",
196 exec_compatible_with = [
197 "@platforms//os:linux",
198 "@platforms//cpu:x86_64",
199 ],
200 target_compatible_with = [
201 "@platforms//os:none",
202 "//tools/platforms/hardware:cortex_m0plus",
203 ],
204 toolchain = ":cc-compiler-rp2040",
205 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
206)
207
208cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800209 name = "cc-compiler-cortex-m4f",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700210 all_files = ":gcc_arm_none_eabi_none_files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800211 ar_files = ":gcc_arm_none_eabi_ar_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700212 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800213 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700214 linker_files = ":gcc_arm_none_eabi_linker_files",
215 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700216 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
217 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700218 toolchain_config = ":cortex-m4f_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800219 toolchain_identifier = "cortex-m4f",
220)
221
222toolchain(
223 name = "cc-toolchain-cortex-m4f",
224 exec_compatible_with = [
225 "@platforms//os:linux",
226 "@platforms//cpu:x86_64",
227 ],
228 target_compatible_with = [
229 "@platforms//os:none",
230 "//tools/platforms/hardware:cortex_m4f",
231 ],
232 toolchain = ":cc-compiler-cortex-m4f",
233 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700234)
235
236cc_toolchain(
237 name = "cc-compiler-cortex-m4f-k22",
238 all_files = ":gcc_arm_none_eabi_none_files",
239 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700240 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700241 linker_files = ":gcc_arm_none_eabi_linker_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800242 objcopy_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800243 strip_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700244 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700245 toolchain_config = ":cortex-m4f-k22_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800246 toolchain_identifier = "cortex-m4f-k22",
247)
248
249toolchain(
250 name = "cc-toolchain-cortex-m4f-k22",
251 exec_compatible_with = [
252 "@platforms//os:linux",
253 "@platforms//cpu:x86_64",
254 ],
255 target_compatible_with = [
256 "@platforms//os:none",
257 "//tools/platforms/hardware:cortex_m4f",
258 ],
259 toolchain = ":cc-compiler-cortex-m4f-k22",
260 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman7b8899e2018-06-30 19:19:24 -0700261)