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