1# Copyright 2019 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""A Starlark cc_toolchain configuration rule""" 16 17load( 18 "@rules_cc//cc:action_names.bzl", 19 _ASSEMBLE_ACTION_NAME = "ASSEMBLE_ACTION_NAME", 20 _CLIF_MATCH_ACTION_NAME = "CLIF_MATCH_ACTION_NAME", 21 _CPP_COMPILE_ACTION_NAME = "CPP_COMPILE_ACTION_NAME", 22 _CPP_HEADER_PARSING_ACTION_NAME = "CPP_HEADER_PARSING_ACTION_NAME", 23 _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME", 24 _CPP_LINK_EXECUTABLE_ACTION_NAME = "CPP_LINK_EXECUTABLE_ACTION_NAME", 25 _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME = "CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME", 26 _CPP_MODULE_CODEGEN_ACTION_NAME = "CPP_MODULE_CODEGEN_ACTION_NAME", 27 _CPP_MODULE_COMPILE_ACTION_NAME = "CPP_MODULE_COMPILE_ACTION_NAME", 28 _C_COMPILE_ACTION_NAME = "C_COMPILE_ACTION_NAME", 29 _LINKSTAMP_COMPILE_ACTION_NAME = "LINKSTAMP_COMPILE_ACTION_NAME", 30 _LTO_BACKEND_ACTION_NAME = "LTO_BACKEND_ACTION_NAME", 31 _PREPROCESS_ASSEMBLE_ACTION_NAME = "PREPROCESS_ASSEMBLE_ACTION_NAME", 32) 33load( 34 "@rules_cc//cc:cc_toolchain_config_lib.bzl", 35 "action_config", 36 "feature", 37 "flag_group", 38 "flag_set", 39 "tool", 40 "tool_path", 41 "with_feature_set", 42) 43 44all_compile_actions = [ 45 _C_COMPILE_ACTION_NAME, 46 _CPP_COMPILE_ACTION_NAME, 47 _LINKSTAMP_COMPILE_ACTION_NAME, 48 _ASSEMBLE_ACTION_NAME, 49 _PREPROCESS_ASSEMBLE_ACTION_NAME, 50 _CPP_HEADER_PARSING_ACTION_NAME, 51 _CPP_MODULE_COMPILE_ACTION_NAME, 52 _CPP_MODULE_CODEGEN_ACTION_NAME, 53 _CLIF_MATCH_ACTION_NAME, 54 _LTO_BACKEND_ACTION_NAME, 55] 56 57all_cpp_compile_actions = [ 58 _CPP_COMPILE_ACTION_NAME, 59 _LINKSTAMP_COMPILE_ACTION_NAME, 60 _CPP_HEADER_PARSING_ACTION_NAME, 61 _CPP_MODULE_COMPILE_ACTION_NAME, 62 _CPP_MODULE_CODEGEN_ACTION_NAME, 63 _CLIF_MATCH_ACTION_NAME, 64] 65 66preprocessor_compile_actions = [ 67 _C_COMPILE_ACTION_NAME, 68 _CPP_COMPILE_ACTION_NAME, 69 _LINKSTAMP_COMPILE_ACTION_NAME, 70 _PREPROCESS_ASSEMBLE_ACTION_NAME, 71 _CPP_HEADER_PARSING_ACTION_NAME, 72 _CPP_MODULE_COMPILE_ACTION_NAME, 73 _CLIF_MATCH_ACTION_NAME, 74] 75 76codegen_compile_actions = [ 77 _C_COMPILE_ACTION_NAME, 78 _CPP_COMPILE_ACTION_NAME, 79 _LINKSTAMP_COMPILE_ACTION_NAME, 80 _ASSEMBLE_ACTION_NAME, 81 _PREPROCESS_ASSEMBLE_ACTION_NAME, 82 _CPP_MODULE_CODEGEN_ACTION_NAME, 83 _LTO_BACKEND_ACTION_NAME, 84] 85 86all_link_actions = [ 87 _CPP_LINK_EXECUTABLE_ACTION_NAME, 88 _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, 89 _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, 90] 91 92def _impl(ctx): 93 if ctx.attr.disable_static_cc_toolchains: 94 fail("@rules_cc//cc/private/toolchain:default-toolchain, as well as the cc_toolchains it points " + 95 "to have been removed. See https://github.com/bazelbuild/bazel/issues/8546.") 96 97 if (ctx.attr.cpu == "darwin"): 98 toolchain_identifier = "local_darwin" 99 elif (ctx.attr.cpu == "freebsd"): 100 toolchain_identifier = "local_freebsd" 101 elif (ctx.attr.cpu == "local"): 102 toolchain_identifier = "local_linux" 103 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): 104 toolchain_identifier = "local_windows_clang" 105 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): 106 toolchain_identifier = "local_windows_mingw" 107 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 108 toolchain_identifier = "local_windows_msys64" 109 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 110 toolchain_identifier = "local_windows_msys64_mingw64" 111 elif (ctx.attr.cpu == "armeabi-v7a"): 112 toolchain_identifier = "stub_armeabi-v7a" 113 elif (ctx.attr.cpu == "x64_windows_msvc"): 114 toolchain_identifier = "vc_14_0_x64" 115 else: 116 fail("Unreachable") 117 118 if (ctx.attr.cpu == "armeabi-v7a"): 119 host_system_name = "armeabi-v7a" 120 elif (ctx.attr.cpu == "darwin" or 121 ctx.attr.cpu == "freebsd" or 122 ctx.attr.cpu == "local" or 123 ctx.attr.cpu == "x64_windows" or 124 ctx.attr.cpu == "x64_windows_msvc"): 125 host_system_name = "local" 126 else: 127 fail("Unreachable") 128 129 if (ctx.attr.cpu == "armeabi-v7a"): 130 target_system_name = "armeabi-v7a" 131 elif (ctx.attr.cpu == "darwin" or 132 ctx.attr.cpu == "freebsd" or 133 ctx.attr.cpu == "local" or 134 ctx.attr.cpu == "x64_windows" or 135 ctx.attr.cpu == "x64_windows_msvc"): 136 target_system_name = "local" 137 else: 138 fail("Unreachable") 139 140 if (ctx.attr.cpu == "armeabi-v7a"): 141 target_cpu = "armeabi-v7a" 142 elif (ctx.attr.cpu == "darwin"): 143 target_cpu = "darwin" 144 elif (ctx.attr.cpu == "freebsd"): 145 target_cpu = "freebsd" 146 elif (ctx.attr.cpu == "local"): 147 target_cpu = "local" 148 elif (ctx.attr.cpu == "x64_windows"): 149 target_cpu = "x64_windows" 150 elif (ctx.attr.cpu == "x64_windows_msvc"): 151 target_cpu = "x64_windows_msvc" 152 else: 153 fail("Unreachable") 154 155 if (ctx.attr.cpu == "armeabi-v7a"): 156 target_libc = "armeabi-v7a" 157 elif (ctx.attr.cpu == "freebsd" or 158 ctx.attr.cpu == "local" or 159 ctx.attr.cpu == "x64_windows"): 160 target_libc = "local" 161 elif (ctx.attr.cpu == "darwin"): 162 target_libc = "macosx" 163 elif (ctx.attr.cpu == "x64_windows_msvc"): 164 target_libc = "msvcrt140" 165 else: 166 fail("Unreachable") 167 168 if (ctx.attr.cpu == "x64_windows_msvc"): 169 compiler = "cl" 170 elif (ctx.attr.cpu == "armeabi-v7a" or 171 ctx.attr.cpu == "darwin" or 172 ctx.attr.cpu == "freebsd" or 173 ctx.attr.cpu == "local"): 174 compiler = "compiler" 175 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): 176 compiler = "windows_clang" 177 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): 178 compiler = "windows_mingw" 179 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 180 compiler = "windows_msys64" 181 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 182 compiler = "windows_msys64_mingw64" 183 else: 184 fail("Unreachable") 185 186 if (ctx.attr.cpu == "armeabi-v7a"): 187 abi_version = "armeabi-v7a" 188 elif (ctx.attr.cpu == "darwin" or 189 ctx.attr.cpu == "freebsd" or 190 ctx.attr.cpu == "local" or 191 ctx.attr.cpu == "x64_windows" or 192 ctx.attr.cpu == "x64_windows_msvc"): 193 abi_version = "local" 194 else: 195 fail("Unreachable") 196 197 if (ctx.attr.cpu == "armeabi-v7a"): 198 abi_libc_version = "armeabi-v7a" 199 elif (ctx.attr.cpu == "darwin" or 200 ctx.attr.cpu == "freebsd" or 201 ctx.attr.cpu == "local" or 202 ctx.attr.cpu == "x64_windows" or 203 ctx.attr.cpu == "x64_windows_msvc"): 204 abi_libc_version = "local" 205 else: 206 fail("Unreachable") 207 208 cc_target_os = None 209 210 builtin_sysroot = None 211 212 objcopy_embed_data_action = None 213 if (ctx.attr.cpu == "darwin" or 214 ctx.attr.cpu == "freebsd" or 215 ctx.attr.cpu == "local"): 216 objcopy_embed_data_action = action_config( 217 action_name = "objcopy_embed_data", 218 enabled = True, 219 tools = [tool(path = "/usr/bin/objcopy")], 220 ) 221 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): 222 objcopy_embed_data_action = action_config( 223 action_name = "objcopy_embed_data", 224 enabled = True, 225 tools = [tool(path = "C:/Program Files (x86)/LLVM/bin/objcopy")], 226 ) 227 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): 228 objcopy_embed_data_action = action_config( 229 action_name = "objcopy_embed_data", 230 enabled = True, 231 tools = [tool(path = "C:/mingw/bin/objcopy")], 232 ) 233 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 234 objcopy_embed_data_action = action_config( 235 action_name = "objcopy_embed_data", 236 enabled = True, 237 tools = [tool(path = "C:/tools/msys64/mingw64/bin/objcopy")], 238 ) 239 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 240 objcopy_embed_data_action = action_config( 241 action_name = "objcopy_embed_data", 242 enabled = True, 243 tools = [tool(path = "C:/tools/msys64/usr/bin/objcopy")], 244 ) 245 246 c_compile_action = action_config( 247 action_name = _C_COMPILE_ACTION_NAME, 248 implies = [ 249 "compiler_input_flags", 250 "compiler_output_flags", 251 "default_compile_flags", 252 "user_compile_flags", 253 "sysroot", 254 "unfiltered_compile_flags", 255 ], 256 tools = [tool(path = "wrapper/bin/msvc_cl.bat")], 257 ) 258 259 cpp_compile_action = action_config( 260 action_name = _CPP_COMPILE_ACTION_NAME, 261 implies = [ 262 "compiler_input_flags", 263 "compiler_output_flags", 264 "default_compile_flags", 265 "user_compile_flags", 266 "sysroot", 267 "unfiltered_compile_flags", 268 ], 269 tools = [tool(path = "wrapper/bin/msvc_cl.bat")], 270 ) 271 272 if (ctx.attr.cpu == "armeabi-v7a"): 273 action_configs = [] 274 elif (ctx.attr.cpu == "x64_windows_msvc"): 275 action_configs = [c_compile_action, cpp_compile_action] 276 elif (ctx.attr.cpu == "darwin" or 277 ctx.attr.cpu == "freebsd" or 278 ctx.attr.cpu == "local" or 279 ctx.attr.cpu == "x64_windows"): 280 action_configs = [objcopy_embed_data_action] 281 else: 282 fail("Unreachable") 283 284 random_seed_feature = feature(name = "random_seed", enabled = True) 285 286 compiler_output_flags_feature = feature( 287 name = "compiler_output_flags", 288 flag_sets = [ 289 flag_set( 290 actions = [_ASSEMBLE_ACTION_NAME], 291 flag_groups = [ 292 flag_group( 293 flags = ["/Fo%{output_file}", "/Zi"], 294 expand_if_available = "output_file", 295 expand_if_not_available = "output_assembly_file", 296 ), 297 ], 298 ), 299 flag_set( 300 actions = [ 301 _PREPROCESS_ASSEMBLE_ACTION_NAME, 302 _C_COMPILE_ACTION_NAME, 303 _CPP_COMPILE_ACTION_NAME, 304 _CPP_HEADER_PARSING_ACTION_NAME, 305 _CPP_MODULE_COMPILE_ACTION_NAME, 306 _CPP_MODULE_CODEGEN_ACTION_NAME, 307 ], 308 flag_groups = [ 309 flag_group( 310 flags = ["/Fo%{output_file}"], 311 expand_if_available = "output_file", 312 expand_if_not_available = "output_assembly_file", 313 ), 314 flag_group( 315 flags = ["/Fa%{output_file}"], 316 expand_if_available = "output_file", 317 ), 318 flag_group( 319 flags = ["/P", "/Fi%{output_file}"], 320 expand_if_available = "output_file", 321 ), 322 ], 323 ), 324 ], 325 ) 326 327 default_link_flags_feature = None 328 if (ctx.attr.cpu == "local"): 329 default_link_flags_feature = feature( 330 name = "default_link_flags", 331 enabled = True, 332 flag_sets = [ 333 flag_set( 334 actions = all_link_actions, 335 flag_groups = [ 336 flag_group( 337 flags = [ 338 "-lstdc++", 339 "-Wl,-z,relro,-z,now", 340 "-no-canonical-prefixes", 341 "-pass-exit-codes", 342 ], 343 ), 344 ], 345 ), 346 flag_set( 347 actions = all_link_actions, 348 flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], 349 with_features = [with_feature_set(features = ["opt"])], 350 ), 351 ], 352 ) 353 elif (ctx.attr.cpu == "freebsd"): 354 default_link_flags_feature = feature( 355 name = "default_link_flags", 356 enabled = True, 357 flag_sets = [ 358 flag_set( 359 actions = all_link_actions, 360 flag_groups = [ 361 flag_group( 362 flags = [ 363 "-lstdc++", 364 "-Wl,-z,relro,-z,now", 365 "-no-canonical-prefixes", 366 ], 367 ), 368 ], 369 ), 370 flag_set( 371 actions = all_link_actions, 372 flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], 373 with_features = [with_feature_set(features = ["opt"])], 374 ), 375 ], 376 ) 377 elif (ctx.attr.cpu == "darwin"): 378 default_link_flags_feature = feature( 379 name = "default_link_flags", 380 enabled = True, 381 flag_sets = [ 382 flag_set( 383 actions = all_link_actions, 384 flag_groups = [ 385 flag_group( 386 flags = [ 387 "-lstdc++", 388 "-undefined", 389 "dynamic_lookup", 390 "-headerpad_max_install_names", 391 "-no-canonical-prefixes", 392 ], 393 ), 394 ], 395 ), 396 ], 397 ) 398 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 399 default_link_flags_feature = feature( 400 name = "default_link_flags", 401 enabled = True, 402 flag_sets = [ 403 flag_set( 404 actions = all_link_actions, 405 flag_groups = [flag_group(flags = ["-lstdc++"])], 406 ), 407 ], 408 ) 409 elif (ctx.attr.cpu == "x64_windows_msvc"): 410 default_link_flags_feature = feature( 411 name = "default_link_flags", 412 enabled = True, 413 flag_sets = [ 414 flag_set( 415 actions = all_link_actions, 416 flag_groups = [flag_group(flags = ["-m64"])], 417 ), 418 ], 419 ) 420 421 unfiltered_compile_flags_feature = None 422 if (ctx.attr.cpu == "darwin" or 423 ctx.attr.cpu == "freebsd"): 424 unfiltered_compile_flags_feature = feature( 425 name = "unfiltered_compile_flags", 426 enabled = True, 427 flag_sets = [ 428 flag_set( 429 actions = [ 430 _ASSEMBLE_ACTION_NAME, 431 _PREPROCESS_ASSEMBLE_ACTION_NAME, 432 _LINKSTAMP_COMPILE_ACTION_NAME, 433 _C_COMPILE_ACTION_NAME, 434 _CPP_COMPILE_ACTION_NAME, 435 _CPP_HEADER_PARSING_ACTION_NAME, 436 _CPP_MODULE_COMPILE_ACTION_NAME, 437 _CPP_MODULE_CODEGEN_ACTION_NAME, 438 _LTO_BACKEND_ACTION_NAME, 439 _CLIF_MATCH_ACTION_NAME, 440 ], 441 flag_groups = [ 442 flag_group( 443 flags = [ 444 "-no-canonical-prefixes", 445 "-Wno-builtin-macro-redefined", 446 "-D__DATE__=\"redacted\"", 447 "-D__TIMESTAMP__=\"redacted\"", 448 "-D__TIME__=\"redacted\"", 449 ], 450 ), 451 ], 452 ), 453 ], 454 ) 455 elif (ctx.attr.cpu == "local"): 456 unfiltered_compile_flags_feature = feature( 457 name = "unfiltered_compile_flags", 458 enabled = True, 459 flag_sets = [ 460 flag_set( 461 actions = [ 462 _ASSEMBLE_ACTION_NAME, 463 _PREPROCESS_ASSEMBLE_ACTION_NAME, 464 _LINKSTAMP_COMPILE_ACTION_NAME, 465 _C_COMPILE_ACTION_NAME, 466 _CPP_COMPILE_ACTION_NAME, 467 _CPP_HEADER_PARSING_ACTION_NAME, 468 _CPP_MODULE_COMPILE_ACTION_NAME, 469 _CPP_MODULE_CODEGEN_ACTION_NAME, 470 _LTO_BACKEND_ACTION_NAME, 471 _CLIF_MATCH_ACTION_NAME, 472 ], 473 flag_groups = [ 474 flag_group( 475 flags = [ 476 "-no-canonical-prefixes", 477 "-fno-canonical-system-headers", 478 "-Wno-builtin-macro-redefined", 479 "-D__DATE__=\"redacted\"", 480 "-D__TIMESTAMP__=\"redacted\"", 481 "-D__TIME__=\"redacted\"", 482 ], 483 ), 484 ], 485 ), 486 ], 487 ) 488 elif (ctx.attr.cpu == "x64_windows_msvc"): 489 unfiltered_compile_flags_feature = feature( 490 name = "unfiltered_compile_flags", 491 flag_sets = [ 492 flag_set( 493 actions = [ 494 _ASSEMBLE_ACTION_NAME, 495 _PREPROCESS_ASSEMBLE_ACTION_NAME, 496 _C_COMPILE_ACTION_NAME, 497 _CPP_COMPILE_ACTION_NAME, 498 _CPP_HEADER_PARSING_ACTION_NAME, 499 _CPP_MODULE_COMPILE_ACTION_NAME, 500 _CPP_MODULE_CODEGEN_ACTION_NAME, 501 ], 502 flag_groups = [ 503 flag_group( 504 flags = ["%{unfiltered_compile_flags}"], 505 iterate_over = "unfiltered_compile_flags", 506 expand_if_available = "unfiltered_compile_flags", 507 ), 508 ], 509 ), 510 ], 511 ) 512 513 supports_pic_feature = feature(name = "supports_pic", enabled = True) 514 515 default_compile_flags_feature = None 516 if (ctx.attr.cpu == "darwin"): 517 default_compile_flags_feature = feature( 518 name = "default_compile_flags", 519 enabled = True, 520 flag_sets = [ 521 flag_set( 522 actions = [ 523 _ASSEMBLE_ACTION_NAME, 524 _PREPROCESS_ASSEMBLE_ACTION_NAME, 525 _LINKSTAMP_COMPILE_ACTION_NAME, 526 _C_COMPILE_ACTION_NAME, 527 _CPP_COMPILE_ACTION_NAME, 528 _CPP_HEADER_PARSING_ACTION_NAME, 529 _CPP_MODULE_COMPILE_ACTION_NAME, 530 _CPP_MODULE_CODEGEN_ACTION_NAME, 531 _LTO_BACKEND_ACTION_NAME, 532 _CLIF_MATCH_ACTION_NAME, 533 ], 534 flag_groups = [ 535 flag_group( 536 flags = [ 537 "-D_FORTIFY_SOURCE=1", 538 "-fstack-protector", 539 "-fcolor-diagnostics", 540 "-Wall", 541 "-Wthread-safety", 542 "-Wself-assign", 543 "-fno-omit-frame-pointer", 544 ], 545 ), 546 ], 547 ), 548 flag_set( 549 actions = [ 550 _ASSEMBLE_ACTION_NAME, 551 _PREPROCESS_ASSEMBLE_ACTION_NAME, 552 _LINKSTAMP_COMPILE_ACTION_NAME, 553 _C_COMPILE_ACTION_NAME, 554 _CPP_COMPILE_ACTION_NAME, 555 _CPP_HEADER_PARSING_ACTION_NAME, 556 _CPP_MODULE_COMPILE_ACTION_NAME, 557 _CPP_MODULE_CODEGEN_ACTION_NAME, 558 _LTO_BACKEND_ACTION_NAME, 559 _CLIF_MATCH_ACTION_NAME, 560 ], 561 flag_groups = [flag_group(flags = ["-g"])], 562 with_features = [with_feature_set(features = ["dbg"])], 563 ), 564 flag_set( 565 actions = [ 566 _ASSEMBLE_ACTION_NAME, 567 _PREPROCESS_ASSEMBLE_ACTION_NAME, 568 _LINKSTAMP_COMPILE_ACTION_NAME, 569 _C_COMPILE_ACTION_NAME, 570 _CPP_COMPILE_ACTION_NAME, 571 _CPP_HEADER_PARSING_ACTION_NAME, 572 _CPP_MODULE_COMPILE_ACTION_NAME, 573 _CPP_MODULE_CODEGEN_ACTION_NAME, 574 _LTO_BACKEND_ACTION_NAME, 575 _CLIF_MATCH_ACTION_NAME, 576 ], 577 flag_groups = [ 578 flag_group( 579 flags = [ 580 "-g0", 581 "-O2", 582 "-DNDEBUG", 583 "-ffunction-sections", 584 "-fdata-sections", 585 ], 586 ), 587 ], 588 with_features = [with_feature_set(features = ["opt"])], 589 ), 590 flag_set( 591 actions = [ 592 _LINKSTAMP_COMPILE_ACTION_NAME, 593 _CPP_COMPILE_ACTION_NAME, 594 _CPP_HEADER_PARSING_ACTION_NAME, 595 _CPP_MODULE_COMPILE_ACTION_NAME, 596 _CPP_MODULE_CODEGEN_ACTION_NAME, 597 _LTO_BACKEND_ACTION_NAME, 598 _CLIF_MATCH_ACTION_NAME, 599 ], 600 flag_groups = [flag_group(flags = ["-std=c++0x"])], 601 ), 602 ], 603 ) 604 elif (ctx.attr.cpu == "local"): 605 default_compile_flags_feature = feature( 606 name = "default_compile_flags", 607 enabled = True, 608 flag_sets = [ 609 flag_set( 610 actions = [ 611 _ASSEMBLE_ACTION_NAME, 612 _PREPROCESS_ASSEMBLE_ACTION_NAME, 613 _LINKSTAMP_COMPILE_ACTION_NAME, 614 _C_COMPILE_ACTION_NAME, 615 _CPP_COMPILE_ACTION_NAME, 616 _CPP_HEADER_PARSING_ACTION_NAME, 617 _CPP_MODULE_COMPILE_ACTION_NAME, 618 _CPP_MODULE_CODEGEN_ACTION_NAME, 619 _LTO_BACKEND_ACTION_NAME, 620 _CLIF_MATCH_ACTION_NAME, 621 ], 622 flag_groups = [ 623 flag_group( 624 flags = [ 625 "-U_FORTIFY_SOURCE", 626 "-D_FORTIFY_SOURCE=1", 627 "-fstack-protector", 628 "-Wall", 629 "-Wunused-but-set-parameter", 630 "-Wno-free-nonheap-object", 631 "-fno-omit-frame-pointer", 632 ], 633 ), 634 ], 635 ), 636 flag_set( 637 actions = [ 638 _ASSEMBLE_ACTION_NAME, 639 _PREPROCESS_ASSEMBLE_ACTION_NAME, 640 _LINKSTAMP_COMPILE_ACTION_NAME, 641 _C_COMPILE_ACTION_NAME, 642 _CPP_COMPILE_ACTION_NAME, 643 _CPP_HEADER_PARSING_ACTION_NAME, 644 _CPP_MODULE_COMPILE_ACTION_NAME, 645 _CPP_MODULE_CODEGEN_ACTION_NAME, 646 _LTO_BACKEND_ACTION_NAME, 647 _CLIF_MATCH_ACTION_NAME, 648 ], 649 flag_groups = [flag_group(flags = ["-g"])], 650 with_features = [with_feature_set(features = ["dbg"])], 651 ), 652 flag_set( 653 actions = [ 654 _ASSEMBLE_ACTION_NAME, 655 _PREPROCESS_ASSEMBLE_ACTION_NAME, 656 _LINKSTAMP_COMPILE_ACTION_NAME, 657 _C_COMPILE_ACTION_NAME, 658 _CPP_COMPILE_ACTION_NAME, 659 _CPP_HEADER_PARSING_ACTION_NAME, 660 _CPP_MODULE_COMPILE_ACTION_NAME, 661 _CPP_MODULE_CODEGEN_ACTION_NAME, 662 _LTO_BACKEND_ACTION_NAME, 663 _CLIF_MATCH_ACTION_NAME, 664 ], 665 flag_groups = [ 666 flag_group( 667 flags = [ 668 "-g0", 669 "-O2", 670 "-DNDEBUG", 671 "-ffunction-sections", 672 "-fdata-sections", 673 ], 674 ), 675 ], 676 with_features = [with_feature_set(features = ["opt"])], 677 ), 678 flag_set( 679 actions = [ 680 _LINKSTAMP_COMPILE_ACTION_NAME, 681 _CPP_COMPILE_ACTION_NAME, 682 _CPP_HEADER_PARSING_ACTION_NAME, 683 _CPP_MODULE_COMPILE_ACTION_NAME, 684 _CPP_MODULE_CODEGEN_ACTION_NAME, 685 _LTO_BACKEND_ACTION_NAME, 686 _CLIF_MATCH_ACTION_NAME, 687 ], 688 flag_groups = [flag_group(flags = ["-std=c++0x"])], 689 ), 690 ], 691 ) 692 elif (ctx.attr.cpu == "freebsd"): 693 default_compile_flags_feature = feature( 694 name = "default_compile_flags", 695 enabled = True, 696 flag_sets = [ 697 flag_set( 698 actions = [ 699 _ASSEMBLE_ACTION_NAME, 700 _PREPROCESS_ASSEMBLE_ACTION_NAME, 701 _LINKSTAMP_COMPILE_ACTION_NAME, 702 _C_COMPILE_ACTION_NAME, 703 _CPP_COMPILE_ACTION_NAME, 704 _CPP_HEADER_PARSING_ACTION_NAME, 705 _CPP_MODULE_COMPILE_ACTION_NAME, 706 _CPP_MODULE_CODEGEN_ACTION_NAME, 707 _LTO_BACKEND_ACTION_NAME, 708 _CLIF_MATCH_ACTION_NAME, 709 ], 710 flag_groups = [ 711 flag_group( 712 flags = [ 713 "-U_FORTIFY_SOURCE", 714 "-D_FORTIFY_SOURCE=1", 715 "-fstack-protector", 716 "-Wall", 717 "-fno-omit-frame-pointer", 718 ], 719 ), 720 ], 721 ), 722 flag_set( 723 actions = [ 724 _ASSEMBLE_ACTION_NAME, 725 _PREPROCESS_ASSEMBLE_ACTION_NAME, 726 _LINKSTAMP_COMPILE_ACTION_NAME, 727 _C_COMPILE_ACTION_NAME, 728 _CPP_COMPILE_ACTION_NAME, 729 _CPP_HEADER_PARSING_ACTION_NAME, 730 _CPP_MODULE_COMPILE_ACTION_NAME, 731 _CPP_MODULE_CODEGEN_ACTION_NAME, 732 _LTO_BACKEND_ACTION_NAME, 733 _CLIF_MATCH_ACTION_NAME, 734 ], 735 flag_groups = [flag_group(flags = ["-g"])], 736 with_features = [with_feature_set(features = ["dbg"])], 737 ), 738 flag_set( 739 actions = [ 740 _ASSEMBLE_ACTION_NAME, 741 _PREPROCESS_ASSEMBLE_ACTION_NAME, 742 _LINKSTAMP_COMPILE_ACTION_NAME, 743 _C_COMPILE_ACTION_NAME, 744 _CPP_COMPILE_ACTION_NAME, 745 _CPP_HEADER_PARSING_ACTION_NAME, 746 _CPP_MODULE_COMPILE_ACTION_NAME, 747 _CPP_MODULE_CODEGEN_ACTION_NAME, 748 _LTO_BACKEND_ACTION_NAME, 749 _CLIF_MATCH_ACTION_NAME, 750 ], 751 flag_groups = [ 752 flag_group( 753 flags = [ 754 "-g0", 755 "-O2", 756 "-DNDEBUG", 757 "-ffunction-sections", 758 "-fdata-sections", 759 ], 760 ), 761 ], 762 with_features = [with_feature_set(features = ["opt"])], 763 ), 764 flag_set( 765 actions = [ 766 _LINKSTAMP_COMPILE_ACTION_NAME, 767 _CPP_COMPILE_ACTION_NAME, 768 _CPP_HEADER_PARSING_ACTION_NAME, 769 _CPP_MODULE_COMPILE_ACTION_NAME, 770 _CPP_MODULE_CODEGEN_ACTION_NAME, 771 _LTO_BACKEND_ACTION_NAME, 772 _CLIF_MATCH_ACTION_NAME, 773 ], 774 flag_groups = [flag_group(flags = ["-std=c++0x"])], 775 ), 776 ], 777 ) 778 elif (ctx.attr.cpu == "x64_windows_msvc"): 779 default_compile_flags_feature = feature( 780 name = "default_compile_flags", 781 enabled = True, 782 flag_sets = [ 783 flag_set( 784 actions = [ 785 _ASSEMBLE_ACTION_NAME, 786 _PREPROCESS_ASSEMBLE_ACTION_NAME, 787 _LINKSTAMP_COMPILE_ACTION_NAME, 788 _C_COMPILE_ACTION_NAME, 789 _CPP_COMPILE_ACTION_NAME, 790 _CPP_HEADER_PARSING_ACTION_NAME, 791 _CPP_MODULE_COMPILE_ACTION_NAME, 792 _CPP_MODULE_CODEGEN_ACTION_NAME, 793 _LTO_BACKEND_ACTION_NAME, 794 _CLIF_MATCH_ACTION_NAME, 795 ], 796 flag_groups = [ 797 flag_group( 798 flags = [ 799 "-m64", 800 "/D__inline__=__inline", 801 "/DCOMPILER_MSVC", 802 "/DNOGDI", 803 "/DNOMINMAX", 804 "/DPRAGMA_SUPPORTED", 805 "/D_WIN32_WINNT=0x0601", 806 "/D_CRT_SECURE_NO_DEPRECATE", 807 "/D_CRT_SECURE_NO_WARNINGS", 808 "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS", 809 "/D_USE_MATH_DEFINES", 810 "/nologo", 811 "/bigobj", 812 "/Zm500", 813 "/J", 814 "/Gy", 815 "/GF", 816 "/W3", 817 "/EHsc", 818 "/wd4351", 819 "/wd4291", 820 "/wd4250", 821 "/wd4996", 822 ], 823 ), 824 ], 825 ), 826 flag_set( 827 actions = [ 828 _ASSEMBLE_ACTION_NAME, 829 _PREPROCESS_ASSEMBLE_ACTION_NAME, 830 _LINKSTAMP_COMPILE_ACTION_NAME, 831 _C_COMPILE_ACTION_NAME, 832 _CPP_COMPILE_ACTION_NAME, 833 _CPP_HEADER_PARSING_ACTION_NAME, 834 _CPP_MODULE_COMPILE_ACTION_NAME, 835 _CPP_MODULE_CODEGEN_ACTION_NAME, 836 _LTO_BACKEND_ACTION_NAME, 837 _CLIF_MATCH_ACTION_NAME, 838 ], 839 flag_groups = [ 840 flag_group( 841 flags = ["/DDEBUG=1", "-g", "/Od", "-Xcompilation-mode=dbg"], 842 ), 843 ], 844 with_features = [with_feature_set(features = ["dbg"])], 845 ), 846 flag_set( 847 actions = [ 848 _ASSEMBLE_ACTION_NAME, 849 _PREPROCESS_ASSEMBLE_ACTION_NAME, 850 _LINKSTAMP_COMPILE_ACTION_NAME, 851 _C_COMPILE_ACTION_NAME, 852 _CPP_COMPILE_ACTION_NAME, 853 _CPP_HEADER_PARSING_ACTION_NAME, 854 _CPP_MODULE_COMPILE_ACTION_NAME, 855 _CPP_MODULE_CODEGEN_ACTION_NAME, 856 _LTO_BACKEND_ACTION_NAME, 857 _CLIF_MATCH_ACTION_NAME, 858 ], 859 flag_groups = [ 860 flag_group( 861 flags = ["/DNDEBUG", "/Od", "-Xcompilation-mode=fastbuild"], 862 ), 863 ], 864 with_features = [with_feature_set(features = ["fastbuild"])], 865 ), 866 flag_set( 867 actions = [ 868 _ASSEMBLE_ACTION_NAME, 869 _PREPROCESS_ASSEMBLE_ACTION_NAME, 870 _LINKSTAMP_COMPILE_ACTION_NAME, 871 _C_COMPILE_ACTION_NAME, 872 _CPP_COMPILE_ACTION_NAME, 873 _CPP_HEADER_PARSING_ACTION_NAME, 874 _CPP_MODULE_COMPILE_ACTION_NAME, 875 _CPP_MODULE_CODEGEN_ACTION_NAME, 876 _LTO_BACKEND_ACTION_NAME, 877 _CLIF_MATCH_ACTION_NAME, 878 ], 879 flag_groups = [ 880 flag_group( 881 flags = ["/DNDEBUG", "/O2", "-Xcompilation-mode=opt"], 882 ), 883 ], 884 with_features = [with_feature_set(features = ["opt"])], 885 ), 886 ], 887 ) 888 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or 889 ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or 890 ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 891 default_compile_flags_feature = feature( 892 name = "default_compile_flags", 893 enabled = True, 894 flag_sets = [ 895 flag_set( 896 actions = [ 897 _LINKSTAMP_COMPILE_ACTION_NAME, 898 _CPP_COMPILE_ACTION_NAME, 899 _CPP_HEADER_PARSING_ACTION_NAME, 900 _CPP_MODULE_COMPILE_ACTION_NAME, 901 _CPP_MODULE_CODEGEN_ACTION_NAME, 902 _LTO_BACKEND_ACTION_NAME, 903 _CLIF_MATCH_ACTION_NAME, 904 ], 905 flag_groups = [flag_group(flags = ["-std=c++0x"])], 906 ), 907 ], 908 ) 909 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 910 default_compile_flags_feature = feature( 911 name = "default_compile_flags", 912 enabled = True, 913 flag_sets = [ 914 flag_set( 915 actions = [ 916 _LINKSTAMP_COMPILE_ACTION_NAME, 917 _CPP_COMPILE_ACTION_NAME, 918 _CPP_HEADER_PARSING_ACTION_NAME, 919 _CPP_MODULE_COMPILE_ACTION_NAME, 920 _CPP_MODULE_CODEGEN_ACTION_NAME, 921 _LTO_BACKEND_ACTION_NAME, 922 _CLIF_MATCH_ACTION_NAME, 923 ], 924 flag_groups = [flag_group(flags = ["-std=gnu++0x"])], 925 ), 926 ], 927 ) 928 929 opt_feature = feature(name = "opt") 930 931 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) 932 933 objcopy_embed_flags_feature = feature( 934 name = "objcopy_embed_flags", 935 enabled = True, 936 flag_sets = [ 937 flag_set( 938 actions = ["objcopy_embed_data"], 939 flag_groups = [flag_group(flags = ["-I", "binary"])], 940 ), 941 ], 942 ) 943 944 dbg_feature = feature(name = "dbg") 945 946 user_compile_flags_feature = None 947 if (ctx.attr.cpu == "darwin" or 948 ctx.attr.cpu == "freebsd" or 949 ctx.attr.cpu == "local"): 950 user_compile_flags_feature = feature( 951 name = "user_compile_flags", 952 enabled = True, 953 flag_sets = [ 954 flag_set( 955 actions = [ 956 _ASSEMBLE_ACTION_NAME, 957 _PREPROCESS_ASSEMBLE_ACTION_NAME, 958 _LINKSTAMP_COMPILE_ACTION_NAME, 959 _C_COMPILE_ACTION_NAME, 960 _CPP_COMPILE_ACTION_NAME, 961 _CPP_HEADER_PARSING_ACTION_NAME, 962 _CPP_MODULE_COMPILE_ACTION_NAME, 963 _CPP_MODULE_CODEGEN_ACTION_NAME, 964 _LTO_BACKEND_ACTION_NAME, 965 _CLIF_MATCH_ACTION_NAME, 966 ], 967 flag_groups = [ 968 flag_group( 969 flags = ["%{user_compile_flags}"], 970 iterate_over = "user_compile_flags", 971 expand_if_available = "user_compile_flags", 972 ), 973 ], 974 ), 975 ], 976 ) 977 elif (ctx.attr.cpu == "x64_windows_msvc"): 978 user_compile_flags_feature = feature( 979 name = "user_compile_flags", 980 flag_sets = [ 981 flag_set( 982 actions = [ 983 _ASSEMBLE_ACTION_NAME, 984 _PREPROCESS_ASSEMBLE_ACTION_NAME, 985 _C_COMPILE_ACTION_NAME, 986 _CPP_COMPILE_ACTION_NAME, 987 _CPP_HEADER_PARSING_ACTION_NAME, 988 _CPP_MODULE_COMPILE_ACTION_NAME, 989 _CPP_MODULE_CODEGEN_ACTION_NAME, 990 ], 991 flag_groups = [ 992 flag_group( 993 flags = ["%{user_compile_flags}"], 994 iterate_over = "user_compile_flags", 995 expand_if_available = "user_compile_flags", 996 ), 997 ], 998 ), 999 ], 1000 ) 1001 1002 sysroot_feature = None 1003 if (ctx.attr.cpu == "darwin" or 1004 ctx.attr.cpu == "freebsd" or 1005 ctx.attr.cpu == "local"): 1006 sysroot_feature = feature( 1007 name = "sysroot", 1008 enabled = True, 1009 flag_sets = [ 1010 flag_set( 1011 actions = [ 1012 _PREPROCESS_ASSEMBLE_ACTION_NAME, 1013 _LINKSTAMP_COMPILE_ACTION_NAME, 1014 _C_COMPILE_ACTION_NAME, 1015 _CPP_COMPILE_ACTION_NAME, 1016 _CPP_HEADER_PARSING_ACTION_NAME, 1017 _CPP_MODULE_COMPILE_ACTION_NAME, 1018 _CPP_MODULE_CODEGEN_ACTION_NAME, 1019 _LTO_BACKEND_ACTION_NAME, 1020 _CLIF_MATCH_ACTION_NAME, 1021 _CPP_LINK_EXECUTABLE_ACTION_NAME, 1022 _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, 1023 _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, 1024 ], 1025 flag_groups = [ 1026 flag_group( 1027 flags = ["--sysroot=%{sysroot}"], 1028 expand_if_available = "sysroot", 1029 ), 1030 ], 1031 ), 1032 ], 1033 ) 1034 elif (ctx.attr.cpu == "x64_windows_msvc"): 1035 sysroot_feature = feature( 1036 name = "sysroot", 1037 flag_sets = [ 1038 flag_set( 1039 actions = [ 1040 _ASSEMBLE_ACTION_NAME, 1041 _PREPROCESS_ASSEMBLE_ACTION_NAME, 1042 _C_COMPILE_ACTION_NAME, 1043 _CPP_COMPILE_ACTION_NAME, 1044 _CPP_HEADER_PARSING_ACTION_NAME, 1045 _CPP_MODULE_COMPILE_ACTION_NAME, 1046 _CPP_MODULE_CODEGEN_ACTION_NAME, 1047 _CPP_LINK_EXECUTABLE_ACTION_NAME, 1048 _CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, 1049 _CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, 1050 ], 1051 flag_groups = [ 1052 flag_group( 1053 flags = ["--sysroot=%{sysroot}"], 1054 iterate_over = "sysroot", 1055 expand_if_available = "sysroot", 1056 ), 1057 ], 1058 ), 1059 ], 1060 ) 1061 1062 include_paths_feature = feature( 1063 name = "include_paths", 1064 enabled = True, 1065 flag_sets = [ 1066 flag_set( 1067 actions = [ 1068 _PREPROCESS_ASSEMBLE_ACTION_NAME, 1069 _C_COMPILE_ACTION_NAME, 1070 _CPP_COMPILE_ACTION_NAME, 1071 _CPP_HEADER_PARSING_ACTION_NAME, 1072 _CPP_MODULE_COMPILE_ACTION_NAME, 1073 ], 1074 flag_groups = [ 1075 flag_group( 1076 flags = ["/I%{quote_include_paths}"], 1077 iterate_over = "quote_include_paths", 1078 ), 1079 flag_group( 1080 flags = ["/I%{include_paths}"], 1081 iterate_over = "include_paths", 1082 ), 1083 flag_group( 1084 flags = ["/I%{system_include_paths}"], 1085 iterate_over = "system_include_paths", 1086 ), 1087 ], 1088 ), 1089 ], 1090 ) 1091 1092 dependency_file_feature = feature( 1093 name = "dependency_file", 1094 enabled = True, 1095 flag_sets = [ 1096 flag_set( 1097 actions = [ 1098 _ASSEMBLE_ACTION_NAME, 1099 _PREPROCESS_ASSEMBLE_ACTION_NAME, 1100 _C_COMPILE_ACTION_NAME, 1101 _CPP_COMPILE_ACTION_NAME, 1102 _CPP_MODULE_COMPILE_ACTION_NAME, 1103 _CPP_HEADER_PARSING_ACTION_NAME, 1104 ], 1105 flag_groups = [ 1106 flag_group( 1107 flags = ["/DEPENDENCY_FILE", "%{dependency_file}"], 1108 expand_if_available = "dependency_file", 1109 ), 1110 ], 1111 ), 1112 ], 1113 ) 1114 1115 compiler_input_flags_feature = feature( 1116 name = "compiler_input_flags", 1117 flag_sets = [ 1118 flag_set( 1119 actions = [ 1120 _ASSEMBLE_ACTION_NAME, 1121 _PREPROCESS_ASSEMBLE_ACTION_NAME, 1122 _C_COMPILE_ACTION_NAME, 1123 _CPP_COMPILE_ACTION_NAME, 1124 _CPP_HEADER_PARSING_ACTION_NAME, 1125 _CPP_MODULE_COMPILE_ACTION_NAME, 1126 _CPP_MODULE_CODEGEN_ACTION_NAME, 1127 ], 1128 flag_groups = [ 1129 flag_group( 1130 flags = ["/c", "%{source_file}"], 1131 expand_if_available = "source_file", 1132 ), 1133 ], 1134 ), 1135 ], 1136 ) 1137 1138 fastbuild_feature = feature(name = "fastbuild") 1139 1140 features = None 1141 if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 1142 features = [ 1143 default_compile_flags_feature, 1144 default_link_flags_feature, 1145 supports_dynamic_linker_feature, 1146 objcopy_embed_flags_feature, 1147 ] 1148 elif (ctx.attr.cpu == "darwin"): 1149 features = [ 1150 default_compile_flags_feature, 1151 default_link_flags_feature, 1152 supports_dynamic_linker_feature, 1153 supports_pic_feature, 1154 objcopy_embed_flags_feature, 1155 dbg_feature, 1156 opt_feature, 1157 user_compile_flags_feature, 1158 sysroot_feature, 1159 unfiltered_compile_flags_feature, 1160 ] 1161 elif (ctx.attr.cpu == "freebsd" or 1162 ctx.attr.cpu == "local"): 1163 features = [ 1164 default_compile_flags_feature, 1165 default_link_flags_feature, 1166 supports_dynamic_linker_feature, 1167 supports_pic_feature, 1168 objcopy_embed_flags_feature, 1169 opt_feature, 1170 dbg_feature, 1171 user_compile_flags_feature, 1172 sysroot_feature, 1173 unfiltered_compile_flags_feature, 1174 ] 1175 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang" or 1176 ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw" or 1177 ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 1178 features = [ 1179 default_compile_flags_feature, 1180 supports_dynamic_linker_feature, 1181 objcopy_embed_flags_feature, 1182 ] 1183 elif (ctx.attr.cpu == "x64_windows_msvc"): 1184 features = [ 1185 default_link_flags_feature, 1186 random_seed_feature, 1187 default_compile_flags_feature, 1188 include_paths_feature, 1189 dependency_file_feature, 1190 user_compile_flags_feature, 1191 sysroot_feature, 1192 unfiltered_compile_flags_feature, 1193 compiler_output_flags_feature, 1194 compiler_input_flags_feature, 1195 dbg_feature, 1196 fastbuild_feature, 1197 opt_feature, 1198 ] 1199 elif (ctx.attr.cpu == "armeabi-v7a"): 1200 features = [supports_dynamic_linker_feature, supports_pic_feature] 1201 1202 if (ctx.attr.cpu == "armeabi-v7a"): 1203 cxx_builtin_include_directories = [] 1204 elif (ctx.attr.cpu == "darwin"): 1205 cxx_builtin_include_directories = ["/"] 1206 elif (ctx.attr.cpu == "freebsd"): 1207 cxx_builtin_include_directories = ["/usr/lib/clang", "/usr/local/include", "/usr/include"] 1208 elif (ctx.attr.cpu == "local" or 1209 ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): 1210 cxx_builtin_include_directories = ["/usr/lib/gcc/", "/usr/local/include", "/usr/include"] 1211 elif (ctx.attr.cpu == "x64_windows_msvc"): 1212 cxx_builtin_include_directories = [ 1213 "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/INCLUDE", 1214 "C:/Program Files (x86)/Windows Kits/10/include/", 1215 "C:/Program Files (x86)/Windows Kits/8.1/include/", 1216 "C:/Program Files (x86)/GnuWin32/include/", 1217 "C:/python_27_amd64/files/include", 1218 ] 1219 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): 1220 cxx_builtin_include_directories = ["C:/mingw/include", "C:/mingw/lib/gcc"] 1221 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 1222 cxx_builtin_include_directories = ["C:/tools/msys64/mingw64/x86_64-w64-mingw32/include"] 1223 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 1224 cxx_builtin_include_directories = ["C:/tools/msys64/", "/usr/"] 1225 else: 1226 fail("Unreachable") 1227 1228 artifact_name_patterns = [] 1229 1230 make_variables = [] 1231 1232 if (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64_mingw64"): 1233 tool_paths = [ 1234 tool_path( 1235 name = "ar", 1236 path = "C:/tools/msys64/mingw64/bin/ar", 1237 ), 1238 tool_path( 1239 name = "compat-ld", 1240 path = "C:/tools/msys64/mingw64/bin/ld", 1241 ), 1242 tool_path( 1243 name = "cpp", 1244 path = "C:/tools/msys64/mingw64/bin/cpp", 1245 ), 1246 tool_path( 1247 name = "dwp", 1248 path = "C:/tools/msys64/mingw64/bin/dwp", 1249 ), 1250 tool_path( 1251 name = "gcc", 1252 path = "C:/tools/msys64/mingw64/bin/gcc", 1253 ), 1254 tool_path( 1255 name = "gcov", 1256 path = "C:/tools/msys64/mingw64/bin/gcov", 1257 ), 1258 tool_path( 1259 name = "ld", 1260 path = "C:/tools/msys64/mingw64/bin/ld", 1261 ), 1262 tool_path( 1263 name = "nm", 1264 path = "C:/tools/msys64/mingw64/bin/nm", 1265 ), 1266 tool_path( 1267 name = "objcopy", 1268 path = "C:/tools/msys64/mingw64/bin/objcopy", 1269 ), 1270 tool_path( 1271 name = "objdump", 1272 path = "C:/tools/msys64/mingw64/bin/objdump", 1273 ), 1274 tool_path( 1275 name = "strip", 1276 path = "C:/tools/msys64/mingw64/bin/strip", 1277 ), 1278 ] 1279 elif (ctx.attr.cpu == "armeabi-v7a"): 1280 tool_paths = [ 1281 tool_path(name = "ar", path = "/bin/false"), 1282 tool_path(name = "compat-ld", path = "/bin/false"), 1283 tool_path(name = "cpp", path = "/bin/false"), 1284 tool_path(name = "dwp", path = "/bin/false"), 1285 tool_path(name = "gcc", path = "/bin/false"), 1286 tool_path(name = "gcov", path = "/bin/false"), 1287 tool_path(name = "ld", path = "/bin/false"), 1288 tool_path(name = "nm", path = "/bin/false"), 1289 tool_path(name = "objcopy", path = "/bin/false"), 1290 tool_path(name = "objdump", path = "/bin/false"), 1291 tool_path(name = "strip", path = "/bin/false"), 1292 ] 1293 elif (ctx.attr.cpu == "freebsd"): 1294 tool_paths = [ 1295 tool_path(name = "ar", path = "/usr/bin/ar"), 1296 tool_path(name = "compat-ld", path = "/usr/bin/ld"), 1297 tool_path(name = "cpp", path = "/usr/bin/cpp"), 1298 tool_path(name = "dwp", path = "/usr/bin/dwp"), 1299 tool_path(name = "gcc", path = "/usr/bin/clang"), 1300 tool_path(name = "gcov", path = "/usr/bin/gcov"), 1301 tool_path(name = "ld", path = "/usr/bin/ld"), 1302 tool_path(name = "nm", path = "/usr/bin/nm"), 1303 tool_path(name = "objcopy", path = "/usr/bin/objcopy"), 1304 tool_path(name = "objdump", path = "/usr/bin/objdump"), 1305 tool_path(name = "strip", path = "/usr/bin/strip"), 1306 ] 1307 elif (ctx.attr.cpu == "local"): 1308 tool_paths = [ 1309 tool_path(name = "ar", path = "/usr/bin/ar"), 1310 tool_path(name = "compat-ld", path = "/usr/bin/ld"), 1311 tool_path(name = "cpp", path = "/usr/bin/cpp"), 1312 tool_path(name = "dwp", path = "/usr/bin/dwp"), 1313 tool_path(name = "gcc", path = "/usr/bin/gcc"), 1314 tool_path(name = "gcov", path = "/usr/bin/gcov"), 1315 tool_path(name = "ld", path = "/usr/bin/ld"), 1316 tool_path(name = "nm", path = "/usr/bin/nm"), 1317 tool_path(name = "objcopy", path = "/usr/bin/objcopy"), 1318 tool_path(name = "objdump", path = "/usr/bin/objdump"), 1319 tool_path(name = "strip", path = "/usr/bin/strip"), 1320 ] 1321 elif (ctx.attr.cpu == "darwin"): 1322 tool_paths = [ 1323 tool_path(name = "ar", path = "/usr/bin/libtool"), 1324 tool_path(name = "compat-ld", path = "/usr/bin/ld"), 1325 tool_path(name = "cpp", path = "/usr/bin/cpp"), 1326 tool_path(name = "dwp", path = "/usr/bin/dwp"), 1327 tool_path(name = "gcc", path = "osx_cc_wrapper.sh"), 1328 tool_path(name = "gcov", path = "/usr/bin/gcov"), 1329 tool_path(name = "ld", path = "/usr/bin/ld"), 1330 tool_path(name = "nm", path = "/usr/bin/nm"), 1331 tool_path(name = "objcopy", path = "/usr/bin/objcopy"), 1332 tool_path(name = "objdump", path = "/usr/bin/objdump"), 1333 tool_path(name = "strip", path = "/usr/bin/strip"), 1334 ] 1335 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_clang"): 1336 tool_paths = [ 1337 tool_path(name = "ar", path = "C:/mingw/bin/ar"), 1338 tool_path( 1339 name = "compat-ld", 1340 path = "C:/Program Files (x86)/LLVM/bin/ld", 1341 ), 1342 tool_path( 1343 name = "cpp", 1344 path = "C:/Program Files (x86)/LLVM/bin/cpp", 1345 ), 1346 tool_path( 1347 name = "dwp", 1348 path = "C:/Program Files (x86)/LLVM/bin/dwp", 1349 ), 1350 tool_path( 1351 name = "gcc", 1352 path = "C:/Program Files (x86)/LLVM/bin/clang", 1353 ), 1354 tool_path( 1355 name = "gcov", 1356 path = "C:/Program Files (x86)/LLVM/bin/gcov", 1357 ), 1358 tool_path( 1359 name = "ld", 1360 path = "C:/Program Files (x86)/LLVM/bin/ld", 1361 ), 1362 tool_path( 1363 name = "nm", 1364 path = "C:/Program Files (x86)/LLVM/bin/nm", 1365 ), 1366 tool_path( 1367 name = "objcopy", 1368 path = "C:/Program Files (x86)/LLVM/bin/objcopy", 1369 ), 1370 tool_path( 1371 name = "objdump", 1372 path = "C:/Program Files (x86)/LLVM/bin/objdump", 1373 ), 1374 tool_path( 1375 name = "strip", 1376 path = "C:/Program Files (x86)/LLVM/bin/strip", 1377 ), 1378 ] 1379 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_mingw"): 1380 tool_paths = [ 1381 tool_path(name = "ar", path = "C:/mingw/bin/ar"), 1382 tool_path(name = "compat-ld", path = "C:/mingw/bin/ld"), 1383 tool_path(name = "cpp", path = "C:/mingw/bin/cpp"), 1384 tool_path(name = "dwp", path = "C:/mingw/bin/dwp"), 1385 tool_path(name = "gcc", path = "C:/mingw/bin/gcc"), 1386 tool_path(name = "gcov", path = "C:/mingw/bin/gcov"), 1387 tool_path(name = "ld", path = "C:/mingw/bin/ld"), 1388 tool_path(name = "nm", path = "C:/mingw/bin/nm"), 1389 tool_path(name = "objcopy", path = "C:/mingw/bin/objcopy"), 1390 tool_path(name = "objdump", path = "C:/mingw/bin/objdump"), 1391 tool_path(name = "strip", path = "C:/mingw/bin/strip"), 1392 ] 1393 elif (ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "windows_msys64"): 1394 tool_paths = [ 1395 tool_path(name = "ar", path = "C:/tools/msys64/usr/bin/ar"), 1396 tool_path( 1397 name = "compat-ld", 1398 path = "C:/tools/msys64/usr/bin/ld", 1399 ), 1400 tool_path( 1401 name = "cpp", 1402 path = "C:/tools/msys64/usr/bin/cpp", 1403 ), 1404 tool_path( 1405 name = "dwp", 1406 path = "C:/tools/msys64/usr/bin/dwp", 1407 ), 1408 tool_path( 1409 name = "gcc", 1410 path = "C:/tools/msys64/usr/bin/gcc", 1411 ), 1412 tool_path( 1413 name = "gcov", 1414 path = "C:/tools/msys64/usr/bin/gcov", 1415 ), 1416 tool_path(name = "ld", path = "C:/tools/msys64/usr/bin/ld"), 1417 tool_path(name = "nm", path = "C:/tools/msys64/usr/bin/nm"), 1418 tool_path( 1419 name = "objcopy", 1420 path = "C:/tools/msys64/usr/bin/objcopy", 1421 ), 1422 tool_path( 1423 name = "objdump", 1424 path = "C:/tools/msys64/usr/bin/objdump", 1425 ), 1426 tool_path( 1427 name = "strip", 1428 path = "C:/tools/msys64/usr/bin/strip", 1429 ), 1430 ] 1431 elif (ctx.attr.cpu == "x64_windows_msvc"): 1432 tool_paths = [ 1433 tool_path(name = "ar", path = "wrapper/bin/msvc_link.bat"), 1434 tool_path(name = "cpp", path = "wrapper/bin/msvc_cl.bat"), 1435 tool_path(name = "gcc", path = "wrapper/bin/msvc_cl.bat"), 1436 tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), 1437 tool_path(name = "ld", path = "wrapper/bin/msvc_link.bat"), 1438 tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), 1439 tool_path( 1440 name = "objcopy", 1441 path = "wrapper/bin/msvc_nop.bat", 1442 ), 1443 tool_path( 1444 name = "objdump", 1445 path = "wrapper/bin/msvc_nop.bat", 1446 ), 1447 tool_path( 1448 name = "strip", 1449 path = "wrapper/bin/msvc_nop.bat", 1450 ), 1451 ] 1452 else: 1453 fail("Unreachable") 1454 1455 out = ctx.actions.declare_file(ctx.label.name) 1456 ctx.actions.write(out, "Fake executable") 1457 return [ 1458 cc_common.create_cc_toolchain_config_info( 1459 ctx = ctx, 1460 features = features, 1461 action_configs = action_configs, 1462 artifact_name_patterns = artifact_name_patterns, 1463 cxx_builtin_include_directories = cxx_builtin_include_directories, 1464 toolchain_identifier = toolchain_identifier, 1465 host_system_name = host_system_name, 1466 target_system_name = target_system_name, 1467 target_cpu = target_cpu, 1468 target_libc = target_libc, 1469 compiler = compiler, 1470 abi_version = abi_version, 1471 abi_libc_version = abi_libc_version, 1472 tool_paths = tool_paths, 1473 make_variables = make_variables, 1474 builtin_sysroot = builtin_sysroot, 1475 cc_target_os = cc_target_os, 1476 ), 1477 DefaultInfo( 1478 executable = out, 1479 ), 1480 ] 1481 1482cc_toolchain_config = rule( 1483 implementation = _impl, 1484 attrs = { 1485 "compiler": attr.string(), 1486 "cpu": attr.string(mandatory = True), 1487 "disable_static_cc_toolchains": attr.bool(), 1488 }, 1489 provides = [CcToolchainConfigInfo], 1490 executable = True, 1491) 1492