Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1 | load( |
| 2 | "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 3 | "action_config", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 4 | "feature", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 5 | "flag_group", |
| 6 | "flag_set", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 7 | "tool", |
| 8 | "tool_path", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 9 | "with_feature_set", |
| 10 | ) |
| 11 | load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") |
| 12 | |
| 13 | def _impl(ctx): |
| 14 | if (ctx.attr.cpu == "armhf-debian"): |
| 15 | toolchain_identifier = "clang_linux_armhf" |
| 16 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 17 | toolchain_identifier = "cortex-m4f" |
| 18 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 19 | toolchain_identifier = "cortex-m4f-k22" |
| 20 | elif (ctx.attr.cpu == "k8"): |
| 21 | toolchain_identifier = "k8_linux" |
| 22 | elif (ctx.attr.cpu == "roborio"): |
| 23 | toolchain_identifier = "roborio_linux" |
| 24 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 25 | toolchain_identifier = "stub_armeabi-v7a" |
| 26 | else: |
| 27 | fail("Unreachable") |
| 28 | |
| 29 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 30 | host_system_name = "armeabi-v7a" |
| 31 | elif (ctx.attr.cpu == "armhf-debian"): |
| 32 | host_system_name = "linux" |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 33 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 34 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 35 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 36 | host_system_name = "local" |
| 37 | elif (ctx.attr.cpu == "roborio"): |
| 38 | host_system_name = "roborio" |
| 39 | else: |
| 40 | fail("Unreachable") |
| 41 | |
| 42 | if (ctx.attr.cpu == "armhf-debian"): |
| 43 | target_system_name = "arm_a15" |
| 44 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 45 | target_system_name = "armeabi-v7a" |
| 46 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 47 | target_system_name = "cortex-m4f" |
| 48 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 49 | target_system_name = "cortex-m4f-k22" |
| 50 | elif (ctx.attr.cpu == "k8"): |
| 51 | target_system_name = "k8" |
| 52 | elif (ctx.attr.cpu == "roborio"): |
| 53 | target_system_name = "roborio" |
| 54 | else: |
| 55 | fail("Unreachable") |
| 56 | |
| 57 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 58 | target_cpu = "armeabi-v7a" |
| 59 | elif (ctx.attr.cpu == "armhf-debian"): |
| 60 | target_cpu = "armhf-debian" |
| 61 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 62 | target_cpu = "cortex-m4f" |
| 63 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 64 | target_cpu = "cortex-m4f-k22" |
| 65 | elif (ctx.attr.cpu == "k8"): |
| 66 | target_cpu = "k8" |
| 67 | elif (ctx.attr.cpu == "roborio"): |
| 68 | target_cpu = "roborio" |
| 69 | else: |
| 70 | fail("Unreachable") |
| 71 | |
| 72 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 73 | target_libc = "armeabi-v7a" |
| 74 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 75 | target_libc = "cortex-m4f" |
| 76 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 77 | target_libc = "cortex-m4f-k22" |
| 78 | elif (ctx.attr.cpu == "armhf-debian"): |
| 79 | target_libc = "glibc_2.19" |
| 80 | elif (ctx.attr.cpu == "k8"): |
| 81 | target_libc = "local" |
| 82 | elif (ctx.attr.cpu == "roborio"): |
| 83 | target_libc = "roborio" |
| 84 | else: |
| 85 | fail("Unreachable") |
| 86 | |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 87 | if (ctx.attr.cpu == "armhf-debian" or |
| 88 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 89 | compiler = "clang" |
| 90 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 91 | compiler = "compiler" |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 92 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 93 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 94 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 95 | compiler = "gcc" |
| 96 | else: |
| 97 | fail("Unreachable") |
| 98 | |
| 99 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 100 | abi_version = "armeabi-v7a" |
| 101 | elif (ctx.attr.cpu == "armhf-debian"): |
| 102 | abi_version = "clang_6.0" |
| 103 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 104 | abi_version = "cortex-m4f" |
| 105 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 106 | abi_version = "cortex-m4f-k22" |
| 107 | elif (ctx.attr.cpu == "k8"): |
| 108 | abi_version = "local" |
| 109 | elif (ctx.attr.cpu == "roborio"): |
| 110 | abi_version = "roborio" |
| 111 | else: |
| 112 | fail("Unreachable") |
| 113 | |
| 114 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 115 | abi_libc_version = "armeabi-v7a" |
| 116 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 117 | abi_libc_version = "cortex-m4f" |
| 118 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 119 | abi_libc_version = "cortex-m4f-k22" |
| 120 | elif (ctx.attr.cpu == "armhf-debian"): |
| 121 | abi_libc_version = "glibc_2.19" |
| 122 | elif (ctx.attr.cpu == "k8"): |
| 123 | abi_libc_version = "local" |
| 124 | elif (ctx.attr.cpu == "roborio"): |
| 125 | abi_libc_version = "roborio" |
| 126 | else: |
| 127 | fail("Unreachable") |
| 128 | |
| 129 | cc_target_os = None |
| 130 | |
| 131 | builtin_sysroot = None |
| 132 | |
| 133 | all_compile_actions = [ |
| 134 | ACTION_NAMES.c_compile, |
| 135 | ACTION_NAMES.cpp_compile, |
| 136 | ACTION_NAMES.linkstamp_compile, |
| 137 | ACTION_NAMES.assemble, |
| 138 | ACTION_NAMES.preprocess_assemble, |
| 139 | ACTION_NAMES.cpp_header_parsing, |
| 140 | ACTION_NAMES.cpp_module_compile, |
| 141 | ACTION_NAMES.cpp_module_codegen, |
| 142 | ACTION_NAMES.clif_match, |
| 143 | ACTION_NAMES.lto_backend, |
| 144 | ] |
| 145 | |
| 146 | all_cpp_compile_actions = [ |
| 147 | ACTION_NAMES.cpp_compile, |
| 148 | ACTION_NAMES.linkstamp_compile, |
| 149 | ACTION_NAMES.cpp_header_parsing, |
| 150 | ACTION_NAMES.cpp_module_compile, |
| 151 | ACTION_NAMES.cpp_module_codegen, |
| 152 | ACTION_NAMES.clif_match, |
| 153 | ] |
| 154 | |
| 155 | preprocessor_compile_actions = [ |
| 156 | ACTION_NAMES.c_compile, |
| 157 | ACTION_NAMES.cpp_compile, |
| 158 | ACTION_NAMES.linkstamp_compile, |
| 159 | ACTION_NAMES.preprocess_assemble, |
| 160 | ACTION_NAMES.cpp_header_parsing, |
| 161 | ACTION_NAMES.cpp_module_compile, |
| 162 | ACTION_NAMES.clif_match, |
| 163 | ] |
| 164 | |
| 165 | codegen_compile_actions = [ |
| 166 | ACTION_NAMES.c_compile, |
| 167 | ACTION_NAMES.cpp_compile, |
| 168 | ACTION_NAMES.linkstamp_compile, |
| 169 | ACTION_NAMES.assemble, |
| 170 | ACTION_NAMES.preprocess_assemble, |
| 171 | ACTION_NAMES.cpp_module_codegen, |
| 172 | ACTION_NAMES.lto_backend, |
| 173 | ] |
| 174 | |
| 175 | all_link_actions = [ |
| 176 | ACTION_NAMES.cpp_link_executable, |
| 177 | ACTION_NAMES.cpp_link_dynamic_library, |
| 178 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 179 | ] |
| 180 | |
| 181 | if (ctx.attr.cpu == "roborio"): |
| 182 | objcopy_embed_data_action = action_config( |
| 183 | action_name = "objcopy_embed_data", |
| 184 | enabled = True, |
| 185 | tools = [ |
| 186 | tool( |
| 187 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objcopy", |
| 188 | ), |
| 189 | ], |
| 190 | ) |
| 191 | elif (ctx.attr.cpu == "armhf-debian"): |
| 192 | objcopy_embed_data_action = action_config( |
| 193 | action_name = "objcopy_embed_data", |
| 194 | enabled = True, |
| 195 | tools = [ |
| 196 | tool(path = "linaro_linux_gcc/arm-linux-gnueabihf-objcopy"), |
| 197 | ], |
| 198 | ) |
| 199 | elif (ctx.attr.cpu == "k8"): |
| 200 | objcopy_embed_data_action = action_config( |
| 201 | action_name = "objcopy_embed_data", |
| 202 | enabled = True, |
| 203 | tools = [tool(path = "clang_6p0/x86_64-linux-gnu-objcopy")], |
| 204 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 205 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 206 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 207 | objcopy_embed_data_action = action_config( |
| 208 | action_name = "objcopy_embed_data", |
| 209 | enabled = True, |
| 210 | tools = [tool(path = "gcc_arm_none_eabi/arm-none-eabi-objcopy")], |
| 211 | ) |
| 212 | else: |
| 213 | objcopy_embed_data_action = None |
| 214 | |
| 215 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 216 | action_configs = [] |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 217 | elif (ctx.attr.cpu == "armhf-debian" or |
| 218 | ctx.attr.cpu == "cortex-m4f" or |
| 219 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 220 | ctx.attr.cpu == "k8" or |
| 221 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 222 | action_configs = [objcopy_embed_data_action] |
| 223 | else: |
| 224 | fail("Unreachable") |
| 225 | |
| 226 | opt_post_feature = feature( |
| 227 | name = "opt_post", |
| 228 | flag_sets = [ |
| 229 | flag_set( |
| 230 | actions = [ |
| 231 | ACTION_NAMES.preprocess_assemble, |
| 232 | ACTION_NAMES.c_compile, |
| 233 | ACTION_NAMES.cpp_compile, |
| 234 | ACTION_NAMES.cpp_header_parsing, |
| 235 | "c++-header-preprocessing", |
| 236 | ACTION_NAMES.cpp_module_compile, |
| 237 | ], |
| 238 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 239 | ), |
| 240 | ], |
| 241 | ) |
| 242 | |
| 243 | supports_pic_feature = feature(name = "supports_pic", enabled = True) |
| 244 | |
| 245 | if (ctx.attr.cpu == "k8"): |
| 246 | default_compile_flags_feature = feature( |
| 247 | name = "default_compile_flags", |
| 248 | enabled = True, |
| 249 | flag_sets = [ |
| 250 | flag_set( |
| 251 | actions = [ |
| 252 | ACTION_NAMES.assemble, |
| 253 | ACTION_NAMES.preprocess_assemble, |
| 254 | ACTION_NAMES.linkstamp_compile, |
| 255 | ACTION_NAMES.c_compile, |
| 256 | ACTION_NAMES.cpp_compile, |
| 257 | ACTION_NAMES.cpp_header_parsing, |
| 258 | ACTION_NAMES.cpp_module_compile, |
| 259 | ACTION_NAMES.cpp_module_codegen, |
| 260 | ACTION_NAMES.lto_backend, |
| 261 | ACTION_NAMES.clif_match, |
| 262 | ], |
| 263 | flag_groups = [ |
| 264 | flag_group( |
| 265 | flags = [ |
| 266 | "--sysroot=external/amd64_debian_sysroot", |
| 267 | "-nostdinc", |
| 268 | "-isystem", |
| 269 | "external/amd64_debian_sysroot/usr/include/c++/7", |
| 270 | "-isystem", |
| 271 | "external/amd64_debian_sysroot/usr/include/x86_64-linux-gnu/c++/7", |
| 272 | "-isystem", |
| 273 | "external/amd64_debian_sysroot/usr/include/c++/8/backward", |
| 274 | "-isystem", |
| 275 | "external/amd64_debian_sysroot/usr/lib/gcc/x86_64-linux-gnu/8/include", |
| 276 | "-isystem", |
| 277 | "external/clang_6p0_repo/usr/lib/llvm-6.0/lib/clang/6.0.0/include", |
| 278 | "-isystem", |
| 279 | "external/amd64_debian_sysroot/usr/include/x86_64-linux-gnu", |
| 280 | "-isystem", |
| 281 | "external/amd64_debian_sysroot/usr/include", |
| 282 | "-D__STDC_FORMAT_MACROS", |
| 283 | "-D__STDC_CONSTANT_MACROS", |
| 284 | "-D__STDC_LIMIT_MACROS", |
| 285 | "-D_FILE_OFFSET_BITS=64", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 286 | "-U_FORTIFY_SOURCE", |
| 287 | "-D_FORTIFY_SOURCE=1", |
| 288 | "-fstack-protector", |
| 289 | "-fPIE", |
| 290 | "-fcolor-diagnostics", |
| 291 | "-fmessage-length=80", |
| 292 | "-fmacro-backtrace-limit=0", |
| 293 | "-Wall", |
| 294 | "-Wextra", |
| 295 | "-Wpointer-arith", |
| 296 | "-Wstrict-aliasing", |
| 297 | "-Wcast-qual", |
| 298 | "-Wcast-align", |
| 299 | "-Wwrite-strings", |
| 300 | "-Wtype-limits", |
| 301 | "-Wsign-compare", |
| 302 | "-Wformat=2", |
| 303 | "-Werror", |
| 304 | "-fno-omit-frame-pointer", |
| 305 | "-pipe", |
| 306 | "-ggdb3", |
| 307 | ], |
| 308 | ), |
| 309 | ], |
| 310 | ), |
| 311 | flag_set( |
| 312 | actions = [ |
| 313 | ACTION_NAMES.assemble, |
| 314 | ACTION_NAMES.preprocess_assemble, |
| 315 | ACTION_NAMES.linkstamp_compile, |
| 316 | ACTION_NAMES.c_compile, |
| 317 | ACTION_NAMES.cpp_compile, |
| 318 | ACTION_NAMES.cpp_header_parsing, |
| 319 | ACTION_NAMES.cpp_module_compile, |
| 320 | ACTION_NAMES.cpp_module_codegen, |
| 321 | ACTION_NAMES.lto_backend, |
| 322 | ACTION_NAMES.clif_match, |
| 323 | ], |
| 324 | flag_groups = [ |
| 325 | flag_group( |
| 326 | flags = [ |
| 327 | "-O2", |
| 328 | "-DNDEBUG", |
| 329 | "-ffunction-sections", |
| 330 | "-fdata-sections", |
| 331 | ], |
| 332 | ), |
| 333 | ], |
| 334 | with_features = [with_feature_set(features = ["opt"])], |
| 335 | ), |
| 336 | ], |
| 337 | ) |
| 338 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 339 | default_compile_flags_feature = feature( |
| 340 | name = "default_compile_flags", |
| 341 | enabled = True, |
| 342 | flag_sets = [ |
| 343 | flag_set( |
| 344 | actions = [ |
| 345 | ACTION_NAMES.assemble, |
| 346 | ACTION_NAMES.preprocess_assemble, |
| 347 | ACTION_NAMES.linkstamp_compile, |
| 348 | ACTION_NAMES.c_compile, |
| 349 | ACTION_NAMES.cpp_compile, |
| 350 | ACTION_NAMES.cpp_header_parsing, |
| 351 | ACTION_NAMES.cpp_module_compile, |
| 352 | ACTION_NAMES.cpp_module_codegen, |
| 353 | ACTION_NAMES.lto_backend, |
| 354 | ACTION_NAMES.clif_match, |
| 355 | ], |
| 356 | flag_groups = [ |
| 357 | flag_group( |
| 358 | flags = [ |
| 359 | "-D__STDC_FORMAT_MACROS", |
| 360 | "-D__STDC_CONSTANT_MACROS", |
| 361 | "-D__STDC_LIMIT_MACROS", |
| 362 | "-D__MK22FX512__", |
| 363 | "-DF_CPU=120000000", |
| 364 | "-Wl,--gc-sections", |
| 365 | "-D__have_long32", |
| 366 | "-fstack-protector", |
| 367 | "-mcpu=cortex-m4", |
| 368 | "-mfpu=fpv4-sp-d16", |
| 369 | "-mthumb", |
| 370 | "-mfloat-abi=hard", |
| 371 | "-fno-strict-aliasing", |
| 372 | "-fmessage-length=80", |
| 373 | "-fmax-errors=20", |
| 374 | "-Wall", |
| 375 | "-Wextra", |
| 376 | "-Wpointer-arith", |
| 377 | "-Wcast-qual", |
| 378 | "-Wwrite-strings", |
| 379 | "-Wtype-limits", |
| 380 | "-Wsign-compare", |
| 381 | "-Wformat=2", |
| 382 | "-Werror", |
| 383 | "-Wstrict-aliasing=2", |
| 384 | "-Wno-misleading-indentation", |
| 385 | "-Wno-int-in-bool-context", |
| 386 | "-Wdouble-promotion", |
| 387 | "-pipe", |
| 388 | "-g", |
| 389 | "-fno-common", |
| 390 | "-ffreestanding", |
| 391 | "-fbuiltin", |
| 392 | ], |
| 393 | ), |
| 394 | ], |
| 395 | ), |
| 396 | flag_set( |
| 397 | actions = [ |
| 398 | ACTION_NAMES.assemble, |
| 399 | ACTION_NAMES.preprocess_assemble, |
| 400 | ACTION_NAMES.linkstamp_compile, |
| 401 | ACTION_NAMES.c_compile, |
| 402 | ACTION_NAMES.cpp_compile, |
| 403 | ACTION_NAMES.cpp_header_parsing, |
| 404 | ACTION_NAMES.cpp_module_compile, |
| 405 | ACTION_NAMES.cpp_module_codegen, |
| 406 | ACTION_NAMES.lto_backend, |
| 407 | ACTION_NAMES.clif_match, |
| 408 | ], |
| 409 | flag_groups = [ |
| 410 | flag_group( |
| 411 | flags = [ |
| 412 | "-O2", |
| 413 | "-finline-functions", |
| 414 | "-ffast-math", |
| 415 | "-funroll-loops", |
| 416 | "-DNDEBUG", |
| 417 | "-ffunction-sections", |
| 418 | ], |
| 419 | ), |
| 420 | ], |
| 421 | with_features = [with_feature_set(features = ["opt"])], |
| 422 | ), |
| 423 | ], |
| 424 | ) |
| 425 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 426 | default_compile_flags_feature = feature( |
| 427 | name = "default_compile_flags", |
| 428 | enabled = True, |
| 429 | flag_sets = [ |
| 430 | flag_set( |
| 431 | actions = [ |
| 432 | ACTION_NAMES.assemble, |
| 433 | ACTION_NAMES.preprocess_assemble, |
| 434 | ACTION_NAMES.linkstamp_compile, |
| 435 | ACTION_NAMES.c_compile, |
| 436 | ACTION_NAMES.cpp_compile, |
| 437 | ACTION_NAMES.cpp_header_parsing, |
| 438 | ACTION_NAMES.cpp_module_compile, |
| 439 | ACTION_NAMES.cpp_module_codegen, |
| 440 | ACTION_NAMES.lto_backend, |
| 441 | ACTION_NAMES.clif_match, |
| 442 | ], |
| 443 | flag_groups = [ |
| 444 | flag_group( |
| 445 | flags = [ |
| 446 | "-D__STDC_FORMAT_MACROS", |
| 447 | "-D__STDC_CONSTANT_MACROS", |
| 448 | "-D__STDC_LIMIT_MACROS", |
| 449 | "-D__MK64FX512__", |
| 450 | "-DF_CPU=120000000", |
| 451 | "-Wl,--gc-sections", |
| 452 | "-D__have_long32", |
| 453 | "-fstack-protector", |
| 454 | "-mcpu=cortex-m4", |
| 455 | "-mfpu=fpv4-sp-d16", |
| 456 | "-mthumb", |
| 457 | "-mfloat-abi=hard", |
| 458 | "-fno-strict-aliasing", |
| 459 | "-fmessage-length=80", |
| 460 | "-fmax-errors=20", |
| 461 | "-Wall", |
| 462 | "-Wextra", |
| 463 | "-Wpointer-arith", |
| 464 | "-Wcast-qual", |
| 465 | "-Wwrite-strings", |
| 466 | "-Wtype-limits", |
| 467 | "-Wsign-compare", |
| 468 | "-Wformat=2", |
| 469 | "-Werror", |
| 470 | "-Wstrict-aliasing=2", |
| 471 | "-Wno-misleading-indentation", |
| 472 | "-Wno-int-in-bool-context", |
| 473 | "-Wdouble-promotion", |
| 474 | "-pipe", |
| 475 | "-g", |
| 476 | "-fno-common", |
| 477 | "-ffreestanding", |
| 478 | "-fbuiltin", |
| 479 | ], |
| 480 | ), |
| 481 | ], |
| 482 | ), |
| 483 | flag_set( |
| 484 | actions = [ |
| 485 | ACTION_NAMES.assemble, |
| 486 | ACTION_NAMES.preprocess_assemble, |
| 487 | ACTION_NAMES.linkstamp_compile, |
| 488 | ACTION_NAMES.c_compile, |
| 489 | ACTION_NAMES.cpp_compile, |
| 490 | ACTION_NAMES.cpp_header_parsing, |
| 491 | ACTION_NAMES.cpp_module_compile, |
| 492 | ACTION_NAMES.cpp_module_codegen, |
| 493 | ACTION_NAMES.lto_backend, |
| 494 | ACTION_NAMES.clif_match, |
| 495 | ], |
| 496 | flag_groups = [ |
| 497 | flag_group( |
| 498 | flags = [ |
| 499 | "-O2", |
| 500 | "-finline-functions", |
| 501 | "-ffast-math", |
| 502 | "-funroll-loops", |
| 503 | "-DNDEBUG", |
| 504 | "-ffunction-sections", |
| 505 | ], |
| 506 | ), |
| 507 | ], |
| 508 | with_features = [with_feature_set(features = ["opt"])], |
| 509 | ), |
| 510 | ], |
| 511 | ) |
| 512 | elif (ctx.attr.cpu == "armhf-debian"): |
| 513 | default_compile_flags_feature = feature( |
| 514 | name = "default_compile_flags", |
| 515 | enabled = True, |
| 516 | flag_sets = [ |
| 517 | flag_set( |
| 518 | actions = [ |
| 519 | ACTION_NAMES.assemble, |
| 520 | ACTION_NAMES.preprocess_assemble, |
| 521 | ACTION_NAMES.linkstamp_compile, |
| 522 | ACTION_NAMES.c_compile, |
| 523 | ACTION_NAMES.cpp_compile, |
| 524 | ACTION_NAMES.cpp_header_parsing, |
| 525 | ACTION_NAMES.cpp_module_compile, |
| 526 | ACTION_NAMES.cpp_module_codegen, |
| 527 | ACTION_NAMES.lto_backend, |
| 528 | ACTION_NAMES.clif_match, |
| 529 | ], |
| 530 | flag_groups = [ |
| 531 | flag_group( |
| 532 | flags = [ |
| 533 | "-target", |
| 534 | "armv7a-arm-linux-gnueabif", |
| 535 | "--sysroot=external/armhf_debian_rootfs", |
| 536 | "-mfloat-abi=hard", |
| 537 | "-mfpu=vfpv3-d16", |
| 538 | "-nostdinc", |
| 539 | "-isystem", |
| 540 | "external/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/7.4.1/include", |
| 541 | "-isystem", |
| 542 | "external/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/7.4.1/include-fixed", |
| 543 | "-isystem", |
| 544 | "external/linaro_linux_gcc_repo/arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf", |
| 545 | "-isystem", |
| 546 | "external/linaro_linux_gcc_repo/arm-linux-gnueabihf/include/c++/7.4.1", |
| 547 | "-isystem", |
| 548 | "external/linaro_linux_gcc_repo/include/c++/7.4.1/arm-linux-gnueabihf", |
| 549 | "-isystem", |
| 550 | "external/linaro_linux_gcc_repo/include/c++/7.4.1", |
| 551 | "-isystem", |
| 552 | "external/armhf_debian_rootfs/usr/include", |
| 553 | "-isystem", |
| 554 | "external/armhf_debian_rootfs/usr/include/arm-linux-gnueabihf", |
| 555 | "-isystem", |
| 556 | "external/org_frc971/third_party", |
| 557 | "-D__STDC_FORMAT_MACROS", |
| 558 | "-D__STDC_CONSTANT_MACROS", |
| 559 | "-D__STDC_LIMIT_MACROS", |
| 560 | "-D_FILE_OFFSET_BITS=64", |
| 561 | "-DAOS_ARCHITECTURE_armhf", |
| 562 | "-U_FORTIFY_SOURCE", |
| 563 | "-fstack-protector", |
| 564 | "-fPIE", |
| 565 | "-fdiagnostics-color=always", |
| 566 | "-Wall", |
| 567 | "-Wextra", |
| 568 | "-Wpointer-arith", |
| 569 | "-Wstrict-aliasing", |
| 570 | "-Wcast-qual", |
| 571 | "-Wcast-align", |
| 572 | "-Wwrite-strings", |
| 573 | "-Wtype-limits", |
| 574 | "-Wsign-compare", |
| 575 | "-Wformat=2", |
| 576 | "-Werror", |
| 577 | "-Wunused-local-typedefs", |
| 578 | "-fno-omit-frame-pointer", |
| 579 | "-pipe", |
| 580 | "-ggdb3", |
| 581 | ], |
| 582 | ), |
| 583 | ], |
| 584 | ), |
| 585 | flag_set( |
| 586 | actions = [ |
| 587 | ACTION_NAMES.assemble, |
| 588 | ACTION_NAMES.preprocess_assemble, |
| 589 | ACTION_NAMES.linkstamp_compile, |
| 590 | ACTION_NAMES.c_compile, |
| 591 | ACTION_NAMES.cpp_compile, |
| 592 | ACTION_NAMES.cpp_header_parsing, |
| 593 | ACTION_NAMES.cpp_module_compile, |
| 594 | ACTION_NAMES.cpp_module_codegen, |
| 595 | ACTION_NAMES.lto_backend, |
| 596 | ACTION_NAMES.clif_match, |
| 597 | ], |
| 598 | flag_groups = [ |
| 599 | flag_group( |
| 600 | flags = [ |
| 601 | "-O2", |
| 602 | "-DNDEBUG", |
| 603 | "-D_FORTIFY_SOURCE=1", |
| 604 | "-ffunction-sections", |
| 605 | "-fdata-sections", |
| 606 | ], |
| 607 | ), |
| 608 | ], |
| 609 | with_features = [with_feature_set(features = ["opt"])], |
| 610 | ), |
| 611 | ], |
| 612 | ) |
| 613 | else: |
| 614 | default_compile_flags_feature = None |
| 615 | |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 616 | if (ctx.attr.cpu == "armhf-debian" or |
| 617 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 618 | dbg_feature = feature( |
| 619 | name = "dbg", |
| 620 | flag_sets = [ |
| 621 | flag_set( |
| 622 | actions = [ |
| 623 | ACTION_NAMES.preprocess_assemble, |
| 624 | ACTION_NAMES.c_compile, |
| 625 | ACTION_NAMES.cpp_compile, |
| 626 | ACTION_NAMES.cpp_header_parsing, |
| 627 | "c++-header-preprocessing", |
| 628 | ACTION_NAMES.cpp_module_compile, |
| 629 | ], |
| 630 | flag_groups = [ |
| 631 | flag_group(flags = ["-DAOS_DEBUG=1"]), |
| 632 | flag_group(flags = ["-fno-omit-frame-pointer"]), |
| 633 | ], |
| 634 | ), |
| 635 | ], |
| 636 | implies = ["all_modes"], |
| 637 | ) |
| 638 | elif (ctx.attr.cpu == "roborio"): |
| 639 | dbg_feature = feature( |
| 640 | name = "dbg", |
| 641 | flag_sets = [ |
| 642 | flag_set( |
| 643 | actions = [ |
| 644 | ACTION_NAMES.preprocess_assemble, |
| 645 | ACTION_NAMES.c_compile, |
| 646 | ACTION_NAMES.cpp_compile, |
| 647 | ACTION_NAMES.cpp_header_parsing, |
| 648 | "c++-header-preprocessing", |
| 649 | ACTION_NAMES.cpp_module_compile, |
| 650 | ], |
| 651 | flag_groups = [ |
| 652 | flag_group(flags = ["-DAOS_DEBUG=1"]), |
| 653 | flag_group(flags = ["-fno-omit-frame-pointer"]), |
| 654 | ], |
| 655 | ), |
| 656 | ], |
| 657 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 658 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 659 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 660 | dbg_feature = feature( |
| 661 | name = "dbg", |
| 662 | flag_sets = [ |
| 663 | flag_set( |
| 664 | actions = [ |
| 665 | ACTION_NAMES.preprocess_assemble, |
| 666 | ACTION_NAMES.c_compile, |
| 667 | ACTION_NAMES.cpp_compile, |
| 668 | ACTION_NAMES.cpp_header_parsing, |
| 669 | "c++-header-preprocessing", |
| 670 | ACTION_NAMES.cpp_module_compile, |
| 671 | ], |
| 672 | flag_groups = [flag_group(flags = ["-fno-omit-frame-pointer"])], |
| 673 | ), |
| 674 | ], |
| 675 | implies = ["all_modes"], |
| 676 | ) |
| 677 | else: |
| 678 | dbg_feature = None |
| 679 | |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 680 | if (ctx.attr.cpu == "armhf-debian" or |
| 681 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 682 | fastbuild_feature = feature( |
| 683 | name = "fastbuild", |
| 684 | flag_sets = [ |
| 685 | flag_set( |
| 686 | actions = [ |
| 687 | ACTION_NAMES.preprocess_assemble, |
| 688 | ACTION_NAMES.c_compile, |
| 689 | ACTION_NAMES.cpp_compile, |
| 690 | ACTION_NAMES.cpp_header_parsing, |
| 691 | "c++-header-preprocessing", |
| 692 | ACTION_NAMES.cpp_module_compile, |
| 693 | ], |
| 694 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 695 | ), |
| 696 | ], |
| 697 | implies = ["all_modes"], |
| 698 | ) |
| 699 | elif (ctx.attr.cpu == "roborio"): |
| 700 | fastbuild_feature = feature( |
| 701 | name = "fastbuild", |
| 702 | flag_sets = [ |
| 703 | flag_set( |
| 704 | actions = [ |
| 705 | ACTION_NAMES.preprocess_assemble, |
| 706 | ACTION_NAMES.c_compile, |
| 707 | ACTION_NAMES.cpp_compile, |
| 708 | ACTION_NAMES.cpp_header_parsing, |
| 709 | "c++-header-preprocessing", |
| 710 | ACTION_NAMES.cpp_module_compile, |
| 711 | ], |
| 712 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 713 | ), |
| 714 | ], |
| 715 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 716 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 717 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 718 | fastbuild_feature = feature(name = "fastbuild", implies = ["all_modes"]) |
| 719 | else: |
| 720 | fastbuild_feature = None |
| 721 | |
| 722 | pie_for_linking_feature = feature( |
| 723 | name = "pie_for_linking", |
| 724 | enabled = True, |
| 725 | flag_sets = [ |
| 726 | flag_set( |
| 727 | actions = [ACTION_NAMES.cpp_link_executable], |
| 728 | flag_groups = [flag_group(flags = ["-pie"])], |
| 729 | ), |
| 730 | ], |
| 731 | ) |
| 732 | |
| 733 | if (ctx.attr.cpu == "roborio"): |
| 734 | opt_feature = feature( |
| 735 | name = "opt", |
| 736 | flag_sets = [ |
| 737 | flag_set( |
| 738 | actions = [ |
| 739 | ACTION_NAMES.assemble, |
| 740 | ACTION_NAMES.preprocess_assemble, |
| 741 | ACTION_NAMES.c_compile, |
| 742 | ACTION_NAMES.cpp_compile, |
| 743 | ACTION_NAMES.cpp_module_compile, |
| 744 | ACTION_NAMES.objc_compile, |
| 745 | ACTION_NAMES.objcpp_compile, |
| 746 | ACTION_NAMES.cpp_header_parsing, |
| 747 | ACTION_NAMES.linkstamp_compile, |
| 748 | ], |
| 749 | flag_groups = [ |
| 750 | flag_group( |
| 751 | flags = [ |
| 752 | "-O2", |
| 753 | "-DNDEBUG", |
| 754 | "-D_FORTIFY_SOURCE=1", |
| 755 | "-ffunction-sections", |
| 756 | "-fdata-sections", |
| 757 | ], |
| 758 | ), |
| 759 | ], |
| 760 | ), |
| 761 | flag_set( |
| 762 | actions = [ |
| 763 | ACTION_NAMES.cpp_link_executable, |
| 764 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 765 | ACTION_NAMES.cpp_link_dynamic_library, |
| 766 | ], |
| 767 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 768 | ), |
| 769 | ], |
| 770 | implies = ["opt_post"], |
| 771 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 772 | elif (ctx.attr.cpu == "armhf-debian" or |
| 773 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 774 | opt_feature = feature( |
| 775 | name = "opt", |
| 776 | flag_sets = [ |
| 777 | flag_set( |
| 778 | actions = [ |
| 779 | ACTION_NAMES.preprocess_assemble, |
| 780 | ACTION_NAMES.c_compile, |
| 781 | ACTION_NAMES.cpp_compile, |
| 782 | ACTION_NAMES.cpp_header_parsing, |
| 783 | "c++-header-preprocessing", |
| 784 | ACTION_NAMES.cpp_module_compile, |
| 785 | ], |
| 786 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 787 | ), |
| 788 | ], |
| 789 | implies = ["all_modes"], |
| 790 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 791 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 792 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 793 | opt_feature = feature(name = "opt", implies = ["all_modes"]) |
| 794 | else: |
| 795 | opt_feature = None |
| 796 | |
| 797 | pic_feature = feature( |
| 798 | name = "pic", |
| 799 | enabled = True, |
| 800 | flag_sets = [ |
| 801 | flag_set( |
| 802 | actions = [ |
| 803 | ACTION_NAMES.assemble, |
| 804 | ACTION_NAMES.preprocess_assemble, |
| 805 | ACTION_NAMES.linkstamp_compile, |
| 806 | ACTION_NAMES.c_compile, |
| 807 | ACTION_NAMES.cpp_compile, |
| 808 | ACTION_NAMES.cpp_module_codegen, |
| 809 | ACTION_NAMES.cpp_module_compile, |
| 810 | ], |
| 811 | flag_groups = [ |
| 812 | flag_group(flags = ["-fPIC"], expand_if_available = "pic"), |
| 813 | ], |
| 814 | ), |
| 815 | ], |
| 816 | ) |
| 817 | |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 818 | if (ctx.attr.cpu == "cortex-m4f" or |
| 819 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 820 | include_paths_feature = feature( |
| 821 | name = "include_paths", |
| 822 | enabled = True, |
| 823 | flag_sets = [ |
| 824 | flag_set( |
| 825 | actions = [ |
| 826 | ACTION_NAMES.preprocess_assemble, |
| 827 | ACTION_NAMES.c_compile, |
| 828 | ACTION_NAMES.cpp_compile, |
| 829 | ACTION_NAMES.cpp_header_parsing, |
| 830 | "c++-header-preprocessing", |
| 831 | ACTION_NAMES.cpp_module_compile, |
| 832 | ], |
| 833 | flag_groups = [ |
| 834 | flag_group( |
| 835 | flags = ["-iquote", "%{quote_include_paths}"], |
| 836 | iterate_over = "quote_include_paths", |
| 837 | ), |
| 838 | flag_group( |
| 839 | flags = ["-I%{include_paths}"], |
| 840 | iterate_over = "include_paths", |
| 841 | ), |
| 842 | flag_group( |
| 843 | flags = ["-I", "%{system_include_paths}"], |
| 844 | iterate_over = "system_include_paths", |
| 845 | ), |
| 846 | ], |
| 847 | ), |
| 848 | ], |
| 849 | ) |
| 850 | elif (ctx.attr.cpu == "roborio"): |
| 851 | include_paths_feature = feature( |
| 852 | name = "include_paths", |
| 853 | enabled = True, |
| 854 | flag_sets = [ |
| 855 | flag_set( |
| 856 | actions = [ |
| 857 | ACTION_NAMES.preprocess_assemble, |
| 858 | ACTION_NAMES.c_compile, |
| 859 | ACTION_NAMES.cpp_compile, |
| 860 | ACTION_NAMES.cpp_header_parsing, |
| 861 | "c++-header-preprocessing", |
| 862 | ACTION_NAMES.cpp_module_compile, |
| 863 | ], |
| 864 | flag_groups = [ |
| 865 | flag_group( |
| 866 | flags = ["-iquote", "%{quote_include_paths}"], |
| 867 | iterate_over = "quote_include_paths", |
| 868 | ), |
| 869 | flag_group( |
| 870 | flags = ["-I%{include_paths}"], |
| 871 | iterate_over = "include_paths", |
| 872 | ), |
| 873 | flag_group( |
| 874 | flags = ["-isystem", "%{system_include_paths}"], |
| 875 | iterate_over = "system_include_paths", |
| 876 | ), |
| 877 | ], |
| 878 | ), |
| 879 | ], |
| 880 | ) |
| 881 | else: |
| 882 | include_paths_feature = None |
| 883 | |
| 884 | random_seed_feature = feature( |
| 885 | name = "random_seed", |
| 886 | enabled = True, |
| 887 | flag_sets = [ |
| 888 | flag_set( |
| 889 | actions = [ |
| 890 | ACTION_NAMES.cpp_compile, |
| 891 | ACTION_NAMES.cpp_module_codegen, |
| 892 | ACTION_NAMES.cpp_module_compile, |
| 893 | ], |
| 894 | flag_groups = [ |
| 895 | flag_group( |
| 896 | flags = ["-frandom-seed=%{output_file}"], |
| 897 | expand_if_available = "output_file", |
| 898 | ), |
| 899 | ], |
| 900 | ), |
| 901 | ], |
| 902 | ) |
| 903 | |
| 904 | if (ctx.attr.cpu == "roborio"): |
| 905 | default_link_flags_feature = feature( |
| 906 | name = "default_link_flags", |
| 907 | enabled = True, |
| 908 | flag_sets = [ |
| 909 | flag_set( |
| 910 | actions = all_link_actions, |
| 911 | flag_groups = [ |
| 912 | flag_group( |
| 913 | flags = [ |
| 914 | "-lstdc++", |
| 915 | "-Ltools/cpp/arm-frc-linux-gnueabi/libs", |
| 916 | "-no-canonical-prefixes", |
| 917 | "-Wl,-z,relro,-z,now", |
| 918 | "-lm", |
| 919 | "-pass-exit-codes", |
| 920 | "-Wl,--build-id=md5", |
| 921 | "-Wl,--hash-style=gnu", |
| 922 | ], |
| 923 | ), |
| 924 | ], |
| 925 | ), |
| 926 | ], |
| 927 | ) |
| 928 | elif (ctx.attr.cpu == "cortex-m4f-k22"): |
| 929 | default_link_flags_feature = feature( |
| 930 | name = "default_link_flags", |
| 931 | enabled = True, |
| 932 | flag_sets = [ |
| 933 | flag_set( |
| 934 | actions = all_link_actions, |
| 935 | flag_groups = [ |
| 936 | flag_group( |
| 937 | flags = [ |
| 938 | "-no-canonical-prefixes", |
| 939 | "-mcpu=cortex-m4", |
| 940 | "-mfpu=fpv4-sp-d16", |
| 941 | "-mthumb", |
| 942 | "-mfloat-abi=hard", |
| 943 | "-fno-strict-aliasing", |
| 944 | "--specs=nano.specs", |
| 945 | "-lgcc", |
| 946 | "-lstdc++_nano", |
| 947 | "-lm", |
| 948 | "-lc_nano", |
| 949 | "-Tmotors/core/kinetis_512_128.ld", |
| 950 | "-Tmotors/core/kinetis_sections.ld", |
| 951 | ], |
| 952 | ), |
| 953 | ], |
| 954 | ), |
| 955 | flag_set( |
| 956 | actions = all_link_actions, |
| 957 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 958 | with_features = [with_feature_set(features = ["opt"])], |
| 959 | ), |
| 960 | ], |
| 961 | ) |
| 962 | elif (ctx.attr.cpu == "cortex-m4f"): |
| 963 | default_link_flags_feature = feature( |
| 964 | name = "default_link_flags", |
| 965 | enabled = True, |
| 966 | flag_sets = [ |
| 967 | flag_set( |
| 968 | actions = all_link_actions, |
| 969 | flag_groups = [ |
| 970 | flag_group( |
| 971 | flags = [ |
| 972 | "-no-canonical-prefixes", |
| 973 | "-mcpu=cortex-m4", |
| 974 | "-mfpu=fpv4-sp-d16", |
| 975 | "-mthumb", |
| 976 | "-mfloat-abi=hard", |
| 977 | "-fno-strict-aliasing", |
| 978 | "--specs=nano.specs", |
| 979 | "-lgcc", |
| 980 | "-lstdc++_nano", |
| 981 | "-lm", |
| 982 | "-lc_nano", |
| 983 | "-Tmotors/core/kinetis_512_256.ld", |
| 984 | "-Tmotors/core/kinetis_sections.ld", |
| 985 | ], |
| 986 | ), |
| 987 | ], |
| 988 | ), |
| 989 | flag_set( |
| 990 | actions = all_link_actions, |
| 991 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 992 | with_features = [with_feature_set(features = ["opt"])], |
| 993 | ), |
| 994 | ], |
| 995 | ) |
| 996 | elif (ctx.attr.cpu == "k8"): |
| 997 | default_link_flags_feature = feature( |
| 998 | name = "default_link_flags", |
| 999 | enabled = True, |
| 1000 | flag_sets = [ |
| 1001 | flag_set( |
| 1002 | actions = all_link_actions, |
| 1003 | flag_groups = [ |
| 1004 | flag_group( |
| 1005 | flags = [ |
| 1006 | "-nodefaultlibs", |
| 1007 | "--sysroot=external/amd64_debian_sysroot", |
| 1008 | "-lstdc++", |
| 1009 | "-lc", |
| 1010 | "-lgcc", |
| 1011 | "-lgcc_s", |
| 1012 | "-Bexternal/clang_6p0_repo/usr/bin/", |
| 1013 | "-Ltools/cpp/clang_6p0/clang_more_libs", |
| 1014 | "-Lexternal/amd64_debian_sysroot/usr/lib/gcc/x86_64-linux-gnu/7/", |
| 1015 | "-Lexternal/amd64_debian_sysroot/usr/lib/x86_64-linux-gnu/", |
| 1016 | "-Lexternal/amd64_debian_sysroot/usr/lib/", |
| 1017 | "-Lexternal/amd64_debian_sysroot/lib/x86_64-linux-gnu/", |
| 1018 | "-Lexternal/amd64_debian_sysroot/lib/", |
| 1019 | "-no-canonical-prefixes", |
| 1020 | "-fuse-ld=gold", |
| 1021 | "-Wl,-z,relro,-z,now", |
| 1022 | "-lm", |
| 1023 | "-Wl,--build-id=md5", |
| 1024 | "-Wl,--hash-style=gnu", |
| 1025 | "-Wl,--warn-execstack", |
| 1026 | "-Wl,--detect-odr-violations", |
| 1027 | ], |
| 1028 | ), |
| 1029 | ], |
| 1030 | ), |
| 1031 | flag_set( |
| 1032 | actions = all_link_actions, |
| 1033 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 1034 | with_features = [with_feature_set(features = ["opt"])], |
| 1035 | ), |
| 1036 | ], |
| 1037 | ) |
| 1038 | elif (ctx.attr.cpu == "armhf-debian"): |
| 1039 | default_link_flags_feature = feature( |
| 1040 | name = "default_link_flags", |
| 1041 | enabled = True, |
| 1042 | flag_sets = [ |
| 1043 | flag_set( |
| 1044 | actions = all_link_actions, |
| 1045 | flag_groups = [ |
| 1046 | flag_group( |
| 1047 | flags = [ |
| 1048 | "-target", |
| 1049 | "armv7a-arm-linux-gnueabif", |
| 1050 | "--sysroot=external/armhf_debian_rootfs", |
| 1051 | "-lstdc++", |
| 1052 | "-Ltools/cpp/linaro_linux_gcc/clang_more_libs", |
| 1053 | "-Lexternal/armhf_debian_rootfs/usr/lib/gcc/arm-linux-gnueabihf/8", |
| 1054 | "-Lexternal/armhf_debian_rootfs/lib/arm-linux-gnueabihf", |
| 1055 | "-Lexternal/armhf_debian_rootfs/usr/lib/arm-linux-gnueabihf", |
| 1056 | "-Lexternal/armhf_debian_rootfs/lib", |
| 1057 | "-Lexternal/armhf_debian_rootfs/usr/lib", |
| 1058 | "-Lexternal/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/7.4.1", |
| 1059 | "-Bexternal/linaro_linux_gcc_repo/lib/gcc/arm-linux-gnueabihf/7.4.1", |
| 1060 | "-Bexternal/linaro_linux_gcc_repo/arm-linux-gnueabihf/bin", |
| 1061 | "-Wl,--dynamic-linker=/lib/ld-linux-armhf.so.3", |
| 1062 | "-no-canonical-prefixes", |
| 1063 | "-Wl,-z,relro,-z,now", |
| 1064 | "-lm", |
| 1065 | "-Wl,--build-id=md5", |
| 1066 | "-Wl,--hash-style=gnu", |
| 1067 | ], |
| 1068 | ), |
| 1069 | ], |
| 1070 | ), |
| 1071 | flag_set( |
| 1072 | actions = all_link_actions, |
| 1073 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 1074 | with_features = [with_feature_set(features = ["opt"])], |
| 1075 | ), |
| 1076 | ], |
| 1077 | ) |
| 1078 | else: |
| 1079 | default_link_flags_feature = None |
| 1080 | |
| 1081 | if (ctx.attr.cpu == "roborio"): |
| 1082 | all_modes_feature = feature( |
| 1083 | name = "all_modes", |
| 1084 | enabled = True, |
| 1085 | flag_sets = [ |
| 1086 | flag_set( |
| 1087 | actions = [ |
| 1088 | ACTION_NAMES.preprocess_assemble, |
| 1089 | ACTION_NAMES.assemble, |
| 1090 | ACTION_NAMES.c_compile, |
| 1091 | ], |
| 1092 | flag_groups = [flag_group(flags = ["-std=gnu99"])], |
| 1093 | ), |
| 1094 | flag_set( |
| 1095 | actions = [ |
| 1096 | ACTION_NAMES.cpp_compile, |
| 1097 | ACTION_NAMES.cpp_header_parsing, |
| 1098 | "c++-header-preprocessing", |
| 1099 | ACTION_NAMES.cpp_module_compile, |
| 1100 | ], |
| 1101 | flag_groups = [ |
| 1102 | flag_group( |
| 1103 | flags = ["-std=gnu++1z", "-fno-sized-deallocation"], |
| 1104 | ), |
| 1105 | ], |
| 1106 | ), |
| 1107 | flag_set( |
| 1108 | actions = [ |
| 1109 | ACTION_NAMES.preprocess_assemble, |
| 1110 | ACTION_NAMES.assemble, |
| 1111 | "c++-link", |
| 1112 | ACTION_NAMES.cpp_compile, |
| 1113 | ACTION_NAMES.cpp_header_parsing, |
| 1114 | "c++-header-preprocessing", |
| 1115 | ACTION_NAMES.cpp_module_compile, |
| 1116 | ACTION_NAMES.c_compile, |
| 1117 | ], |
| 1118 | flag_groups = [flag_group(flags = ["-pthread"])], |
| 1119 | ), |
| 1120 | ], |
| 1121 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1122 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 1123 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1124 | all_modes_feature = feature( |
| 1125 | name = "all_modes", |
| 1126 | flag_sets = [ |
| 1127 | flag_set( |
| 1128 | actions = [ |
| 1129 | ACTION_NAMES.preprocess_assemble, |
| 1130 | ACTION_NAMES.assemble, |
| 1131 | ACTION_NAMES.c_compile, |
| 1132 | ], |
| 1133 | flag_groups = [flag_group(flags = ["--std=gnu99"])], |
| 1134 | ), |
| 1135 | flag_set( |
| 1136 | actions = [ |
| 1137 | ACTION_NAMES.cpp_compile, |
| 1138 | ACTION_NAMES.cpp_header_parsing, |
| 1139 | "c++-header-preprocessing", |
| 1140 | ACTION_NAMES.cpp_module_compile, |
| 1141 | ], |
| 1142 | flag_groups = [ |
| 1143 | flag_group( |
| 1144 | flags = ["--std=gnu++1z", "-fno-exceptions", "-fno-rtti"], |
| 1145 | ), |
| 1146 | ], |
| 1147 | ), |
| 1148 | ], |
| 1149 | ) |
| 1150 | elif (ctx.attr.cpu == "armhf-debian"): |
| 1151 | all_modes_feature = feature( |
| 1152 | name = "all_modes", |
| 1153 | flag_sets = [ |
| 1154 | flag_set( |
| 1155 | actions = [ |
| 1156 | ACTION_NAMES.preprocess_assemble, |
| 1157 | ACTION_NAMES.assemble, |
| 1158 | ACTION_NAMES.c_compile, |
| 1159 | ], |
| 1160 | flag_groups = [flag_group(flags = ["-std=gnu99"])], |
| 1161 | ), |
| 1162 | flag_set( |
| 1163 | actions = [ |
| 1164 | ACTION_NAMES.cpp_compile, |
| 1165 | ACTION_NAMES.cpp_header_parsing, |
| 1166 | "c++-header-preprocessing", |
| 1167 | ACTION_NAMES.cpp_module_compile, |
| 1168 | ], |
| 1169 | flag_groups = [flag_group(flags = ["-std=gnu++1z"])], |
| 1170 | ), |
| 1171 | flag_set( |
| 1172 | actions = [ |
| 1173 | ACTION_NAMES.preprocess_assemble, |
| 1174 | ACTION_NAMES.assemble, |
| 1175 | "c++-link", |
| 1176 | ACTION_NAMES.cpp_compile, |
| 1177 | ACTION_NAMES.cpp_header_parsing, |
| 1178 | "c++-header-preprocessing", |
| 1179 | ACTION_NAMES.cpp_module_compile, |
| 1180 | ACTION_NAMES.c_compile, |
| 1181 | ], |
| 1182 | flag_groups = [flag_group(flags = ["-pthread"])], |
| 1183 | ), |
| 1184 | ], |
| 1185 | ) |
| 1186 | elif (ctx.attr.cpu == "k8"): |
| 1187 | all_modes_feature = feature( |
| 1188 | name = "all_modes", |
| 1189 | flag_sets = [ |
| 1190 | flag_set( |
| 1191 | actions = [ |
| 1192 | ACTION_NAMES.preprocess_assemble, |
| 1193 | ACTION_NAMES.assemble, |
| 1194 | ACTION_NAMES.c_compile, |
| 1195 | ], |
| 1196 | flag_groups = [flag_group(flags = ["-std=gnu99"])], |
| 1197 | ), |
| 1198 | flag_set( |
| 1199 | actions = [ |
| 1200 | ACTION_NAMES.cpp_compile, |
| 1201 | ACTION_NAMES.cpp_header_parsing, |
| 1202 | "c++-header-preprocessing", |
| 1203 | ACTION_NAMES.cpp_module_compile, |
| 1204 | ], |
| 1205 | flag_groups = [flag_group(flags = ["-std=gnu++1z"])], |
| 1206 | ), |
| 1207 | ], |
| 1208 | ) |
| 1209 | else: |
| 1210 | all_modes_feature = None |
| 1211 | |
| 1212 | supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) |
| 1213 | |
| 1214 | if (ctx.attr.cpu == "k8"): |
| 1215 | unfiltered_compile_flags_feature = feature( |
| 1216 | name = "unfiltered_compile_flags", |
| 1217 | enabled = True, |
| 1218 | flag_sets = [ |
| 1219 | flag_set( |
| 1220 | actions = [ |
| 1221 | ACTION_NAMES.assemble, |
| 1222 | ACTION_NAMES.preprocess_assemble, |
| 1223 | ACTION_NAMES.linkstamp_compile, |
| 1224 | ACTION_NAMES.c_compile, |
| 1225 | ACTION_NAMES.cpp_compile, |
| 1226 | ACTION_NAMES.cpp_header_parsing, |
| 1227 | ACTION_NAMES.cpp_module_compile, |
| 1228 | ACTION_NAMES.cpp_module_codegen, |
| 1229 | ACTION_NAMES.lto_backend, |
| 1230 | ACTION_NAMES.clif_match, |
| 1231 | ], |
| 1232 | flag_groups = [ |
| 1233 | flag_group( |
| 1234 | flags = [ |
| 1235 | "-no-canonical-prefixes", |
| 1236 | "-Wno-builtin-macro-redefined", |
| 1237 | "-D__DATE__=\"redacted\"", |
| 1238 | "-D__TIMESTAMP__=\"redacted\"", |
| 1239 | "-D__TIME__=\"redacted\"", |
| 1240 | "-Wno-varargs", |
| 1241 | "-Wno-null-pointer-arithmetic", |
| 1242 | "-Wno-mismatched-new-delete", |
| 1243 | ], |
| 1244 | ), |
| 1245 | ], |
| 1246 | ), |
| 1247 | ], |
| 1248 | ) |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1249 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 1250 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 1251 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1252 | unfiltered_compile_flags_feature = feature( |
| 1253 | name = "unfiltered_compile_flags", |
| 1254 | enabled = True, |
| 1255 | flag_sets = [ |
| 1256 | flag_set( |
| 1257 | actions = [ |
| 1258 | ACTION_NAMES.assemble, |
| 1259 | ACTION_NAMES.preprocess_assemble, |
| 1260 | ACTION_NAMES.linkstamp_compile, |
| 1261 | ACTION_NAMES.c_compile, |
| 1262 | ACTION_NAMES.cpp_compile, |
| 1263 | ACTION_NAMES.cpp_header_parsing, |
| 1264 | ACTION_NAMES.cpp_module_compile, |
| 1265 | ACTION_NAMES.cpp_module_codegen, |
| 1266 | ACTION_NAMES.lto_backend, |
| 1267 | ACTION_NAMES.clif_match, |
| 1268 | ], |
| 1269 | flag_groups = [ |
| 1270 | flag_group( |
| 1271 | flags = [ |
| 1272 | "-no-canonical-prefixes", |
| 1273 | "-Wno-builtin-macro-redefined", |
| 1274 | "-D__DATE__=\"redacted\"", |
| 1275 | "-D__TIMESTAMP__=\"redacted\"", |
| 1276 | "-D__TIME__=\"redacted\"", |
| 1277 | ], |
| 1278 | ), |
| 1279 | ], |
| 1280 | ), |
| 1281 | ], |
| 1282 | ) |
| 1283 | elif (ctx.attr.cpu == "armhf-debian"): |
| 1284 | unfiltered_compile_flags_feature = feature( |
| 1285 | name = "unfiltered_compile_flags", |
| 1286 | enabled = True, |
| 1287 | flag_sets = [ |
| 1288 | flag_set( |
| 1289 | actions = [ |
| 1290 | ACTION_NAMES.assemble, |
| 1291 | ACTION_NAMES.preprocess_assemble, |
| 1292 | ACTION_NAMES.linkstamp_compile, |
| 1293 | ACTION_NAMES.c_compile, |
| 1294 | ACTION_NAMES.cpp_compile, |
| 1295 | ACTION_NAMES.cpp_header_parsing, |
| 1296 | ACTION_NAMES.cpp_module_compile, |
| 1297 | ACTION_NAMES.cpp_module_codegen, |
| 1298 | ACTION_NAMES.lto_backend, |
| 1299 | ACTION_NAMES.clif_match, |
| 1300 | ], |
| 1301 | flag_groups = [ |
| 1302 | flag_group( |
| 1303 | flags = [ |
| 1304 | "-no-canonical-prefixes", |
| 1305 | "-Wno-builtin-macro-redefined", |
| 1306 | "-Wno-mismatched-new-delete", |
| 1307 | "-Wno-null-pointer-arithmetic", |
| 1308 | "-Wno-varargs", |
| 1309 | "-D__DATE__=\"redacted\"", |
| 1310 | "-D__TIMESTAMP__=\"redacted\"", |
| 1311 | "-D__TIME__=\"redacted\"", |
| 1312 | ], |
| 1313 | ), |
| 1314 | ], |
| 1315 | ), |
| 1316 | ], |
| 1317 | ) |
| 1318 | else: |
| 1319 | unfiltered_compile_flags_feature = None |
| 1320 | |
| 1321 | dependency_file_feature = feature( |
| 1322 | name = "dependency_file", |
| 1323 | enabled = True, |
| 1324 | flag_sets = [ |
| 1325 | flag_set( |
| 1326 | actions = [ |
| 1327 | ACTION_NAMES.assemble, |
| 1328 | ACTION_NAMES.preprocess_assemble, |
| 1329 | ACTION_NAMES.c_compile, |
| 1330 | ACTION_NAMES.cpp_compile, |
| 1331 | ACTION_NAMES.cpp_module_compile, |
| 1332 | ACTION_NAMES.objc_compile, |
| 1333 | ACTION_NAMES.objcpp_compile, |
| 1334 | ACTION_NAMES.cpp_header_parsing, |
| 1335 | ACTION_NAMES.clif_match, |
| 1336 | ], |
| 1337 | flag_groups = [ |
| 1338 | flag_group( |
| 1339 | flags = ["-MD", "-MF", "%{dependency_file}"], |
| 1340 | expand_if_available = "dependency_file", |
| 1341 | ), |
| 1342 | ], |
| 1343 | ), |
| 1344 | ], |
| 1345 | ) |
| 1346 | |
| 1347 | objcopy_embed_flags_feature = feature( |
| 1348 | name = "objcopy_embed_flags", |
| 1349 | enabled = True, |
| 1350 | flag_sets = [ |
| 1351 | flag_set( |
| 1352 | actions = ["objcopy_embed_data"], |
| 1353 | flag_groups = [flag_group(flags = ["-I", "binary"])], |
| 1354 | ), |
| 1355 | ], |
| 1356 | ) |
| 1357 | |
| 1358 | user_compile_flags_feature = feature( |
| 1359 | name = "user_compile_flags", |
| 1360 | enabled = True, |
| 1361 | flag_sets = [ |
| 1362 | flag_set( |
| 1363 | actions = [ |
| 1364 | ACTION_NAMES.assemble, |
| 1365 | ACTION_NAMES.preprocess_assemble, |
| 1366 | ACTION_NAMES.linkstamp_compile, |
| 1367 | ACTION_NAMES.c_compile, |
| 1368 | ACTION_NAMES.cpp_compile, |
| 1369 | ACTION_NAMES.cpp_header_parsing, |
| 1370 | ACTION_NAMES.cpp_module_compile, |
| 1371 | ACTION_NAMES.cpp_module_codegen, |
| 1372 | ACTION_NAMES.lto_backend, |
| 1373 | ACTION_NAMES.clif_match, |
| 1374 | ], |
| 1375 | flag_groups = [ |
| 1376 | flag_group( |
| 1377 | flags = ["%{user_compile_flags}"], |
| 1378 | iterate_over = "user_compile_flags", |
| 1379 | expand_if_available = "user_compile_flags", |
| 1380 | ), |
| 1381 | ], |
| 1382 | ), |
| 1383 | ], |
| 1384 | ) |
| 1385 | |
| 1386 | sysroot_feature = feature( |
| 1387 | name = "sysroot", |
| 1388 | enabled = True, |
| 1389 | flag_sets = [ |
| 1390 | flag_set( |
| 1391 | actions = [ |
| 1392 | ACTION_NAMES.preprocess_assemble, |
| 1393 | ACTION_NAMES.linkstamp_compile, |
| 1394 | ACTION_NAMES.c_compile, |
| 1395 | ACTION_NAMES.cpp_compile, |
| 1396 | ACTION_NAMES.cpp_header_parsing, |
| 1397 | ACTION_NAMES.cpp_module_compile, |
| 1398 | ACTION_NAMES.cpp_module_codegen, |
| 1399 | ACTION_NAMES.lto_backend, |
| 1400 | ACTION_NAMES.clif_match, |
| 1401 | ACTION_NAMES.cpp_link_executable, |
| 1402 | ACTION_NAMES.cpp_link_dynamic_library, |
| 1403 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 1404 | ], |
| 1405 | flag_groups = [ |
| 1406 | flag_group( |
| 1407 | flags = ["--sysroot=%{sysroot}"], |
| 1408 | expand_if_available = "sysroot", |
| 1409 | ), |
| 1410 | ], |
| 1411 | ), |
| 1412 | ], |
| 1413 | ) |
| 1414 | |
| 1415 | compile_flags1_feature = feature( |
| 1416 | name = "compile_flags1", |
| 1417 | enabled = True, |
| 1418 | flag_sets = [ |
| 1419 | flag_set( |
| 1420 | actions = [ |
| 1421 | ACTION_NAMES.assemble, |
| 1422 | ACTION_NAMES.preprocess_assemble, |
| 1423 | ACTION_NAMES.c_compile, |
| 1424 | ACTION_NAMES.cpp_compile, |
| 1425 | ACTION_NAMES.cpp_header_parsing, |
| 1426 | ACTION_NAMES.cpp_module_compile, |
| 1427 | ACTION_NAMES.cpp_module_codegen, |
| 1428 | ACTION_NAMES.lto_backend, |
| 1429 | ACTION_NAMES.clif_match, |
| 1430 | ], |
| 1431 | flag_groups = [ |
| 1432 | flag_group( |
| 1433 | flags = [ |
| 1434 | "--sysroot=external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi", |
| 1435 | "-nostdinc", |
| 1436 | "-isystem", |
| 1437 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include", |
| 1438 | "-isystem", |
| 1439 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include-fixed", |
| 1440 | ], |
| 1441 | ), |
| 1442 | ], |
| 1443 | ), |
| 1444 | flag_set( |
| 1445 | actions = [ |
| 1446 | ACTION_NAMES.assemble, |
| 1447 | ACTION_NAMES.preprocess_assemble, |
| 1448 | ACTION_NAMES.cpp_compile, |
| 1449 | ACTION_NAMES.cpp_header_parsing, |
| 1450 | "c++-header-preprocessing", |
| 1451 | ], |
| 1452 | flag_groups = [flag_group(flags = ["-fno-canonical-system-headers"])], |
| 1453 | ), |
| 1454 | flag_set( |
| 1455 | actions = [ |
| 1456 | ACTION_NAMES.cpp_compile, |
| 1457 | ACTION_NAMES.cpp_header_parsing, |
| 1458 | ACTION_NAMES.cpp_module_compile, |
| 1459 | ACTION_NAMES.cpp_module_codegen, |
| 1460 | ], |
| 1461 | flag_groups = [ |
| 1462 | flag_group( |
| 1463 | flags = [ |
| 1464 | "-isystem", |
| 1465 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0", |
| 1466 | "-isystem", |
| 1467 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/arm-frc2020-linux-gnueabi", |
| 1468 | "-isystem", |
| 1469 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/backward", |
| 1470 | ], |
| 1471 | ), |
| 1472 | ], |
| 1473 | ), |
| 1474 | flag_set( |
| 1475 | actions = [ |
| 1476 | ACTION_NAMES.assemble, |
| 1477 | ACTION_NAMES.preprocess_assemble, |
| 1478 | ACTION_NAMES.c_compile, |
| 1479 | ACTION_NAMES.cpp_compile, |
| 1480 | ACTION_NAMES.cpp_header_parsing, |
| 1481 | ACTION_NAMES.cpp_module_compile, |
| 1482 | ACTION_NAMES.cpp_module_codegen, |
| 1483 | ACTION_NAMES.lto_backend, |
| 1484 | ACTION_NAMES.clif_match, |
| 1485 | ], |
| 1486 | flag_groups = [ |
| 1487 | flag_group( |
| 1488 | flags = [ |
| 1489 | "-isystem", |
| 1490 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include", |
| 1491 | "-mfpu=neon", |
| 1492 | "-D__STDC_FORMAT_MACROS", |
| 1493 | "-D__STDC_CONSTANT_MACROS", |
| 1494 | "-D__STDC_LIMIT_MACROS", |
| 1495 | "-D_FILE_OFFSET_BITS=64", |
| 1496 | "-DAOS_ARCHITECTURE_arm_frc", |
| 1497 | "-U_FORTIFY_SOURCE", |
| 1498 | "-fstack-protector", |
| 1499 | "-fPIE", |
| 1500 | "-fdiagnostics-color=always", |
| 1501 | "-Wall", |
| 1502 | "-Wextra", |
| 1503 | "-Wpointer-arith", |
| 1504 | "-Wstrict-aliasing", |
| 1505 | "-Wcast-qual", |
| 1506 | "-Wwrite-strings", |
| 1507 | "-Wtype-limits", |
| 1508 | "-Wsign-compare", |
| 1509 | "-Wformat=2", |
| 1510 | "-Werror", |
| 1511 | "-Wunused-local-typedefs", |
| 1512 | "-Wno-psabi", |
| 1513 | "-fno-omit-frame-pointer", |
| 1514 | "-D__has_feature(x)=0", |
| 1515 | "-pipe", |
| 1516 | "-ggdb3", |
| 1517 | ], |
| 1518 | ), |
| 1519 | ], |
| 1520 | ), |
| 1521 | ], |
| 1522 | ) |
| 1523 | |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1524 | if (ctx.attr.cpu == "cortex-m4f" or |
| 1525 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1526 | features = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1527 | default_compile_flags_feature, |
| 1528 | default_link_flags_feature, |
| 1529 | dbg_feature, |
| 1530 | opt_feature, |
| 1531 | fastbuild_feature, |
| 1532 | all_modes_feature, |
| 1533 | include_paths_feature, |
| 1534 | objcopy_embed_flags_feature, |
| 1535 | user_compile_flags_feature, |
| 1536 | sysroot_feature, |
| 1537 | unfiltered_compile_flags_feature, |
| 1538 | ] |
| 1539 | elif (ctx.attr.cpu == "armhf-debian" or |
| 1540 | ctx.attr.cpu == "k8"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1541 | features = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1542 | default_compile_flags_feature, |
| 1543 | default_link_flags_feature, |
| 1544 | opt_feature, |
| 1545 | dbg_feature, |
| 1546 | fastbuild_feature, |
| 1547 | all_modes_feature, |
| 1548 | pie_for_linking_feature, |
| 1549 | supports_dynamic_linker_feature, |
| 1550 | supports_pic_feature, |
| 1551 | objcopy_embed_flags_feature, |
| 1552 | user_compile_flags_feature, |
| 1553 | sysroot_feature, |
| 1554 | unfiltered_compile_flags_feature, |
| 1555 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1556 | elif (ctx.attr.cpu == "roborio"): |
| 1557 | features = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1558 | default_link_flags_feature, |
| 1559 | compile_flags1_feature, |
| 1560 | opt_feature, |
| 1561 | dependency_file_feature, |
| 1562 | random_seed_feature, |
| 1563 | pic_feature, |
| 1564 | include_paths_feature, |
| 1565 | opt_post_feature, |
| 1566 | dbg_feature, |
| 1567 | fastbuild_feature, |
| 1568 | all_modes_feature, |
| 1569 | pie_for_linking_feature, |
| 1570 | supports_dynamic_linker_feature, |
| 1571 | supports_pic_feature, |
| 1572 | objcopy_embed_flags_feature, |
| 1573 | user_compile_flags_feature, |
| 1574 | sysroot_feature, |
| 1575 | unfiltered_compile_flags_feature, |
| 1576 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1577 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 1578 | features = [supports_pic_feature] |
| 1579 | else: |
| 1580 | fail("Unreachable") |
| 1581 | |
| 1582 | if (ctx.attr.cpu == "armeabi-v7a"): |
| 1583 | cxx_builtin_include_directories = [] |
| 1584 | elif (ctx.attr.cpu == "roborio"): |
| 1585 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1586 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include)%", |
| 1587 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include-fixed)%", |
| 1588 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/arm-frc2020-linux-gnueabi)%", |
| 1589 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/backward)%", |
| 1590 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1591 | elif (ctx.attr.cpu == "k8"): |
| 1592 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1593 | "%package(@clang_6p0_repo//usr)%/lib/llvm-6.0/lib/clang/6.0.0/include", |
| 1594 | "%package(@amd64_debian_sysroot//usr)%/include", |
| 1595 | "%package(@amd64_debian_sysroot//usr)%/lib/gcc/x86_64-linux-gnu/7/include", |
| 1596 | "%package(@amd64_debian_sysroot//usr)%/lib/gcc/x86_64-linux-gnu/7/include-fixed", |
| 1597 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1598 | elif (ctx.attr.cpu == "armhf-debian"): |
| 1599 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1600 | "%package(@linaro_linux_gcc_repo//include)%", |
| 1601 | "%package(@armhf_debian_rootfs//usr/include)%", |
| 1602 | "%package(@linaro_linux_gcc_repo//include)%/c++/7.4.1", |
| 1603 | "%package(@linaro_linux_gcc_repo//lib/gcc/arm-linux-gnueabihf/7.4.1/include)%", |
| 1604 | "%package(@linaro_linux_gcc_repo//lib/gcc/arm-linux-gnueabihf/7.4.1/include-fixed)%", |
| 1605 | "%package(@linaro_linux_gcc_repo//arm-linux-gnueabihf/include)%/c++/7.4.1", |
| 1606 | ] |
| 1607 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 1608 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1609 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1610 | "/usr/lib/gcc/arm-none-eabi/4.8/include", |
| 1611 | "/usr/lib/gcc/arm-none-eabi/4.8/include-fixed", |
| 1612 | "/usr/lib/arm-none-eabi/include", |
| 1613 | "/usr/include/newlib", |
| 1614 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1615 | else: |
| 1616 | fail("Unreachable") |
| 1617 | |
| 1618 | artifact_name_patterns = [] |
| 1619 | |
| 1620 | make_variables = [] |
| 1621 | |
| 1622 | if (ctx.attr.cpu == "roborio"): |
| 1623 | tool_paths = [ |
| 1624 | tool_path( |
| 1625 | name = "ar", |
| 1626 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ar", |
| 1627 | ), |
| 1628 | tool_path( |
| 1629 | name = "as", |
| 1630 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-as", |
| 1631 | ), |
| 1632 | tool_path( |
| 1633 | name = "compat-ld", |
| 1634 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ld", |
| 1635 | ), |
| 1636 | tool_path( |
| 1637 | name = "cpp", |
| 1638 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-cpp", |
| 1639 | ), |
| 1640 | tool_path(name = "dwp", path = "/bin/false"), |
| 1641 | tool_path( |
| 1642 | name = "gcc", |
| 1643 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcc", |
| 1644 | ), |
| 1645 | tool_path( |
| 1646 | name = "gcov", |
| 1647 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9", |
| 1648 | ), |
| 1649 | tool_path( |
| 1650 | name = "ld", |
| 1651 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ld", |
| 1652 | ), |
| 1653 | tool_path( |
| 1654 | name = "nm", |
| 1655 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-nm", |
| 1656 | ), |
| 1657 | tool_path( |
| 1658 | name = "objcopy", |
| 1659 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objcopy", |
| 1660 | ), |
| 1661 | tool_path( |
| 1662 | name = "objdump", |
| 1663 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objdump", |
| 1664 | ), |
| 1665 | tool_path( |
| 1666 | name = "strip", |
| 1667 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-strip", |
| 1668 | ), |
| 1669 | ] |
| 1670 | elif (ctx.attr.cpu == "k8"): |
| 1671 | tool_paths = [ |
| 1672 | tool_path( |
| 1673 | name = "ar", |
| 1674 | path = "clang_6p0/x86_64-linux-gnu-ar", |
| 1675 | ), |
| 1676 | tool_path( |
| 1677 | name = "compat-ld", |
| 1678 | path = "clang_6p0/x86_64-linux-gnu-ld", |
| 1679 | ), |
| 1680 | tool_path( |
| 1681 | name = "cpp", |
| 1682 | path = "clang_6p0/x86_64-linux-gnu-cpp", |
| 1683 | ), |
| 1684 | tool_path( |
| 1685 | name = "dwp", |
| 1686 | path = "clang_6p0/x86_64-linux-gnu-dwp", |
| 1687 | ), |
| 1688 | tool_path( |
| 1689 | name = "gcc", |
| 1690 | path = "clang_6p0/x86_64-linux-gnu-clang-6.0", |
| 1691 | ), |
| 1692 | tool_path( |
| 1693 | name = "gcov", |
| 1694 | path = "clang_6p0/x86_64-linux-gnu-gcov", |
| 1695 | ), |
| 1696 | tool_path( |
| 1697 | name = "ld", |
| 1698 | path = "clang_6p0/x86_64-linux-gnu-ld", |
| 1699 | ), |
| 1700 | tool_path( |
| 1701 | name = "nm", |
| 1702 | path = "clang_6p0/x86_64-linux-gnu-nm", |
| 1703 | ), |
| 1704 | tool_path( |
| 1705 | name = "objcopy", |
| 1706 | path = "clang_6p0/x86_64-linux-gnu-objcopy", |
| 1707 | ), |
| 1708 | tool_path( |
| 1709 | name = "objdump", |
| 1710 | path = "clang_6p0/x86_64-linux-gnu-objdump", |
| 1711 | ), |
| 1712 | tool_path( |
| 1713 | name = "strip", |
| 1714 | path = "clang_6p0/x86_64-linux-gnu-strip", |
| 1715 | ), |
| 1716 | ] |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1717 | elif (ctx.attr.cpu == "cortex-m4f" or |
| 1718 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1719 | tool_paths = [ |
| 1720 | tool_path( |
| 1721 | name = "ar", |
| 1722 | path = "gcc_arm_none_eabi/arm-none-eabi-ar", |
| 1723 | ), |
| 1724 | tool_path( |
| 1725 | name = "compat-ld", |
| 1726 | path = "gcc_arm_none_eabi/arm-none-eabi-ld", |
| 1727 | ), |
| 1728 | tool_path( |
| 1729 | name = "cpp", |
| 1730 | path = "gcc_arm_none_eabi/arm-none-eabi-cpp", |
| 1731 | ), |
| 1732 | tool_path( |
| 1733 | name = "dwp", |
| 1734 | path = "gcc_arm_none_eabi/arm-none-eabi-dwp", |
| 1735 | ), |
| 1736 | tool_path( |
| 1737 | name = "gcc", |
| 1738 | path = "gcc_arm_none_eabi/arm-none-eabi-gcc", |
| 1739 | ), |
| 1740 | tool_path( |
| 1741 | name = "gcov", |
| 1742 | path = "gcc_arm_none_eabi/arm-none-eabi-gcov", |
| 1743 | ), |
| 1744 | tool_path( |
| 1745 | name = "ld", |
| 1746 | path = "gcc_arm_none_eabi/arm-none-eabi-ld", |
| 1747 | ), |
| 1748 | tool_path( |
| 1749 | name = "nm", |
| 1750 | path = "gcc_arm_none_eabi/arm-none-eabi-nm", |
| 1751 | ), |
| 1752 | tool_path( |
| 1753 | name = "objcopy", |
| 1754 | path = "gcc_arm_none_eabi/arm-none-eabi-objcopy", |
| 1755 | ), |
| 1756 | tool_path( |
| 1757 | name = "objdump", |
| 1758 | path = "gcc_arm_none_eabi/arm-none-eabi-objdump", |
| 1759 | ), |
| 1760 | tool_path( |
| 1761 | name = "strip", |
| 1762 | path = "gcc_arm_none_eabi/arm-none-eabi-strip", |
| 1763 | ), |
| 1764 | ] |
| 1765 | elif (ctx.attr.cpu == "armhf-debian"): |
| 1766 | tool_paths = [ |
| 1767 | tool_path( |
| 1768 | name = "ar", |
| 1769 | path = "linaro_linux_gcc/arm-linux-gnueabihf-ar", |
| 1770 | ), |
| 1771 | tool_path( |
| 1772 | name = "compat-ld", |
| 1773 | path = "linaro_linux_gcc/arm-linux-gnueabihf-ld", |
| 1774 | ), |
| 1775 | tool_path( |
| 1776 | name = "cpp", |
| 1777 | path = "linaro_linux_gcc/clang_bin/clang", |
| 1778 | ), |
| 1779 | tool_path( |
| 1780 | name = "dwp", |
| 1781 | path = "linaro_linux_gcc/arm-linux-gnueabihf-dwp", |
| 1782 | ), |
| 1783 | tool_path( |
| 1784 | name = "gcc", |
| 1785 | path = "linaro_linux_gcc/clang_bin/clang", |
| 1786 | ), |
| 1787 | tool_path( |
| 1788 | name = "gcov", |
| 1789 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9", |
| 1790 | ), |
| 1791 | tool_path( |
| 1792 | name = "ld", |
| 1793 | path = "linaro_linux_gcc/arm-linux-gnueabihf-ld", |
| 1794 | ), |
| 1795 | tool_path( |
| 1796 | name = "nm", |
| 1797 | path = "linaro_linux_gcc/arm-linux-gnueabihf-nm", |
| 1798 | ), |
| 1799 | tool_path( |
| 1800 | name = "objcopy", |
| 1801 | path = "linaro_linux_gcc/arm-linux-gnueabihf-objcopy", |
| 1802 | ), |
| 1803 | tool_path( |
| 1804 | name = "objdump", |
| 1805 | path = "linaro_linux_gcc/arm-linux-gnueabihf-objdump", |
| 1806 | ), |
| 1807 | tool_path( |
| 1808 | name = "strip", |
| 1809 | path = "linaro_linux_gcc/arm-linux-gnueabihf-strip", |
| 1810 | ), |
| 1811 | ] |
| 1812 | elif (ctx.attr.cpu == "armeabi-v7a"): |
| 1813 | tool_paths = [ |
| 1814 | tool_path(name = "ar", path = "/bin/false"), |
| 1815 | tool_path(name = "compat-ld", path = "/bin/false"), |
| 1816 | tool_path(name = "cpp", path = "/bin/false"), |
| 1817 | tool_path(name = "dwp", path = "/bin/false"), |
| 1818 | tool_path(name = "gcc", path = "/bin/false"), |
| 1819 | tool_path(name = "gcov", path = "/bin/false"), |
| 1820 | tool_path(name = "ld", path = "/bin/false"), |
| 1821 | tool_path(name = "nm", path = "/bin/false"), |
| 1822 | tool_path(name = "objcopy", path = "/bin/false"), |
| 1823 | tool_path(name = "objdump", path = "/bin/false"), |
| 1824 | tool_path(name = "strip", path = "/bin/false"), |
| 1825 | ] |
| 1826 | else: |
| 1827 | fail("Unreachable") |
| 1828 | |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1829 | out = ctx.actions.declare_file(ctx.label.name) |
| 1830 | ctx.actions.write(out, "Fake executable") |
| 1831 | return [ |
| 1832 | cc_common.create_cc_toolchain_config_info( |
| 1833 | ctx = ctx, |
| 1834 | features = features, |
| 1835 | action_configs = action_configs, |
| 1836 | artifact_name_patterns = artifact_name_patterns, |
| 1837 | cxx_builtin_include_directories = cxx_builtin_include_directories, |
| 1838 | toolchain_identifier = toolchain_identifier, |
| 1839 | host_system_name = host_system_name, |
| 1840 | target_system_name = target_system_name, |
| 1841 | target_cpu = target_cpu, |
| 1842 | target_libc = target_libc, |
| 1843 | compiler = compiler, |
| 1844 | abi_version = abi_version, |
| 1845 | abi_libc_version = abi_libc_version, |
| 1846 | tool_paths = tool_paths, |
| 1847 | make_variables = make_variables, |
| 1848 | builtin_sysroot = builtin_sysroot, |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1849 | cc_target_os = cc_target_os, |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1850 | ), |
| 1851 | DefaultInfo( |
| 1852 | executable = out, |
| 1853 | ), |
| 1854 | ] |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1855 | |
| 1856 | cc_toolchain_config = rule( |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1857 | implementation = _impl, |
| 1858 | attrs = { |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1859 | "cpu": attr.string(mandatory = True, values = ["armeabi-v7a", "armhf-debian", "cortex-m4f", "cortex-m4f-k22", "k8", "roborio"]), |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1860 | }, |
| 1861 | provides = [CcToolchainConfigInfo], |
| 1862 | executable = True, |
| 1863 | ) |