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