blob: bac0c0bdf88bce9acbc2bf0afb71fc04f2680184 [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",
Philipp Schraderf1bbf342022-02-05 14:30:15 -080010 "arm64": "@llvm_toolchain//:cc-clang-aarch64-linux",
Austin Schuhc4788d12021-01-23 17:23:37 -080011 "roborio": ":cc-compiler-roborio",
12 "cortex-m4f": ":cc-compiler-cortex-m4f",
Austin Schuh0a96ea32022-01-01 22:29:30 -080013 "rp2040": ":cc-compiler-rp2040",
Austin Schuhc4788d12021-01-23 17:23:37 -080014 },
15 visibility = ["//visibility:public"],
16)
17
Philipp Schraderdada1072020-11-24 11:34:46 -080018[
19 cc_toolchain_config(
20 name = "{}_toolchain_config".format(cpu),
21 cpu = cpu,
22 )
23 for cpu in [
24 "armeabi-v7a",
Philipp Schraderdada1072020-11-24 11:34:46 -080025 "cortex-m4f",
26 "cortex-m4f-k22",
Austin Schuh0a96ea32022-01-01 22:29:30 -080027 "rp2040",
Philipp Schraderdada1072020-11-24 11:34:46 -080028 "roborio",
29 ]
Austin Schuhda9d0602019-09-15 17:29:38 -070030]
31
Brian Silverman12b3fc52015-10-11 19:38:33 -040032cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080033 name = "empty_main",
34 srcs = ["empty_main.c"],
Philipp Schraderdada1072020-11-24 11:34:46 -080035 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman63889f92015-11-27 01:33:56 -050036)
37
38cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080039 name = "malloc",
40 deps = select({
41 "//tools:has_asan": [],
42 "//tools:has_tsan": [],
43 "//tools:cpu_cortex_m4f": [],
Austin Schuh0a96ea32022-01-01 22:29:30 -080044 "//tools:cpu_cortex_m0plus": [],
Philipp Schraderdada1072020-11-24 11:34:46 -080045 # TODO(phil): Support this properly.
46 #"//tools:cpu_cortex_m4f_k22": [],
Philipp Schrader9b1790e2018-03-10 20:21:30 -080047 "//conditions:default": ["//third_party/gperftools:tcmalloc"],
48 }),
Brian Silverman12b3fc52015-10-11 19:38:33 -040049)
50
51cc_library(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080052 name = "stl",
Philipp Schraderdada1072020-11-24 11:34:46 -080053 target_compatible_with = ["@platforms//os:linux"],
Brian Silverman12b3fc52015-10-11 19:38:33 -040054)
55
56filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080057 name = "empty",
58 srcs = [],
Brian Silverman12b3fc52015-10-11 19:38:33 -040059)
60
Brian Silvermanb466eef2015-11-28 20:33:44 -050061# Compiler inputs given by --copt etc in //tools:bazel.rc.
62filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080063 name = "flags_compiler_inputs",
64 srcs = select({
65 "//tools:has_asan": [
66 "asan-blacklist",
67 ],
68 "//tools:has_ubsan": [
69 "ubsan-blacklist",
70 ],
71 "//conditions:default": [],
72 }),
73)
74
75filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080076 name = "roborio-compiler-files",
77 srcs = [
78 ":flags_compiler_inputs",
79 "//tools/cpp/arm-frc-linux-gnueabi:as",
Ravago Jones16809802021-11-18 20:40:03 -080080 "//tools/cpp/arm-frc-linux-gnueabi:libs",
Philipp Schrader9b1790e2018-03-10 20:21:30 -080081 "//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers",
82 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
83 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070084)
85
86filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080087 name = "roborio_linker_files",
88 srcs = [
89 "//tools/cpp/arm-frc-linux-gnueabi:ar",
90 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
91 "//tools/cpp/arm-frc-linux-gnueabi:ld",
92 "//tools/cpp/arm-frc-linux-gnueabi:libs",
93 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
94 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070095)
Philipp Schrader9b1790e2018-03-10 20:21:30 -080096
Austin Schuh55139fe2015-10-14 23:55:24 -070097filegroup(
Austin Schuhda9d0602019-09-15 17:29:38 -070098 name = "roborio_ar_files",
99 srcs = [
100 "//tools/cpp/arm-frc-linux-gnueabi:ar",
101 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
102 ],
103)
104
105filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800106 name = "roborio_compiler_files",
107 srcs = [
108 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
109 "//tools/cpp/arm-frc-linux-gnueabi:ld",
110 "@arm_frc_linux_gnueabi_repo//:compiler_components",
111 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
112 ],
Austin Schuh55139fe2015-10-14 23:55:24 -0700113)
114
Brian Silverman50b9ac02018-08-12 13:24:10 -0700115filegroup(
116 name = "roborio_strip_files",
117 srcs = [
118 "//tools/cpp/arm-frc-linux-gnueabi:strip",
119 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
120 ],
121)
122
Austin Schuh23da18b2015-10-11 20:52:49 -0700123cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800124 name = "cc-compiler-roborio",
125 all_files = ":roborio-compiler-files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800126 ar_files = ":roborio_ar_files",
127 as_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800128 compiler_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800129 dwp_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800130 linker_files = ":roborio_linker_files",
131 objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
Brian Silverman50b9ac02018-08-12 13:24:10 -0700132 strip_files = ":roborio_strip_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800133 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700134 toolchain_config = ":roborio_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800135 toolchain_identifier = "roborio_linux",
136)
137
138toolchain(
139 name = "cc-toolchain-roborio",
140 exec_compatible_with = [
141 "@platforms//os:linux",
142 "@platforms//cpu:x86_64",
143 ],
144 target_compatible_with = [
145 "@platforms//os:linux",
146 "//tools/platforms/hardware:roborio",
147 ],
148 toolchain = ":cc-compiler-roborio",
149 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Austin Schuh23da18b2015-10-11 20:52:49 -0700150)
Brian Silverman0d57fc82016-01-24 21:02:53 -0500151
152filegroup(
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700153 name = "gcc_arm_none_eabi_none_files",
154 srcs = [
155 "//tools/cpp/gcc_arm_none_eabi:tool-wrappers",
156 "@gcc_arm_none_eabi//:compiler_pieces",
157 ],
158)
159
160filegroup(
161 name = "gcc_arm_none_eabi_compiler_files",
162 srcs = [
163 "//tools/cpp/gcc_arm_none_eabi:as",
164 "//tools/cpp/gcc_arm_none_eabi:gcc",
165 "//tools/cpp/gcc_arm_none_eabi:ld",
Austin Schuhda9d0602019-09-15 17:29:38 -0700166 "@gcc_arm_none_eabi//:compiler_pieces",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700167 ],
168)
169
170filegroup(
171 name = "gcc_arm_none_eabi_linker_files",
172 srcs = [
173 "//motors/core:linkerscripts",
174 "//tools/cpp/gcc_arm_none_eabi:ar",
175 "//tools/cpp/gcc_arm_none_eabi:gcc",
176 "//tools/cpp/gcc_arm_none_eabi:ld",
177 "@gcc_arm_none_eabi//:compiler_pieces",
178 ],
179)
180
Austin Schuhda9d0602019-09-15 17:29:38 -0700181filegroup(
182 name = "gcc_arm_none_eabi_ar_files",
183 srcs = [
184 "//tools/cpp/gcc_arm_none_eabi:ar",
185 "@gcc_arm_none_eabi//:compiler_pieces",
186 ],
187)
188
Brian Silverman8b638692017-06-26 23:10:26 -0700189cc_toolchain(
Austin Schuh0a96ea32022-01-01 22:29:30 -0800190 name = "cc-compiler-rp2040",
191 all_files = ":gcc_arm_none_eabi_none_files",
192 ar_files = ":gcc_arm_none_eabi_ar_files",
193 compiler_files = ":gcc_arm_none_eabi_compiler_files",
194 dwp_files = ":empty",
195 linker_files = ":gcc_arm_none_eabi_linker_files",
196 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
197 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
198 supports_param_files = 1,
199 toolchain_config = ":rp2040_toolchain_config",
200 toolchain_identifier = "rp2040",
201)
202
203toolchain(
204 name = "cc-toolchain-rp2040",
205 exec_compatible_with = [
206 "@platforms//os:linux",
207 "@platforms//cpu:x86_64",
208 ],
209 target_compatible_with = [
210 "@platforms//os:none",
211 "//tools/platforms/hardware:cortex_m0plus",
212 ],
213 toolchain = ":cc-compiler-rp2040",
214 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
215)
216
217cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800218 name = "cc-compiler-cortex-m4f",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700219 all_files = ":gcc_arm_none_eabi_none_files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800220 ar_files = ":gcc_arm_none_eabi_ar_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700221 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800222 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700223 linker_files = ":gcc_arm_none_eabi_linker_files",
224 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700225 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
226 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700227 toolchain_config = ":cortex-m4f_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800228 toolchain_identifier = "cortex-m4f",
229)
230
231toolchain(
232 name = "cc-toolchain-cortex-m4f",
233 exec_compatible_with = [
234 "@platforms//os:linux",
235 "@platforms//cpu:x86_64",
236 ],
237 target_compatible_with = [
238 "@platforms//os:none",
239 "//tools/platforms/hardware:cortex_m4f",
240 ],
241 toolchain = ":cc-compiler-cortex-m4f",
242 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700243)
244
245cc_toolchain(
246 name = "cc-compiler-cortex-m4f-k22",
247 all_files = ":gcc_arm_none_eabi_none_files",
248 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700249 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700250 linker_files = ":gcc_arm_none_eabi_linker_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800251 objcopy_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800252 strip_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700253 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700254 toolchain_config = ":cortex-m4f-k22_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800255 toolchain_identifier = "cortex-m4f-k22",
256)
257
258toolchain(
259 name = "cc-toolchain-cortex-m4f-k22",
260 exec_compatible_with = [
261 "@platforms//os:linux",
262 "@platforms//cpu:x86_64",
263 ],
264 target_compatible_with = [
265 "@platforms//os:none",
266 "//tools/platforms/hardware:cortex_m4f",
267 ],
268 toolchain = ":cc-compiler-cortex-m4f-k22",
269 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman7b8899e2018-06-30 19:19:24 -0700270)