blob: 6ff661a245d4c762c06b0692fc83da1519d61359 [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",
Ravago Jones16809802021-11-18 20:40:03 -080079 "//tools/cpp/arm-frc-linux-gnueabi:libs",
Philipp Schrader9b1790e2018-03-10 20:21:30 -080080 "//tools/cpp/arm-frc-linux-gnueabi:tool-wrappers",
81 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
82 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070083)
84
85filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -080086 name = "roborio_linker_files",
87 srcs = [
88 "//tools/cpp/arm-frc-linux-gnueabi:ar",
89 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
90 "//tools/cpp/arm-frc-linux-gnueabi:ld",
91 "//tools/cpp/arm-frc-linux-gnueabi:libs",
92 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
93 ],
Austin Schuh55139fe2015-10-14 23:55:24 -070094)
Philipp Schrader9b1790e2018-03-10 20:21:30 -080095
Austin Schuh55139fe2015-10-14 23:55:24 -070096filegroup(
Austin Schuhda9d0602019-09-15 17:29:38 -070097 name = "roborio_ar_files",
98 srcs = [
99 "//tools/cpp/arm-frc-linux-gnueabi:ar",
100 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
101 ],
102)
103
104filegroup(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800105 name = "roborio_compiler_files",
106 srcs = [
107 "//tools/cpp/arm-frc-linux-gnueabi:gcc",
108 "//tools/cpp/arm-frc-linux-gnueabi:ld",
109 "@arm_frc_linux_gnueabi_repo//:compiler_components",
110 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
111 ],
Austin Schuh55139fe2015-10-14 23:55:24 -0700112)
113
Brian Silverman50b9ac02018-08-12 13:24:10 -0700114filegroup(
115 name = "roborio_strip_files",
116 srcs = [
117 "//tools/cpp/arm-frc-linux-gnueabi:strip",
118 "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
119 ],
120)
121
Austin Schuh23da18b2015-10-11 20:52:49 -0700122cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800123 name = "cc-compiler-roborio",
124 all_files = ":roborio-compiler-files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800125 ar_files = ":roborio_ar_files",
126 as_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800127 compiler_files = ":roborio_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800128 dwp_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800129 linker_files = ":roborio_linker_files",
130 objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
Brian Silverman50b9ac02018-08-12 13:24:10 -0700131 strip_files = ":roborio_strip_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800132 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700133 toolchain_config = ":roborio_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800134 toolchain_identifier = "roborio_linux",
135)
136
137toolchain(
138 name = "cc-toolchain-roborio",
139 exec_compatible_with = [
140 "@platforms//os:linux",
141 "@platforms//cpu:x86_64",
142 ],
143 target_compatible_with = [
144 "@platforms//os:linux",
145 "//tools/platforms/hardware:roborio",
146 ],
147 toolchain = ":cc-compiler-roborio",
148 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Austin Schuh23da18b2015-10-11 20:52:49 -0700149)
Brian Silverman0d57fc82016-01-24 21:02:53 -0500150
151filegroup(
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700152 name = "gcc_arm_none_eabi_none_files",
153 srcs = [
154 "//tools/cpp/gcc_arm_none_eabi:tool-wrappers",
155 "@gcc_arm_none_eabi//:compiler_pieces",
156 ],
157)
158
159filegroup(
160 name = "gcc_arm_none_eabi_compiler_files",
161 srcs = [
162 "//tools/cpp/gcc_arm_none_eabi:as",
163 "//tools/cpp/gcc_arm_none_eabi:gcc",
164 "//tools/cpp/gcc_arm_none_eabi:ld",
Austin Schuhda9d0602019-09-15 17:29:38 -0700165 "@gcc_arm_none_eabi//:compiler_pieces",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700166 ],
167)
168
169filegroup(
170 name = "gcc_arm_none_eabi_linker_files",
171 srcs = [
172 "//motors/core:linkerscripts",
173 "//tools/cpp/gcc_arm_none_eabi:ar",
174 "//tools/cpp/gcc_arm_none_eabi:gcc",
175 "//tools/cpp/gcc_arm_none_eabi:ld",
176 "@gcc_arm_none_eabi//:compiler_pieces",
177 ],
178)
179
Austin Schuhda9d0602019-09-15 17:29:38 -0700180filegroup(
181 name = "gcc_arm_none_eabi_ar_files",
182 srcs = [
183 "//tools/cpp/gcc_arm_none_eabi:ar",
184 "@gcc_arm_none_eabi//:compiler_pieces",
185 ],
186)
187
Brian Silverman8b638692017-06-26 23:10:26 -0700188cc_toolchain(
Austin Schuh0a96ea32022-01-01 22:29:30 -0800189 name = "cc-compiler-rp2040",
190 all_files = ":gcc_arm_none_eabi_none_files",
191 ar_files = ":gcc_arm_none_eabi_ar_files",
192 compiler_files = ":gcc_arm_none_eabi_compiler_files",
193 dwp_files = ":empty",
194 linker_files = ":gcc_arm_none_eabi_linker_files",
195 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
196 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
197 supports_param_files = 1,
198 toolchain_config = ":rp2040_toolchain_config",
199 toolchain_identifier = "rp2040",
200)
201
202toolchain(
203 name = "cc-toolchain-rp2040",
204 exec_compatible_with = [
205 "@platforms//os:linux",
206 "@platforms//cpu:x86_64",
207 ],
208 target_compatible_with = [
209 "@platforms//os:none",
210 "//tools/platforms/hardware:cortex_m0plus",
211 ],
212 toolchain = ":cc-compiler-rp2040",
213 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
214)
215
216cc_toolchain(
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800217 name = "cc-compiler-cortex-m4f",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700218 all_files = ":gcc_arm_none_eabi_none_files",
Philipp Schraderdada1072020-11-24 11:34:46 -0800219 ar_files = ":gcc_arm_none_eabi_ar_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700220 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800221 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700222 linker_files = ":gcc_arm_none_eabi_linker_files",
223 objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700224 strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
225 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700226 toolchain_config = ":cortex-m4f_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800227 toolchain_identifier = "cortex-m4f",
228)
229
230toolchain(
231 name = "cc-toolchain-cortex-m4f",
232 exec_compatible_with = [
233 "@platforms//os:linux",
234 "@platforms//cpu:x86_64",
235 ],
236 target_compatible_with = [
237 "@platforms//os:none",
238 "//tools/platforms/hardware:cortex_m4f",
239 ],
240 toolchain = ":cc-compiler-cortex-m4f",
241 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700242)
243
244cc_toolchain(
245 name = "cc-compiler-cortex-m4f-k22",
246 all_files = ":gcc_arm_none_eabi_none_files",
247 compiler_files = ":gcc_arm_none_eabi_compiler_files",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700248 dwp_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700249 linker_files = ":gcc_arm_none_eabi_linker_files",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800250 objcopy_files = ":empty",
Philipp Schrader9b1790e2018-03-10 20:21:30 -0800251 strip_files = ":empty",
Brian Silverman6c8b88b2018-09-03 18:17:02 -0700252 supports_param_files = 1,
Austin Schuhda9d0602019-09-15 17:29:38 -0700253 toolchain_config = ":cortex-m4f-k22_toolchain_config",
Philipp Schraderdada1072020-11-24 11:34:46 -0800254 toolchain_identifier = "cortex-m4f-k22",
255)
256
257toolchain(
258 name = "cc-toolchain-cortex-m4f-k22",
259 exec_compatible_with = [
260 "@platforms//os:linux",
261 "@platforms//cpu:x86_64",
262 ],
263 target_compatible_with = [
264 "@platforms//os:none",
265 "//tools/platforms/hardware:cortex_m4f",
266 ],
267 toolchain = ":cc-compiler-cortex-m4f-k22",
268 toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Brian Silverman7b8899e2018-06-30 19:19:24 -0700269)