github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/toolchains/preconfig/ubuntu14.04/gcc-nvcc-cuda10.0/cc_toolchain_config.bzl (about) 1 """cc_toolchain_config rule for configuring CUDA toolchains on Linux, Mac, and Windows.""" 2 3 load( 4 "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", 5 "action_config", 6 "env_entry", 7 "env_set", 8 "feature", 9 "feature_set", 10 "flag_group", 11 "flag_set", 12 "tool", 13 "tool_path", 14 "variable_with_value", 15 ) 16 load( 17 "@bazel_tools//tools/build_defs/cc:action_names.bzl", 18 "ASSEMBLE_ACTION_NAME", 19 "CC_FLAGS_MAKE_VARIABLE_ACTION_NAME", 20 "CLIF_MATCH_ACTION_NAME", 21 "CPP_COMPILE_ACTION_NAME", 22 "CPP_HEADER_PARSING_ACTION_NAME", 23 "CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME", 24 "CPP_LINK_EXECUTABLE_ACTION_NAME", 25 "CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME", 26 "CPP_LINK_STATIC_LIBRARY_ACTION_NAME", 27 "CPP_MODULE_CODEGEN_ACTION_NAME", 28 "CPP_MODULE_COMPILE_ACTION_NAME", 29 "C_COMPILE_ACTION_NAME", 30 "LINKSTAMP_COMPILE_ACTION_NAME", 31 "LTO_BACKEND_ACTION_NAME", 32 "LTO_INDEXING_ACTION_NAME", 33 "OBJCPP_COMPILE_ACTION_NAME", 34 "OBJCPP_EXECUTABLE_ACTION_NAME", 35 "OBJC_ARCHIVE_ACTION_NAME", 36 "OBJC_COMPILE_ACTION_NAME", 37 "OBJC_EXECUTABLE_ACTION_NAME", 38 "OBJC_FULLY_LINK_ACTION_NAME", 39 "PREPROCESS_ASSEMBLE_ACTION_NAME", 40 "STRIP_ACTION_NAME", 41 ) 42 43 ACTION_NAMES = struct( 44 c_compile = C_COMPILE_ACTION_NAME, 45 cpp_compile = CPP_COMPILE_ACTION_NAME, 46 linkstamp_compile = LINKSTAMP_COMPILE_ACTION_NAME, 47 cc_flags_make_variable = CC_FLAGS_MAKE_VARIABLE_ACTION_NAME, 48 cpp_module_codegen = CPP_MODULE_CODEGEN_ACTION_NAME, 49 cpp_header_parsing = CPP_HEADER_PARSING_ACTION_NAME, 50 cpp_module_compile = CPP_MODULE_COMPILE_ACTION_NAME, 51 assemble = ASSEMBLE_ACTION_NAME, 52 preprocess_assemble = PREPROCESS_ASSEMBLE_ACTION_NAME, 53 lto_indexing = LTO_INDEXING_ACTION_NAME, 54 lto_backend = LTO_BACKEND_ACTION_NAME, 55 cpp_link_executable = CPP_LINK_EXECUTABLE_ACTION_NAME, 56 cpp_link_dynamic_library = CPP_LINK_DYNAMIC_LIBRARY_ACTION_NAME, 57 cpp_link_nodeps_dynamic_library = CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME, 58 cpp_link_static_library = CPP_LINK_STATIC_LIBRARY_ACTION_NAME, 59 strip = STRIP_ACTION_NAME, 60 objc_archive = OBJC_ARCHIVE_ACTION_NAME, 61 objc_compile = OBJC_COMPILE_ACTION_NAME, 62 objc_executable = OBJC_EXECUTABLE_ACTION_NAME, 63 objc_fully_link = OBJC_FULLY_LINK_ACTION_NAME, 64 objcpp_compile = OBJCPP_COMPILE_ACTION_NAME, 65 objcpp_executable = OBJCPP_EXECUTABLE_ACTION_NAME, 66 clif_match = CLIF_MATCH_ACTION_NAME, 67 objcopy_embed_data = "objcopy_embed_data", 68 ld_embed_data = "ld_embed_data", 69 ) 70 71 def _impl(ctx): 72 if (ctx.attr.cpu == "darwin"): 73 toolchain_identifier = "local_darwin" 74 elif (ctx.attr.cpu == "local"): 75 toolchain_identifier = "local_linux" 76 elif (ctx.attr.cpu == "x64_windows"): 77 toolchain_identifier = "local_windows" 78 else: 79 fail("Unreachable") 80 81 host_system_name = "local" 82 83 target_system_name = "local" 84 85 if (ctx.attr.cpu == "darwin"): 86 target_cpu = "darwin" 87 elif (ctx.attr.cpu == "local"): 88 target_cpu = "local" 89 elif (ctx.attr.cpu == "x64_windows"): 90 target_cpu = "x64_windows" 91 else: 92 fail("Unreachable") 93 94 if (ctx.attr.cpu == "local"): 95 target_libc = "local" 96 elif (ctx.attr.cpu == "darwin"): 97 target_libc = "macosx" 98 elif (ctx.attr.cpu == "x64_windows"): 99 target_libc = "msvcrt" 100 else: 101 fail("Unreachable") 102 103 if (ctx.attr.cpu == "darwin" or 104 ctx.attr.cpu == "local"): 105 compiler = "compiler" 106 elif (ctx.attr.cpu == "x64_windows"): 107 compiler = "msvc-cl" 108 else: 109 fail("Unreachable") 110 111 abi_version = "local" 112 113 abi_libc_version = "local" 114 115 cc_target_os = None 116 117 builtin_sysroot = None 118 119 all_link_actions = [ 120 ACTION_NAMES.cpp_link_executable, 121 ACTION_NAMES.cpp_link_dynamic_library, 122 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 123 ] 124 125 cpp_link_dynamic_library_action = action_config( 126 action_name = ACTION_NAMES.cpp_link_dynamic_library, 127 implies = [ 128 "nologo", 129 "shared_flag", 130 "linkstamps", 131 "output_execpath_flags", 132 "input_param_flags", 133 "user_link_flags", 134 "linker_subsystem_flag", 135 "linker_param_file", 136 "msvc_env", 137 "no_stripping", 138 "has_configured_linker_path", 139 "def_file", 140 ], 141 tools = [tool(path = ctx.attr.msvc_link_path)], 142 ) 143 144 cpp_link_nodeps_dynamic_library_action = action_config( 145 action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library, 146 implies = [ 147 "nologo", 148 "shared_flag", 149 "linkstamps", 150 "output_execpath_flags", 151 "input_param_flags", 152 "user_link_flags", 153 "linker_subsystem_flag", 154 "linker_param_file", 155 "msvc_env", 156 "no_stripping", 157 "has_configured_linker_path", 158 "def_file", 159 ], 160 tools = [tool(path = ctx.attr.msvc_link_path)], 161 ) 162 163 cpp_link_static_library_action = action_config( 164 action_name = ACTION_NAMES.cpp_link_static_library, 165 implies = [ 166 "nologo", 167 "archiver_flags", 168 "input_param_flags", 169 "linker_param_file", 170 "msvc_env", 171 ], 172 tools = [tool(path = ctx.attr.msvc_lib_path)], 173 ) 174 175 assemble_action = action_config( 176 action_name = ACTION_NAMES.assemble, 177 implies = [ 178 "compiler_input_flags", 179 "compiler_output_flags", 180 "nologo", 181 "msvc_env", 182 "sysroot", 183 ], 184 tools = [tool(path = ctx.attr.msvc_ml_path)], 185 ) 186 187 preprocess_assemble_action = action_config( 188 action_name = ACTION_NAMES.preprocess_assemble, 189 implies = [ 190 "compiler_input_flags", 191 "compiler_output_flags", 192 "nologo", 193 "msvc_env", 194 "sysroot", 195 ], 196 tools = [tool(path = ctx.attr.msvc_ml_path)], 197 ) 198 199 c_compile_action = action_config( 200 action_name = ACTION_NAMES.c_compile, 201 implies = [ 202 "compiler_input_flags", 203 "compiler_output_flags", 204 "nologo", 205 "msvc_env", 206 "parse_showincludes", 207 "user_compile_flags", 208 "sysroot", 209 "unfiltered_compile_flags", 210 ], 211 tools = [tool(path = ctx.attr.msvc_cl_path)], 212 ) 213 214 cpp_compile_action = action_config( 215 action_name = ACTION_NAMES.cpp_compile, 216 implies = [ 217 "compiler_input_flags", 218 "compiler_output_flags", 219 "nologo", 220 "msvc_env", 221 "parse_showincludes", 222 "user_compile_flags", 223 "sysroot", 224 "unfiltered_compile_flags", 225 ], 226 tools = [tool(path = ctx.attr.msvc_cl_path)], 227 ) 228 229 cpp_link_executable_action = action_config( 230 action_name = ACTION_NAMES.cpp_link_executable, 231 implies = [ 232 "nologo", 233 "linkstamps", 234 "output_execpath_flags", 235 "input_param_flags", 236 "user_link_flags", 237 "linker_subsystem_flag", 238 "linker_param_file", 239 "msvc_env", 240 "no_stripping", 241 ], 242 tools = [tool(path = ctx.attr.msvc_link_path)], 243 ) 244 245 if (ctx.attr.cpu == "darwin" or 246 ctx.attr.cpu == "local"): 247 action_configs = [] 248 elif (ctx.attr.cpu == "x64_windows"): 249 action_configs = [ 250 assemble_action, 251 preprocess_assemble_action, 252 c_compile_action, 253 cpp_compile_action, 254 cpp_link_executable_action, 255 cpp_link_dynamic_library_action, 256 cpp_link_nodeps_dynamic_library_action, 257 cpp_link_static_library_action, 258 ] 259 else: 260 fail("Unreachable") 261 262 no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols") 263 264 pic_feature = feature( 265 name = "pic", 266 enabled = True, 267 flag_sets = [ 268 flag_set( 269 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 270 flag_groups = [ 271 flag_group(flags = ["-fPIC"], expand_if_available = "pic"), 272 flag_group( 273 flags = ["-fPIE"], 274 expand_if_not_available = "pic", 275 ), 276 ], 277 ), 278 ], 279 ) 280 281 preprocessor_defines_feature = feature( 282 name = "preprocessor_defines", 283 flag_sets = [ 284 flag_set( 285 actions = [ 286 ACTION_NAMES.assemble, 287 ACTION_NAMES.preprocess_assemble, 288 ACTION_NAMES.c_compile, 289 ACTION_NAMES.cpp_compile, 290 ACTION_NAMES.cpp_header_parsing, 291 ACTION_NAMES.cpp_module_compile, 292 ], 293 flag_groups = [ 294 flag_group( 295 flags = ["/D%{preprocessor_defines}"], 296 iterate_over = "preprocessor_defines", 297 ), 298 ], 299 ), 300 ], 301 ) 302 303 generate_pdb_file_feature = feature( 304 name = "generate_pdb_file", 305 requires = [ 306 feature_set(features = ["dbg"]), 307 feature_set(features = ["fastbuild"]), 308 ], 309 ) 310 311 linkstamps_feature = feature( 312 name = "linkstamps", 313 flag_sets = [ 314 flag_set( 315 actions = all_link_actions, 316 flag_groups = [ 317 flag_group( 318 flags = ["%{linkstamp_paths}"], 319 iterate_over = "linkstamp_paths", 320 expand_if_available = "linkstamp_paths", 321 ), 322 ], 323 ), 324 ], 325 ) 326 327 unfiltered_compile_flags_feature = feature( 328 name = "unfiltered_compile_flags", 329 flag_sets = ([ 330 flag_set( 331 actions = [ 332 ACTION_NAMES.preprocess_assemble, 333 ACTION_NAMES.c_compile, 334 ACTION_NAMES.cpp_compile, 335 ACTION_NAMES.cpp_header_parsing, 336 ACTION_NAMES.cpp_module_compile, 337 ACTION_NAMES.cpp_module_codegen, 338 ], 339 flag_groups = [ 340 flag_group( 341 flags = ctx.attr.host_unfiltered_compile_flags, 342 ), 343 ], 344 ), 345 ] if ctx.attr.host_unfiltered_compile_flags else []), 346 ) 347 348 determinism_feature = feature( 349 name = "determinism", 350 flag_sets = [ 351 flag_set( 352 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 353 flag_groups = [ 354 flag_group( 355 flags = [ 356 "-Wno-builtin-macro-redefined", 357 "-D__DATE__=\"redacted\"", 358 "-D__TIMESTAMP__=\"redacted\"", 359 "-D__TIME__=\"redacted\"", 360 ], 361 ), 362 ], 363 ), 364 ], 365 ) 366 367 nologo_feature = feature( 368 name = "nologo", 369 flag_sets = [ 370 flag_set( 371 actions = [ 372 ACTION_NAMES.c_compile, 373 ACTION_NAMES.cpp_compile, 374 ACTION_NAMES.cpp_module_compile, 375 ACTION_NAMES.cpp_module_codegen, 376 ACTION_NAMES.cpp_header_parsing, 377 ACTION_NAMES.assemble, 378 ACTION_NAMES.preprocess_assemble, 379 ACTION_NAMES.cpp_link_executable, 380 ACTION_NAMES.cpp_link_dynamic_library, 381 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 382 ACTION_NAMES.cpp_link_static_library, 383 ], 384 flag_groups = [flag_group(flags = ["/nologo"])], 385 ), 386 ], 387 ) 388 389 supports_pic_feature = feature(name = "supports_pic", enabled = True) 390 391 output_execpath_flags_feature = feature( 392 name = "output_execpath_flags", 393 flag_sets = [ 394 flag_set( 395 actions = all_link_actions, 396 flag_groups = [ 397 flag_group( 398 flags = ["/OUT:%{output_execpath}"], 399 expand_if_available = "output_execpath", 400 ), 401 ], 402 ), 403 ], 404 ) 405 406 default_link_flags_feature = feature( 407 name = "default_link_flags", 408 enabled = True, 409 flag_sets = [ 410 flag_set( 411 actions = all_link_actions, 412 flag_groups = [flag_group(flags = ["/MACHINE:X64"])], 413 ), 414 ], 415 ) 416 417 if (ctx.attr.cpu == "local"): 418 hardening_feature = feature( 419 name = "hardening", 420 flag_sets = [ 421 flag_set( 422 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 423 flag_groups = [ 424 flag_group( 425 flags = [ 426 "-U_FORTIFY_SOURCE", 427 "-D_FORTIFY_SOURCE=1", 428 "-fstack-protector", 429 ], 430 ), 431 ], 432 ), 433 flag_set( 434 actions = [ 435 ACTION_NAMES.cpp_link_dynamic_library, 436 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 437 ], 438 flag_groups = [flag_group(flags = ["-Wl,-z,relro,-z,now"])], 439 ), 440 flag_set( 441 actions = [ACTION_NAMES.cpp_link_executable], 442 flag_groups = [flag_group(flags = ["-pie", "-Wl,-z,relro,-z,now"])], 443 ), 444 ], 445 ) 446 elif (ctx.attr.cpu == "darwin"): 447 hardening_feature = feature( 448 name = "hardening", 449 flag_sets = [ 450 flag_set( 451 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 452 flag_groups = [ 453 flag_group( 454 flags = [ 455 "-U_FORTIFY_SOURCE", 456 "-D_FORTIFY_SOURCE=1", 457 "-fstack-protector", 458 ], 459 ), 460 ], 461 ), 462 flag_set( 463 actions = [ACTION_NAMES.cpp_link_executable], 464 flag_groups = [flag_group(flags = ["-pie"])], 465 ), 466 ], 467 ) 468 else: 469 hardening_feature = None 470 471 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) 472 473 targets_windows_feature = feature( 474 name = "targets_windows", 475 enabled = True, 476 implies = ["copy_dynamic_libraries_to_binary"], 477 ) 478 479 msvc_env_feature = feature( 480 name = "msvc_env", 481 env_sets = [ 482 env_set( 483 actions = [ 484 ACTION_NAMES.c_compile, 485 ACTION_NAMES.cpp_compile, 486 ACTION_NAMES.cpp_module_compile, 487 ACTION_NAMES.cpp_module_codegen, 488 ACTION_NAMES.cpp_header_parsing, 489 ACTION_NAMES.assemble, 490 ACTION_NAMES.preprocess_assemble, 491 ACTION_NAMES.cpp_link_executable, 492 ACTION_NAMES.cpp_link_dynamic_library, 493 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 494 ACTION_NAMES.cpp_link_static_library, 495 ], 496 env_entries = [ 497 env_entry(key = "PATH", value = ctx.attr.msvc_env_path), 498 env_entry( 499 key = "INCLUDE", 500 value = ctx.attr.msvc_env_include, 501 ), 502 env_entry(key = "LIB", value = ctx.attr.msvc_env_lib), 503 env_entry(key = "TMP", value = ctx.attr.msvc_env_tmp), 504 env_entry(key = "TEMP", value = ctx.attr.msvc_env_tmp), 505 ], 506 ), 507 ], 508 ) 509 510 linker_subsystem_flag_feature = feature( 511 name = "linker_subsystem_flag", 512 flag_sets = [ 513 flag_set( 514 actions = all_link_actions, 515 flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])], 516 ), 517 ], 518 ) 519 520 dynamic_link_msvcrt_no_debug_feature = feature( 521 name = "dynamic_link_msvcrt_no_debug", 522 flag_sets = [ 523 flag_set( 524 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 525 flag_groups = [flag_group(flags = ["/MD"])], 526 ), 527 flag_set( 528 actions = all_link_actions, 529 flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])], 530 ), 531 ], 532 requires = [ 533 feature_set(features = ["fastbuild"]), 534 feature_set(features = ["opt"]), 535 ], 536 ) 537 538 warnings_feature = feature( 539 name = "warnings", 540 flag_sets = [ 541 flag_set( 542 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 543 flag_groups = [ 544 flag_group( 545 flags = ["-Wall"] + ctx.attr.host_compiler_warnings, 546 ), 547 ], 548 ), 549 ], 550 ) 551 552 dynamic_link_msvcrt_debug_feature = feature( 553 name = "dynamic_link_msvcrt_debug", 554 flag_sets = [ 555 flag_set( 556 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 557 flag_groups = [flag_group(flags = ["/MDd"])], 558 ), 559 flag_set( 560 actions = all_link_actions, 561 flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])], 562 ), 563 ], 564 requires = [feature_set(features = ["dbg"])], 565 ) 566 567 compiler_output_flags_feature = feature( 568 name = "compiler_output_flags", 569 flag_sets = [ 570 flag_set( 571 actions = [ACTION_NAMES.assemble], 572 flag_groups = [ 573 flag_group( 574 flag_groups = [ 575 flag_group( 576 flags = ["/Fo%{output_file}", "/Zi"], 577 expand_if_not_available = "output_preprocess_file", 578 ), 579 ], 580 expand_if_available = "output_file", 581 expand_if_not_available = "output_assembly_file", 582 ), 583 ], 584 ), 585 flag_set( 586 actions = [ 587 ACTION_NAMES.preprocess_assemble, 588 ACTION_NAMES.c_compile, 589 ACTION_NAMES.cpp_compile, 590 ACTION_NAMES.cpp_header_parsing, 591 ACTION_NAMES.cpp_module_compile, 592 ACTION_NAMES.cpp_module_codegen, 593 ], 594 flag_groups = [ 595 flag_group( 596 flag_groups = [ 597 flag_group( 598 flags = ["/Fo%{output_file}"], 599 expand_if_not_available = "output_preprocess_file", 600 ), 601 ], 602 expand_if_available = "output_file", 603 expand_if_not_available = "output_assembly_file", 604 ), 605 flag_group( 606 flag_groups = [ 607 flag_group( 608 flags = ["/Fa%{output_file}"], 609 expand_if_available = "output_assembly_file", 610 ), 611 ], 612 expand_if_available = "output_file", 613 ), 614 flag_group( 615 flag_groups = [ 616 flag_group( 617 flags = ["/P", "/Fi%{output_file}"], 618 expand_if_available = "output_preprocess_file", 619 ), 620 ], 621 expand_if_available = "output_file", 622 ), 623 ], 624 ), 625 ], 626 ) 627 628 default_compile_flags_feature = feature( 629 name = "default_compile_flags", 630 enabled = True, 631 flag_sets = [ 632 flag_set( 633 actions = [ 634 ACTION_NAMES.assemble, 635 ACTION_NAMES.preprocess_assemble, 636 ACTION_NAMES.linkstamp_compile, 637 ACTION_NAMES.c_compile, 638 ACTION_NAMES.cpp_compile, 639 ACTION_NAMES.cpp_header_parsing, 640 ACTION_NAMES.cpp_module_compile, 641 ACTION_NAMES.cpp_module_codegen, 642 ACTION_NAMES.lto_backend, 643 ACTION_NAMES.clif_match, 644 ], 645 flag_groups = [ 646 flag_group( 647 flags = [ 648 "/DCOMPILER_MSVC", 649 "/DNOMINMAX", 650 "/D_WIN32_WINNT=0x0600", 651 "/D_CRT_SECURE_NO_DEPRECATE", 652 "/D_CRT_SECURE_NO_WARNINGS", 653 "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS", 654 "/bigobj", 655 "/Zm500", 656 "/J", 657 "/Gy", 658 "/GF", 659 "/EHsc", 660 "/wd4351", 661 "/wd4291", 662 "/wd4250", 663 "/wd4996", 664 ], 665 ), 666 ], 667 ), 668 ], 669 ) 670 671 static_link_msvcrt_debug_feature = feature( 672 name = "static_link_msvcrt_debug", 673 flag_sets = [ 674 flag_set( 675 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 676 flag_groups = [flag_group(flags = ["/MTd"])], 677 ), 678 flag_set( 679 actions = all_link_actions, 680 flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])], 681 ), 682 ], 683 requires = [feature_set(features = ["dbg"])], 684 ) 685 686 static_link_msvcrt_feature = feature(name = "static_link_msvcrt") 687 688 if (ctx.attr.cpu == "darwin" or 689 ctx.attr.cpu == "local"): 690 dbg_feature = feature( 691 name = "dbg", 692 flag_sets = [ 693 flag_set( 694 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 695 flag_groups = [flag_group(flags = ["-g"])], 696 ), 697 ], 698 implies = ["common"], 699 ) 700 elif (ctx.attr.cpu == "x64_windows"): 701 dbg_feature = feature( 702 name = "dbg", 703 flag_sets = [ 704 flag_set( 705 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 706 flag_groups = [flag_group(flags = ["/Od", "/Z7", "/DDEBUG"])], 707 ), 708 flag_set( 709 actions = all_link_actions, 710 flag_groups = [flag_group(flags = ["/DEBUG:FULL", "/INCREMENTAL:NO"])], 711 ), 712 ], 713 implies = ["generate_pdb_file"], 714 ) 715 else: 716 dbg_feature = None 717 718 undefined_dynamic_feature = feature( 719 name = "undefined-dynamic", 720 flag_sets = [ 721 flag_set( 722 actions = [ 723 ACTION_NAMES.cpp_link_dynamic_library, 724 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 725 ACTION_NAMES.cpp_link_executable, 726 ], 727 flag_groups = [flag_group(flags = ["-undefined", "dynamic_lookup"])], 728 ), 729 ], 730 ) 731 732 parse_showincludes_feature = feature( 733 name = "parse_showincludes", 734 flag_sets = [ 735 flag_set( 736 actions = [ 737 ACTION_NAMES.preprocess_assemble, 738 ACTION_NAMES.c_compile, 739 ACTION_NAMES.cpp_compile, 740 ACTION_NAMES.cpp_module_compile, 741 ACTION_NAMES.cpp_header_parsing, 742 ], 743 flag_groups = [flag_group(flags = ["/showIncludes"])], 744 ), 745 ], 746 ) 747 748 linker_param_file_feature = feature( 749 name = "linker_param_file", 750 flag_sets = [ 751 flag_set( 752 actions = all_link_actions + 753 [ACTION_NAMES.cpp_link_static_library], 754 flag_groups = [ 755 flag_group( 756 flags = ["@%{linker_param_file}"], 757 expand_if_available = "linker_param_file", 758 ), 759 ], 760 ), 761 ], 762 ) 763 764 static_link_msvcrt_no_debug_feature = feature( 765 name = "static_link_msvcrt_no_debug", 766 flag_sets = [ 767 flag_set( 768 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 769 flag_groups = [flag_group(flags = ["/MT"])], 770 ), 771 flag_set( 772 actions = all_link_actions, 773 flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])], 774 ), 775 ], 776 requires = [ 777 feature_set(features = ["fastbuild"]), 778 feature_set(features = ["opt"]), 779 ], 780 ) 781 782 supports_interface_shared_libraries_feature = feature( 783 name = "supports_interface_shared_libraries", 784 enabled = True, 785 ) 786 787 disable_assertions_feature = feature( 788 name = "disable-assertions", 789 flag_sets = [ 790 flag_set( 791 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 792 flag_groups = [flag_group(flags = ["-DNDEBUG"])], 793 ), 794 ], 795 ) 796 797 if (ctx.attr.cpu == "x64_windows"): 798 fastbuild_feature = feature( 799 name = "fastbuild", 800 flag_sets = [ 801 flag_set( 802 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 803 flag_groups = [flag_group(flags = ["/Od", "/Z7", "/DDEBUG"])], 804 ), 805 flag_set( 806 actions = all_link_actions, 807 flag_groups = [ 808 flag_group(flags = ["/DEBUG:FASTLINK", "/INCREMENTAL:NO"]), 809 ], 810 ), 811 ], 812 implies = ["generate_pdb_file"], 813 ) 814 elif (ctx.attr.cpu == "darwin" or 815 ctx.attr.cpu == "local"): 816 fastbuild_feature = feature(name = "fastbuild", implies = ["common"]) 817 else: 818 fastbuild_feature = None 819 820 user_compile_flags_feature = feature( 821 name = "user_compile_flags", 822 flag_sets = [ 823 flag_set( 824 actions = [ 825 ACTION_NAMES.preprocess_assemble, 826 ACTION_NAMES.c_compile, 827 ACTION_NAMES.cpp_compile, 828 ACTION_NAMES.cpp_header_parsing, 829 ACTION_NAMES.cpp_module_compile, 830 ACTION_NAMES.cpp_module_codegen, 831 ], 832 flag_groups = [ 833 flag_group( 834 flags = ["%{user_compile_flags}"], 835 iterate_over = "user_compile_flags", 836 expand_if_available = "user_compile_flags", 837 ), 838 ], 839 ), 840 ], 841 ) 842 843 compiler_input_flags_feature = feature( 844 name = "compiler_input_flags", 845 flag_sets = [ 846 flag_set( 847 actions = [ 848 ACTION_NAMES.assemble, 849 ACTION_NAMES.preprocess_assemble, 850 ACTION_NAMES.c_compile, 851 ACTION_NAMES.cpp_compile, 852 ACTION_NAMES.cpp_header_parsing, 853 ACTION_NAMES.cpp_module_compile, 854 ACTION_NAMES.cpp_module_codegen, 855 ], 856 flag_groups = [ 857 flag_group( 858 flags = ["/c", "%{source_file}"], 859 expand_if_available = "source_file", 860 ), 861 ], 862 ), 863 ], 864 ) 865 866 no_legacy_features_feature = feature(name = "no_legacy_features") 867 868 archiver_flags_feature = feature( 869 name = "archiver_flags", 870 flag_sets = [ 871 flag_set( 872 actions = [ACTION_NAMES.cpp_link_static_library], 873 flag_groups = [ 874 flag_group( 875 flags = ["/OUT:%{output_execpath}"], 876 expand_if_available = "output_execpath", 877 ), 878 ], 879 ), 880 ], 881 ) 882 883 redirector_feature = feature( 884 name = "redirector", 885 enabled = True, 886 flag_sets = [ 887 flag_set( 888 actions = [ 889 ACTION_NAMES.c_compile, 890 ACTION_NAMES.cpp_compile, 891 ACTION_NAMES.cpp_module_compile, 892 ACTION_NAMES.cpp_module_codegen, 893 ACTION_NAMES.cpp_header_parsing, 894 ACTION_NAMES.assemble, 895 ACTION_NAMES.preprocess_assemble, 896 ], 897 flag_groups = [ 898 flag_group( 899 flags = [ 900 "-B", 901 "external/local_config_cuda/crosstool/windows/msvc_wrapper_for_nvcc.py", 902 ], 903 ), 904 ], 905 ), 906 ], 907 ) 908 909 linker_bin_path_feature = feature( 910 name = "linker-bin-path", 911 flag_sets = [ 912 flag_set( 913 actions = all_link_actions, 914 flag_groups = [flag_group(flags = ["-B" + ctx.attr.linker_bin_path])], 915 ), 916 ], 917 ) 918 919 if (ctx.attr.cpu == "local"): 920 opt_feature = feature( 921 name = "opt", 922 flag_sets = [ 923 flag_set( 924 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 925 flag_groups = [ 926 flag_group( 927 flags = ["-g0", "-O2", "-ffunction-sections", "-fdata-sections"], 928 ), 929 ], 930 ), 931 flag_set( 932 actions = [ 933 ACTION_NAMES.cpp_link_dynamic_library, 934 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 935 ACTION_NAMES.cpp_link_executable, 936 ], 937 flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], 938 ), 939 ], 940 implies = ["common", "disable-assertions"], 941 ) 942 elif (ctx.attr.cpu == "darwin"): 943 opt_feature = feature( 944 name = "opt", 945 flag_sets = [ 946 flag_set( 947 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 948 flag_groups = [ 949 flag_group( 950 flags = ["-g0", "-O2", "-ffunction-sections", "-fdata-sections"], 951 ), 952 ], 953 ), 954 ], 955 implies = ["common", "disable-assertions"], 956 ) 957 elif (ctx.attr.cpu == "x64_windows"): 958 opt_feature = feature( 959 name = "opt", 960 flag_sets = [ 961 flag_set( 962 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 963 flag_groups = [flag_group(flags = ["/O2", "/DNDEBUG"])], 964 ), 965 ], 966 ) 967 else: 968 opt_feature = None 969 970 include_paths_feature = feature( 971 name = "include_paths", 972 enabled = True, 973 flag_sets = [ 974 flag_set( 975 actions = [ 976 ACTION_NAMES.assemble, 977 ACTION_NAMES.preprocess_assemble, 978 ACTION_NAMES.c_compile, 979 ACTION_NAMES.cpp_compile, 980 ACTION_NAMES.cpp_header_parsing, 981 ACTION_NAMES.cpp_module_compile, 982 ], 983 flag_groups = [ 984 flag_group( 985 flags = ["/I%{quote_include_paths}"], 986 iterate_over = "quote_include_paths", 987 ), 988 flag_group( 989 flags = ["/I%{include_paths}"], 990 iterate_over = "include_paths", 991 ), 992 flag_group( 993 flags = ["/I%{system_include_paths}"], 994 iterate_over = "system_include_paths", 995 ), 996 ], 997 ), 998 ], 999 ) 1000 1001 shared_flag_feature = feature( 1002 name = "shared_flag", 1003 flag_sets = [ 1004 flag_set( 1005 actions = [ 1006 ACTION_NAMES.cpp_link_dynamic_library, 1007 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1008 ], 1009 flag_groups = [flag_group(flags = ["/DLL"])], 1010 ), 1011 ], 1012 ) 1013 1014 windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols") 1015 1016 frame_pointer_feature = feature( 1017 name = "frame-pointer", 1018 flag_sets = [ 1019 flag_set( 1020 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], 1021 flag_groups = [flag_group(flags = ["-fno-omit-frame-pointer"])], 1022 ), 1023 ], 1024 ) 1025 1026 build_id_feature = feature( 1027 name = "build-id", 1028 flag_sets = [ 1029 flag_set( 1030 actions = all_link_actions, 1031 flag_groups = [ 1032 flag_group( 1033 flags = ["-Wl,--build-id=md5", "-Wl,--hash-style=gnu"], 1034 ), 1035 ], 1036 ), 1037 ], 1038 ) 1039 1040 sysroot_feature = feature( 1041 name = "sysroot", 1042 flag_sets = [ 1043 flag_set( 1044 actions = [ 1045 ACTION_NAMES.assemble, 1046 ACTION_NAMES.preprocess_assemble, 1047 ACTION_NAMES.c_compile, 1048 ACTION_NAMES.cpp_compile, 1049 ACTION_NAMES.cpp_header_parsing, 1050 ACTION_NAMES.cpp_module_compile, 1051 ACTION_NAMES.cpp_module_codegen, 1052 ACTION_NAMES.cpp_link_executable, 1053 ACTION_NAMES.cpp_link_dynamic_library, 1054 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1055 ], 1056 flag_groups = [ 1057 flag_group( 1058 flags = ["--sysroot=%{sysroot}"], 1059 iterate_over = "sysroot", 1060 expand_if_available = "sysroot", 1061 ), 1062 ], 1063 ), 1064 ], 1065 ) 1066 1067 def_file_feature = feature( 1068 name = "def_file", 1069 flag_sets = [ 1070 flag_set( 1071 actions = all_link_actions, 1072 flag_groups = [ 1073 flag_group( 1074 flags = ["/DEF:%{def_file_path}", "/ignore:4070"], 1075 expand_if_available = "def_file_path", 1076 ), 1077 ], 1078 ), 1079 ], 1080 ) 1081 1082 if (ctx.attr.cpu == "darwin"): 1083 stdlib_feature = feature( 1084 name = "stdlib", 1085 flag_sets = [ 1086 flag_set( 1087 actions = all_link_actions, 1088 flag_groups = [flag_group(flags = ["-lc++"])], 1089 ), 1090 ], 1091 ) 1092 elif (ctx.attr.cpu == "local"): 1093 stdlib_feature = feature( 1094 name = "stdlib", 1095 flag_sets = [ 1096 flag_set( 1097 actions = all_link_actions, 1098 flag_groups = [flag_group(flags = ["-lstdc++"])], 1099 ), 1100 ], 1101 ) 1102 else: 1103 stdlib_feature = None 1104 1105 no_stripping_feature = feature(name = "no_stripping") 1106 1107 alwayslink_feature = feature( 1108 name = "alwayslink", 1109 flag_sets = [ 1110 flag_set( 1111 actions = [ 1112 ACTION_NAMES.cpp_link_dynamic_library, 1113 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1114 ACTION_NAMES.cpp_link_executable, 1115 ], 1116 flag_groups = [flag_group(flags = ["-Wl,-no-as-needed"])], 1117 ), 1118 ], 1119 ) 1120 1121 input_param_flags_feature = feature( 1122 name = "input_param_flags", 1123 flag_sets = [ 1124 flag_set( 1125 actions = [ 1126 ACTION_NAMES.cpp_link_dynamic_library, 1127 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1128 ], 1129 flag_groups = [ 1130 flag_group( 1131 flags = ["/IMPLIB:%{interface_library_output_path}"], 1132 expand_if_available = "interface_library_output_path", 1133 ), 1134 ], 1135 ), 1136 flag_set( 1137 actions = all_link_actions + 1138 [ACTION_NAMES.cpp_link_static_library], 1139 flag_groups = [ 1140 flag_group( 1141 iterate_over = "libraries_to_link", 1142 flag_groups = [ 1143 flag_group( 1144 iterate_over = "libraries_to_link.object_files", 1145 flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])], 1146 expand_if_equal = variable_with_value( 1147 name = "libraries_to_link.type", 1148 value = "object_file_group", 1149 ), 1150 ), 1151 flag_group( 1152 flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], 1153 expand_if_equal = variable_with_value( 1154 name = "libraries_to_link.type", 1155 value = "object_file", 1156 ), 1157 ), 1158 flag_group( 1159 flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])], 1160 expand_if_equal = variable_with_value( 1161 name = "libraries_to_link.type", 1162 value = "interface_library", 1163 ), 1164 ), 1165 flag_group( 1166 flag_groups = [ 1167 flag_group( 1168 flags = ["%{libraries_to_link.name}"], 1169 expand_if_false = "libraries_to_link.is_whole_archive", 1170 ), 1171 flag_group( 1172 flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"], 1173 expand_if_true = "libraries_to_link.is_whole_archive", 1174 ), 1175 ], 1176 expand_if_equal = variable_with_value( 1177 name = "libraries_to_link.type", 1178 value = "static_library", 1179 ), 1180 ), 1181 ], 1182 expand_if_available = "libraries_to_link", 1183 ), 1184 ], 1185 ), 1186 ], 1187 ) 1188 1189 if (ctx.attr.cpu == "local"): 1190 no_canonical_prefixes_feature = feature( 1191 name = "no-canonical-prefixes", 1192 flag_sets = [ 1193 flag_set( 1194 actions = [ 1195 ACTION_NAMES.c_compile, 1196 ACTION_NAMES.cpp_compile, 1197 ACTION_NAMES.cpp_link_executable, 1198 ACTION_NAMES.cpp_link_dynamic_library, 1199 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1200 ], 1201 flag_groups = [ 1202 flag_group( 1203 flags = [ 1204 "-no-canonical-prefixes", 1205 ] + ctx.attr.extra_no_canonical_prefixes_flags, 1206 ), 1207 ], 1208 ), 1209 ], 1210 ) 1211 elif (ctx.attr.cpu == "darwin"): 1212 no_canonical_prefixes_feature = feature( 1213 name = "no-canonical-prefixes", 1214 flag_sets = [ 1215 flag_set( 1216 actions = [ 1217 ACTION_NAMES.c_compile, 1218 ACTION_NAMES.cpp_compile, 1219 ACTION_NAMES.cpp_link_executable, 1220 ACTION_NAMES.cpp_link_dynamic_library, 1221 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 1222 ], 1223 flag_groups = [flag_group(flags = ["-no-canonical-prefixes"])], 1224 ), 1225 ], 1226 ) 1227 else: 1228 no_canonical_prefixes_feature = None 1229 1230 has_configured_linker_path_feature = feature(name = "has_configured_linker_path") 1231 1232 copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") 1233 1234 user_link_flags_feature = feature( 1235 name = "user_link_flags", 1236 flag_sets = [ 1237 flag_set( 1238 actions = all_link_actions, 1239 flag_groups = [ 1240 flag_group( 1241 flags = ["%{user_link_flags}"], 1242 iterate_over = "user_link_flags", 1243 expand_if_available = "user_link_flags", 1244 ), 1245 ], 1246 ), 1247 ], 1248 ) 1249 1250 cpp11_feature = feature( 1251 name = "c++11", 1252 flag_sets = [ 1253 flag_set( 1254 actions = [ACTION_NAMES.cpp_compile], 1255 flag_groups = [flag_group(flags = ["-std=c++11"])], 1256 ), 1257 ], 1258 ) 1259 1260 if (ctx.attr.cpu == "local"): 1261 common_feature = feature( 1262 name = "common", 1263 implies = [ 1264 "stdlib", 1265 "c++11", 1266 "determinism", 1267 "alwayslink", 1268 "hardening", 1269 "warnings", 1270 "frame-pointer", 1271 "build-id", 1272 "no-canonical-prefixes", 1273 "linker-bin-path", 1274 ], 1275 ) 1276 elif (ctx.attr.cpu == "darwin"): 1277 common_feature = feature( 1278 name = "common", 1279 implies = [ 1280 "stdlib", 1281 "c++11", 1282 "determinism", 1283 "hardening", 1284 "warnings", 1285 "frame-pointer", 1286 "no-canonical-prefixes", 1287 "linker-bin-path", 1288 "undefined-dynamic", 1289 ], 1290 ) 1291 else: 1292 common_feature = None 1293 1294 if (ctx.attr.cpu == "local"): 1295 features = [ 1296 cpp11_feature, 1297 stdlib_feature, 1298 determinism_feature, 1299 alwayslink_feature, 1300 pic_feature, 1301 hardening_feature, 1302 warnings_feature, 1303 frame_pointer_feature, 1304 build_id_feature, 1305 no_canonical_prefixes_feature, 1306 disable_assertions_feature, 1307 linker_bin_path_feature, 1308 common_feature, 1309 opt_feature, 1310 fastbuild_feature, 1311 dbg_feature, 1312 supports_dynamic_linker_feature, 1313 supports_pic_feature, 1314 ] 1315 elif (ctx.attr.cpu == "darwin"): 1316 features = [ 1317 cpp11_feature, 1318 stdlib_feature, 1319 determinism_feature, 1320 pic_feature, 1321 hardening_feature, 1322 warnings_feature, 1323 frame_pointer_feature, 1324 no_canonical_prefixes_feature, 1325 disable_assertions_feature, 1326 linker_bin_path_feature, 1327 undefined_dynamic_feature, 1328 common_feature, 1329 opt_feature, 1330 fastbuild_feature, 1331 dbg_feature, 1332 supports_dynamic_linker_feature, 1333 supports_pic_feature, 1334 ] 1335 elif (ctx.attr.cpu == "x64_windows"): 1336 features = [ 1337 no_legacy_features_feature, 1338 redirector_feature, 1339 nologo_feature, 1340 has_configured_linker_path_feature, 1341 no_stripping_feature, 1342 targets_windows_feature, 1343 copy_dynamic_libraries_to_binary_feature, 1344 default_compile_flags_feature, 1345 msvc_env_feature, 1346 include_paths_feature, 1347 preprocessor_defines_feature, 1348 parse_showincludes_feature, 1349 generate_pdb_file_feature, 1350 shared_flag_feature, 1351 linkstamps_feature, 1352 output_execpath_flags_feature, 1353 archiver_flags_feature, 1354 input_param_flags_feature, 1355 linker_subsystem_flag_feature, 1356 user_link_flags_feature, 1357 default_link_flags_feature, 1358 linker_param_file_feature, 1359 static_link_msvcrt_feature, 1360 static_link_msvcrt_no_debug_feature, 1361 dynamic_link_msvcrt_no_debug_feature, 1362 static_link_msvcrt_debug_feature, 1363 dynamic_link_msvcrt_debug_feature, 1364 dbg_feature, 1365 fastbuild_feature, 1366 opt_feature, 1367 user_compile_flags_feature, 1368 sysroot_feature, 1369 unfiltered_compile_flags_feature, 1370 compiler_output_flags_feature, 1371 compiler_input_flags_feature, 1372 def_file_feature, 1373 windows_export_all_symbols_feature, 1374 no_windows_export_all_symbols_feature, 1375 supports_dynamic_linker_feature, 1376 supports_interface_shared_libraries_feature, 1377 ] 1378 else: 1379 fail("Unreachable") 1380 1381 cxx_builtin_include_directories = ctx.attr.builtin_include_directories 1382 1383 if (ctx.attr.cpu == "x64_windows"): 1384 tool_paths = [ 1385 tool_path(name = "ar", path = ctx.attr.msvc_lib_path), 1386 tool_path(name = "ml", path = ctx.attr.msvc_ml_path), 1387 tool_path(name = "cpp", path = ctx.attr.msvc_cl_path), 1388 tool_path(name = "gcc", path = ctx.attr.msvc_cl_path), 1389 tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"), 1390 tool_path(name = "ld", path = ctx.attr.msvc_link_path), 1391 tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"), 1392 tool_path( 1393 name = "objcopy", 1394 path = "wrapper/bin/msvc_nop.bat", 1395 ), 1396 tool_path( 1397 name = "objdump", 1398 path = "wrapper/bin/msvc_nop.bat", 1399 ), 1400 tool_path( 1401 name = "strip", 1402 path = "wrapper/bin/msvc_nop.bat", 1403 ), 1404 ] 1405 elif (ctx.attr.cpu == "local"): 1406 tool_paths = [ 1407 tool_path(name = "gcc", path = ctx.attr.host_compiler_path), 1408 tool_path(name = "ar", path = ctx.attr.host_compiler_prefix + "/ar"), 1409 tool_path(name = "compat-ld", path = ctx.attr.host_compiler_prefix + "/ld"), 1410 tool_path(name = "cpp", path = ctx.attr.host_compiler_prefix + "/cpp"), 1411 tool_path(name = "dwp", path = ctx.attr.host_compiler_prefix + "/dwp"), 1412 tool_path(name = "gcov", path = ctx.attr.host_compiler_prefix + "/gcov"), 1413 tool_path(name = "ld", path = ctx.attr.host_compiler_prefix + "/ld"), 1414 tool_path(name = "nm", path = ctx.attr.host_compiler_prefix + "/nm"), 1415 tool_path(name = "objcopy", path = ctx.attr.host_compiler_prefix + "/objcopy"), 1416 tool_path(name = "objdump", path = ctx.attr.host_compiler_prefix + "/objdump"), 1417 tool_path(name = "strip", path = ctx.attr.host_compiler_prefix + "/strip"), 1418 ] 1419 elif (ctx.attr.cpu == "darwin"): 1420 tool_paths = [ 1421 tool_path(name = "gcc", path = ctx.attr.host_compiler_path), 1422 tool_path(name = "ar", path = ctx.attr.host_compiler_prefix + "/libtool"), 1423 tool_path(name = "compat-ld", path = ctx.attr.host_compiler_prefix + "/ld"), 1424 tool_path(name = "cpp", path = ctx.attr.host_compiler_prefix + "/cpp"), 1425 tool_path(name = "dwp", path = ctx.attr.host_compiler_prefix + "/dwp"), 1426 tool_path(name = "gcov", path = ctx.attr.host_compiler_prefix + "/gcov"), 1427 tool_path(name = "ld", path = ctx.attr.host_compiler_prefix + "/ld"), 1428 tool_path(name = "nm", path = ctx.attr.host_compiler_prefix + "/nm"), 1429 tool_path(name = "objcopy", path = ctx.attr.host_compiler_prefix + "/objcopy"), 1430 tool_path(name = "objdump", path = ctx.attr.host_compiler_prefix + "/objdump"), 1431 tool_path(name = "strip", path = ctx.attr.host_compiler_prefix + "/strip"), 1432 ] 1433 else: 1434 fail("Unreachable") 1435 1436 out = ctx.actions.declare_file(ctx.label.name) 1437 ctx.actions.write(out, "Fake executable") 1438 return [ 1439 cc_common.create_cc_toolchain_config_info( 1440 ctx = ctx, 1441 features = features, 1442 action_configs = action_configs, 1443 artifact_name_patterns = [], 1444 cxx_builtin_include_directories = cxx_builtin_include_directories, 1445 toolchain_identifier = toolchain_identifier, 1446 host_system_name = host_system_name, 1447 target_system_name = target_system_name, 1448 target_cpu = target_cpu, 1449 target_libc = target_libc, 1450 compiler = compiler, 1451 abi_version = abi_version, 1452 abi_libc_version = abi_libc_version, 1453 tool_paths = tool_paths, 1454 make_variables = [], 1455 builtin_sysroot = builtin_sysroot, 1456 cc_target_os = cc_target_os, 1457 ), 1458 DefaultInfo( 1459 executable = out, 1460 ), 1461 ] 1462 1463 cc_toolchain_config = rule( 1464 implementation = _impl, 1465 attrs = { 1466 "cpu": attr.string(mandatory = True, values = ["darwin", "local", "x64_windows"]), 1467 "builtin_include_directories": attr.string_list(), 1468 "extra_no_canonical_prefixes_flags": attr.string_list(), 1469 "host_compiler_path": attr.string(), 1470 "host_compiler_prefix": attr.string(), 1471 "host_compiler_warnings": attr.string_list(), 1472 "host_unfiltered_compile_flags": attr.string_list(), 1473 "linker_bin_path": attr.string(), 1474 "msvc_cl_path": attr.string(default = "msvc_not_used"), 1475 "msvc_env_include": attr.string(default = "msvc_not_used"), 1476 "msvc_env_lib": attr.string(default = "msvc_not_used"), 1477 "msvc_env_path": attr.string(default = "msvc_not_used"), 1478 "msvc_env_tmp": attr.string(default = "msvc_not_used"), 1479 "msvc_lib_path": attr.string(default = "msvc_not_used"), 1480 "msvc_link_path": attr.string(default = "msvc_not_used"), 1481 "msvc_ml_path": attr.string(default = "msvc_not_used"), 1482 }, 1483 provides = [CcToolchainConfigInfo], 1484 executable = True, 1485 )