blob: 2619ff7c815983ab37d0235e7453115c914ed02e [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",
James Kuszmaul5a728562023-12-28 21:45:01 -080019 "cortex-m4f-imu",
Philipp Schraderdada1072020-11-24 11:34:46 -080020 "roborio",
21 ]
Austin Schuhda9d0602019-09-15 17:29:38 -070022]
23
Brian Silverman12b3fc52015-10-11 19:38:33 -040024cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080025 name = "empty_main",
26 srcs = ["empty_main.c"],
Philipp Schraderdada1072020-11-24 11:34:46 -080027 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman63889f92015-11-27 01:33:56 -050028)
29
30cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080031 name = "malloc",
32 deps = select({
33 "//tools:has_asan": [],
34 "//tools:has_tsan": [],
35 "//tools:cpu_cortex_m4f": [],
James Kuszmaul5a728562023-12-28 21:45:01 -080036 "//tools:cpu_cortex-m4f-imu": [],
Austin Schuh0a96ea32022-01-01 22:29:30 -080037 "//tools:cpu_cortex_m0plus": [],
Philipp Schraderdada1072020-11-24 11:34:46 -080038 # TODO(phil): Support this properly.
39 #"//tools:cpu_cortex_m4f_k22": [],
Austin Schuh99f7c6a2024-06-25 22:07:44 -070040 "//conditions:default": [],
41 # TODO(austin): Figure out how to make malloc hooks work with the new tcmalloc...
42 #"//conditions:default": ["@com_google_tcmalloc//tcmalloc"],
Philipp Schrader9b1790e2018-03-10 20:21:30 -080043 }),
Brian Silverman12b3fc52015-10-11 19:38:33 -040044)
45
46cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080047 name = "stl",
Philipp Schraderdada1072020-11-24 11:34:46 -080048 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman12b3fc52015-10-11 19:38:33 -040049)
50
51filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080052 name = "empty",
53 srcs = [],
Brian Silverman12b3fc52015-10-11 19:38:33 -040054)
55
Brian Silvermanb466eef2015-11-28 20:33:44 -050056# Compiler inputs given by --copt etc in //tools:bazel.rc.
57filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080058 name = "flags_compiler_inputs",
59 srcs = select({
60 "//tools:has_asan": [
61 "asan-blacklist",
62 ],
63 "//tools:has_ubsan": [
64 "ubsan-blacklist",
65 ],
66 "//conditions:default": [],
67 }),
68)
69
70filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080071 name = "roborio-compiler-files",
72 srcs = [
73 ":flags_compiler_inputs",
74 "//tools/cpp/arm-frc-linux-gnueabi:as",
Ravago Jones16809802021-11-18 20:40:03 -080075 "//tools/cpp/arm-frc-linux-gnueabi:libs",
Philipp Schrader9b1790e2018-03-10 20:21:30 -080076 "//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers",
77 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
78 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070079)
80
81filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080082 name = "roborio_linker_files",
83 srcs = [
84 "//tools/cpp/arm-frc-linux-gnueabi:ar",
85 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
86 "//tools/cpp/arm-frc-linux-gnueabi:ld",
87 "//tools/cpp/arm-frc-linux-gnueabi:libs",
88 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
89 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070090)
Philipp Schrader9b1790e2018-03-10 20:21:30 -080091
Austin Schuh55139fe2015-10-14 23:55:24 -070092filegroup(
Austin Schuhda9d0602019-09-15 17:29:38 -070093 name = "roborio_ar_files",
94 srcs = [
95 "//tools/cpp/arm-frc-linux-gnueabi:ar",
96 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
97 ],
98)
99
100filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800101 name = "roborio_compiler_files",
102 srcs = [
103 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
104 "//tools/cpp/arm-frc-linux-gnueabi:ld",
105 "@arm_frc_linux_gnueabi_repo//:compiler_components",
106 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
107 ],
Austin Schuh55139fe2015-10-14 23:55:24 -0700108)
109
Brian Silverman50b9ac02018-08-12 13:24:10 -0700110filegroup(
111 name = "roborio_strip_files",
112 srcs = [
113 "//tools/cpp/arm-frc-linux-gnueabi:strip",
114 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
115 ],
116)
117
Austin Schuh23da18b2015-10-11 20:52:49 -0700118cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800119 name = "cc-compiler-roborio",
120 all_files = ":roborio-compiler-files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800121 ar_files = ":roborio_ar_files",
122 as_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800123 compiler_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800124 dwp_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800125 linker_files = ":roborio_linker_files",
126 objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
Brian Silverman50b9ac02018-08-12 13:24:10 -0700127 strip_files = ":roborio_strip_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800128 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700129 toolchain_config = ":roborio_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800130 toolchain_identifier = "roborio_linux",
131)
132
133toolchain(
134 name = "cc-toolchain-roborio",
135 exec_compatible_with = [
136 "@platforms//os:linux",
137 "@platforms//cpu:x86_64",
138 ],
139 target_compatible_with = [
140 "@platforms//os:linux",
141 "//tools/platforms/hardware:roborio",
142 ],
143 toolchain = ":cc-compiler-roborio",
144 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Austin Schuh23da18b2015-10-11 20:52:49 -0700145)
Brian Silverman0d57fc82016-01-24 21:02:53 -0500146
147filegroup(
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700148 name = "gcc_arm_none_eabi_none_files",
149 srcs = [
150 "//tools/cpp/gcc_arm_none_eabi:tool-wrappers",
151 "@gcc_arm_none_eabi//:compiler_pieces",
152 ],
153)
154
155filegroup(
156 name = "gcc_arm_none_eabi_compiler_files",
157 srcs = [
158 "//tools/cpp/gcc_arm_none_eabi:as",
159 "//tools/cpp/gcc_arm_none_eabi:gcc",
160 "//tools/cpp/gcc_arm_none_eabi:ld",
Austin Schuhda9d0602019-09-15 17:29:38 -0700161 "@gcc_arm_none_eabi//:compiler_pieces",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700162 ],
163)
164
165filegroup(
166 name = "gcc_arm_none_eabi_linker_files",
167 srcs = [
James Kuszmaul5a728562023-12-28 21:45:01 -0800168 "//frc971/imu_fdcan/Dual_IMU:linker_scripts",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700169 "//motors/core:linkerscripts",
170 "//tools/cpp/gcc_arm_none_eabi:ar",
171 "//tools/cpp/gcc_arm_none_eabi:gcc",
172 "//tools/cpp/gcc_arm_none_eabi:ld",
173 "@gcc_arm_none_eabi//:compiler_pieces",
174 ],
175)
176
Austin Schuhda9d0602019-09-15 17:29:38 -0700177filegroup(
178 name = "gcc_arm_none_eabi_ar_files",
179 srcs = [
180 "//tools/cpp/gcc_arm_none_eabi:ar",
181 "@gcc_arm_none_eabi//:compiler_pieces",
182 ],
183)
184
Brian Silverman8b638692017-06-26 23:10:26 -0700185cc_toolchain(
Austin Schuh0a96ea32022-01-01 22:29:30 -0800186 name = "cc-compiler-rp2040",
187 all_files = ":gcc_arm_none_eabi_none_files",
188 ar_files = ":gcc_arm_none_eabi_ar_files",
189 compiler_files = ":gcc_arm_none_eabi_compiler_files",
190 dwp_files = ":empty",
191 linker_files = ":gcc_arm_none_eabi_linker_files",
192 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
193 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
194 supports_param_files = 1,
195 toolchain_config = ":rp2040_toolchain_config",
196 toolchain_identifier = "rp2040",
197)
198
199toolchain(
200 name = "cc-toolchain-rp2040",
201 exec_compatible_with = [
202 "@platforms//os:linux",
203 "@platforms//cpu:x86_64",
204 ],
205 target_compatible_with = [
206 "@platforms//os:none",
207 "//tools/platforms/hardware:cortex_m0plus",
208 ],
209 toolchain = ":cc-compiler-rp2040",
210 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
211)
212
213cc_toolchain(
James Kuszmaul5a728562023-12-28 21:45:01 -0800214 name = "cc-compiler-cortex-m4f-imu",
215 all_files = ":gcc_arm_none_eabi_none_files",
216 ar_files = ":gcc_arm_none_eabi_ar_files",
217 compiler_files = ":gcc_arm_none_eabi_compiler_files",
218 dwp_files = ":empty",
219 linker_files = ":gcc_arm_none_eabi_linker_files",
220 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
221 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
222 supports_param_files = 1,
223 toolchain_config = ":cortex-m4f-imu_toolchain_config",
224 toolchain_identifier = "cortex-m4f-imu",
225)
226
227toolchain(
228 name = "cc-toolchain-cortex-m4f-imu",
229 exec_compatible_with = [
230 "@platforms//os:linux",
231 "@platforms//cpu:x86_64",
232 ],
233 target_compatible_with = [
234 "@platforms//os:none",
235 "//tools/platforms/hardware:cortex-m4f-imu",
236 ],
237 toolchain = ":cc-compiler-cortex-m4f-imu",
238 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
239)
240
241cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800242 name = "cc-compiler-cortex-m4f",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700243 all_files = ":gcc_arm_none_eabi_none_files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800244 ar_files = ":gcc_arm_none_eabi_ar_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700245 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800246 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700247 linker_files = ":gcc_arm_none_eabi_linker_files",
248 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700249 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
250 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700251 toolchain_config = ":cortex-m4f_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800252 toolchain_identifier = "cortex-m4f",
253)
254
255toolchain(
256 name = "cc-toolchain-cortex-m4f",
257 exec_compatible_with = [
258 "@platforms//os:linux",
259 "@platforms//cpu:x86_64",
260 ],
261 target_compatible_with = [
262 "@platforms//os:none",
263 "//tools/platforms/hardware:cortex_m4f",
264 ],
265 toolchain = ":cc-compiler-cortex-m4f",
266 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700267)
268
269cc_toolchain(
270 name = "cc-compiler-cortex-m4f-k22",
271 all_files = ":gcc_arm_none_eabi_none_files",
272 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700273 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700274 linker_files = ":gcc_arm_none_eabi_linker_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800275 objcopy_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800276 strip_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700277 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700278 toolchain_config = ":cortex-m4f-k22_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800279 toolchain_identifier = "cortex-m4f-k22",
280)
281
282toolchain(
283 name = "cc-toolchain-cortex-m4f-k22",
284 exec_compatible_with = [
285 "@platforms//os:linux",
286 "@platforms//cpu:x86_64",
287 ],
288 target_compatible_with = [
289 "@platforms//os:none",
290 "//tools/platforms/hardware:cortex_m4f",
291 ],
292 toolchain = ":cc-compiler-cortex-m4f-k22",
293 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman7b8899e2018-06-30 19:19:24 -0700294)