blob: 17f218e4bea659d583e8dfb7c070f32debad8c77 [file] [log] [blame]
Austin Schuhda9d0602019-09-15 17:29:38 -07001load(":toolchain_config.bzl", "cc_toolchain_config")
2
Philipp Schrader9b1790e2018-03-10 20:21:30 -08003package(default_visibility = ["//visibility:public"])
Brian Silverman12b3fc52015-10-11 19:38:33 -04004
Austin Schuhc4788d12021-01-23 17:23:37 -08005cc_toolchain_suite(
6 name = "toolchain",
7 toolchains = {
Brian Silverman4c7235a2021-11-17 19:04:37 -08008 "k8": "@llvm_toolchain//:cc-clang-x86_64-linux",
9 "armv7": "@llvm_toolchain//:cc-clang-armv7-linux",
Austin Schuhc4788d12021-01-23 17:23:37 -080010 "roborio": ":cc-compiler-roborio",
11 "cortex-m4f": ":cc-compiler-cortex-m4f",
Austin Schuh0a96ea32022-01-01 22:29:30 -080012 "rp2040": ":cc-compiler-rp2040",
Austin Schuhc4788d12021-01-23 17:23:37 -080013 },
14 visibility = ["//visibility:public"],
15)
16
Philipp Schraderdada1072020-11-24 11:34:46 -080017[
18 cc_toolchain_config(
19 name = "{}_toolchain_config".format(cpu),
20 cpu = cpu,
21 )
22 for cpu in [
23 "armeabi-v7a",
Philipp Schraderdada1072020-11-24 11:34:46 -080024 "cortex-m4f",
25 "cortex-m4f-k22",
Austin Schuh0a96ea32022-01-01 22:29:30 -080026 "rp2040",
Philipp Schraderdada1072020-11-24 11:34:46 -080027 "roborio",
28 ]
Austin Schuhda9d0602019-09-15 17:29:38 -070029]
30
Brian Silverman12b3fc52015-10-11 19:38:33 -040031cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080032 name = "empty_main",
33 srcs = ["empty_main.c"],
Philipp Schraderdada1072020-11-24 11:34:46 -080034 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman63889f92015-11-27 01:33:56 -050035)
36
37cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080038 name = "malloc",
39 deps = select({
40 "//tools:has_asan": [],
41 "//tools:has_tsan": [],
42 "//tools:cpu_cortex_m4f": [],
Austin Schuh0a96ea32022-01-01 22:29:30 -080043 "//tools:cpu_cortex_m0plus": [],
Philipp Schraderdada1072020-11-24 11:34:46 -080044 # TODO(phil): Support this properly.
45 #"//tools:cpu_cortex_m4f_k22": [],
Philipp Schrader9b1790e2018-03-10 20:21:30 -080046 "//conditions:default": ["//third_party/gperftools:tcmalloc"],
47 }),
Brian Silverman12b3fc52015-10-11 19:38:33 -040048)
49
50cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080051 name = "stl",
Philipp Schraderdada1072020-11-24 11:34:46 -080052 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman12b3fc52015-10-11 19:38:33 -040053)
54
55filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080056 name = "empty",
57 srcs = [],
Brian Silverman12b3fc52015-10-11 19:38:33 -040058)
59
Brian Silvermanb466eef2015-11-28 20:33:44 -050060# Compiler inputs given by --copt etc in //tools:bazel.rc.
61filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080062 name = "flags_compiler_inputs",
63 srcs = select({
64 "//tools:has_asan": [
65 "asan-blacklist",
66 ],
67 "//tools:has_ubsan": [
68 "ubsan-blacklist",
69 ],
70 "//conditions:default": [],
71 }),
72)
73
74filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080075 name = "roborio-compiler-files",
76 srcs = [
77 ":flags_compiler_inputs",
78 "//tools/cpp/arm-frc-linux-gnueabi:as",
79 "//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers",
80 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
81 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070082)
83
84filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080085 name = "roborio_linker_files",
86 srcs = [
87 "//tools/cpp/arm-frc-linux-gnueabi:ar",
88 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
89 "//tools/cpp/arm-frc-linux-gnueabi:ld",
90 "//tools/cpp/arm-frc-linux-gnueabi:libs",
91 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
92 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070093)
Philipp Schrader9b1790e2018-03-10 20:21:30 -080094
Austin Schuh55139fe2015-10-14 23:55:24 -070095filegroup(
Austin Schuhda9d0602019-09-15 17:29:38 -070096 name = "roborio_ar_files",
97 srcs = [
98 "//tools/cpp/arm-frc-linux-gnueabi:ar",
99 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
100 ],
101)
102
103filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800104 name = "roborio_compiler_files",
105 srcs = [
106 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
107 "//tools/cpp/arm-frc-linux-gnueabi:ld",
108 "@arm_frc_linux_gnueabi_repo//:compiler_components",
109 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
110 ],
Austin Schuh55139fe2015-10-14 23:55:24 -0700111)
112
Brian Silverman50b9ac02018-08-12 13:24:10 -0700113filegroup(
114 name = "roborio_strip_files",
115 srcs = [
116 "//tools/cpp/arm-frc-linux-gnueabi:strip",
117 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
118 ],
119)
120
Austin Schuh23da18b2015-10-11 20:52:49 -0700121cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800122 name = "cc-compiler-roborio",
123 all_files = ":roborio-compiler-files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800124 ar_files = ":roborio_ar_files",
125 as_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800126 compiler_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800127 dwp_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800128 linker_files = ":roborio_linker_files",
129 objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
Brian Silverman50b9ac02018-08-12 13:24:10 -0700130 strip_files = ":roborio_strip_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800131 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700132 toolchain_config = ":roborio_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800133 toolchain_identifier = "roborio_linux",
134)
135
136toolchain(
137 name = "cc-toolchain-roborio",
138 exec_compatible_with = [
139 "@platforms//os:linux",
140 "@platforms//cpu:x86_64",
141 ],
142 target_compatible_with = [
143 "@platforms//os:linux",
144 "//tools/platforms/hardware:roborio",
145 ],
146 toolchain = ":cc-compiler-roborio",
147 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Austin Schuh23da18b2015-10-11 20:52:49 -0700148)
Brian Silverman0d57fc82016-01-24 21:02:53 -0500149
150filegroup(
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700151 name = "gcc_arm_none_eabi_none_files",
152 srcs = [
153 "//tools/cpp/gcc_arm_none_eabi:tool-wrappers",
154 "@gcc_arm_none_eabi//:compiler_pieces",
155 ],
156)
157
158filegroup(
159 name = "gcc_arm_none_eabi_compiler_files",
160 srcs = [
161 "//tools/cpp/gcc_arm_none_eabi:as",
162 "//tools/cpp/gcc_arm_none_eabi:gcc",
163 "//tools/cpp/gcc_arm_none_eabi:ld",
Austin Schuhda9d0602019-09-15 17:29:38 -0700164 "@gcc_arm_none_eabi//:compiler_pieces",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700165 ],
166)
167
168filegroup(
169 name = "gcc_arm_none_eabi_linker_files",
170 srcs = [
171 "//motors/core:linkerscripts",
172 "//tools/cpp/gcc_arm_none_eabi:ar",
173 "//tools/cpp/gcc_arm_none_eabi:gcc",
174 "//tools/cpp/gcc_arm_none_eabi:ld",
175 "@gcc_arm_none_eabi//:compiler_pieces",
176 ],
177)
178
Austin Schuhda9d0602019-09-15 17:29:38 -0700179filegroup(
180 name = "gcc_arm_none_eabi_ar_files",
181 srcs = [
182 "//tools/cpp/gcc_arm_none_eabi:ar",
183 "@gcc_arm_none_eabi//:compiler_pieces",
184 ],
185)
186
Brian Silverman8b638692017-06-26 23:10:26 -0700187cc_toolchain(
Austin Schuh0a96ea32022-01-01 22:29:30 -0800188 name = "cc-compiler-rp2040",
189 all_files = ":gcc_arm_none_eabi_none_files",
190 ar_files = ":gcc_arm_none_eabi_ar_files",
191 compiler_files = ":gcc_arm_none_eabi_compiler_files",
192 dwp_files = ":empty",
193 linker_files = ":gcc_arm_none_eabi_linker_files",
194 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
195 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
196 supports_param_files = 1,
197 toolchain_config = ":rp2040_toolchain_config",
198 toolchain_identifier = "rp2040",
199)
200
201toolchain(
202 name = "cc-toolchain-rp2040",
203 exec_compatible_with = [
204 "@platforms//os:linux",
205 "@platforms//cpu:x86_64",
206 ],
207 target_compatible_with = [
208 "@platforms//os:none",
209 "//tools/platforms/hardware:cortex_m0plus",
210 ],
211 toolchain = ":cc-compiler-rp2040",
212 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
213)
214
215cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800216 name = "cc-compiler-cortex-m4f",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700217 all_files = ":gcc_arm_none_eabi_none_files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800218 ar_files = ":gcc_arm_none_eabi_ar_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700219 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800220 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700221 linker_files = ":gcc_arm_none_eabi_linker_files",
222 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700223 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
224 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700225 toolchain_config = ":cortex-m4f_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800226 toolchain_identifier = "cortex-m4f",
227)
228
229toolchain(
230 name = "cc-toolchain-cortex-m4f",
231 exec_compatible_with = [
232 "@platforms//os:linux",
233 "@platforms//cpu:x86_64",
234 ],
235 target_compatible_with = [
236 "@platforms//os:none",
237 "//tools/platforms/hardware:cortex_m4f",
238 ],
239 toolchain = ":cc-compiler-cortex-m4f",
240 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700241)
242
243cc_toolchain(
244 name = "cc-compiler-cortex-m4f-k22",
245 all_files = ":gcc_arm_none_eabi_none_files",
246 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700247 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700248 linker_files = ":gcc_arm_none_eabi_linker_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800249 objcopy_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800250 strip_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700251 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700252 toolchain_config = ":cortex-m4f-k22_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800253 toolchain_identifier = "cortex-m4f-k22",
254)
255
256toolchain(
257 name = "cc-toolchain-cortex-m4f-k22",
258 exec_compatible_with = [
259 "@platforms//os:linux",
260 "@platforms//cpu:x86_64",
261 ],
262 target_compatible_with = [
263 "@platforms//os:none",
264 "//tools/platforms/hardware:cortex_m4f",
265 ],
266 toolchain = ":cc-compiler-cortex-m4f-k22",
267 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman7b8899e2018-06-30 19:19:24 -0700268)