github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010/cc_toolchain_config.bzl (about)

     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  
    17  load(
    18      "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
    19      "action_config",
    20      "artifact_name_pattern",
    21      "env_entry",
    22      "env_set",
    23      "feature",
    24      "feature_set",
    25      "flag_group",
    26      "flag_set",
    27      "make_variable",  # @unused
    28      "tool",
    29      "tool_path",
    30      "variable_with_value",
    31      "with_feature_set",
    32  )
    33  load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
    34  
    35  all_compile_actions = [
    36      ACTION_NAMES.c_compile,
    37      ACTION_NAMES.cpp_compile,
    38      ACTION_NAMES.linkstamp_compile,
    39      ACTION_NAMES.assemble,
    40      ACTION_NAMES.preprocess_assemble,
    41      ACTION_NAMES.cpp_header_parsing,
    42      ACTION_NAMES.cpp_module_compile,
    43      ACTION_NAMES.cpp_module_codegen,
    44      ACTION_NAMES.clif_match,
    45      ACTION_NAMES.lto_backend,
    46  ]
    47  
    48  all_cpp_compile_actions = [
    49      ACTION_NAMES.cpp_compile,
    50      ACTION_NAMES.linkstamp_compile,
    51      ACTION_NAMES.cpp_header_parsing,
    52      ACTION_NAMES.cpp_module_compile,
    53      ACTION_NAMES.cpp_module_codegen,
    54      ACTION_NAMES.clif_match,
    55  ]
    56  
    57  preprocessor_compile_actions = [
    58      ACTION_NAMES.c_compile,
    59      ACTION_NAMES.cpp_compile,
    60      ACTION_NAMES.linkstamp_compile,
    61      ACTION_NAMES.preprocess_assemble,
    62      ACTION_NAMES.cpp_header_parsing,
    63      ACTION_NAMES.cpp_module_compile,
    64      ACTION_NAMES.clif_match,
    65  ]
    66  
    67  codegen_compile_actions = [
    68      ACTION_NAMES.c_compile,
    69      ACTION_NAMES.cpp_compile,
    70      ACTION_NAMES.linkstamp_compile,
    71      ACTION_NAMES.assemble,
    72      ACTION_NAMES.preprocess_assemble,
    73      ACTION_NAMES.cpp_module_codegen,
    74      ACTION_NAMES.lto_backend,
    75  ]
    76  
    77  all_link_actions = [
    78      ACTION_NAMES.cpp_link_executable,
    79      ACTION_NAMES.cpp_link_dynamic_library,
    80      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
    81  ]
    82  
    83  def _windows_msvc_impl(ctx):
    84      toolchain_identifier = "msvc_x64"
    85      host_system_name = "local"
    86      target_system_name = "local"
    87      target_cpu = "x64_windows"
    88      target_libc = "msvcrt"
    89      compiler = "msvc-cl"
    90      abi_version = "local"
    91      abi_libc_version = "local"
    92      cc_target_os = None
    93      builtin_sysroot = None
    94  
    95      cxx_builtin_include_directories = [
    96          "/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include",
    97          "/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include-fixed",
    98          "/dt7/usr/include",
    99          "/dt7/usr/include/c++/7",
   100          "/dt7/usr/include/c++/7/x86_64-pc-linux-gnu",
   101          "/dt7/usr/include/c++/7/backward",
   102      ]
   103  
   104      cpp_link_nodeps_dynamic_library_action = action_config(
   105          action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library,
   106          implies = [
   107              "nologo",
   108              "shared_flag",
   109              "linkstamps",
   110              "output_execpath_flags",
   111              "input_param_flags",
   112              "user_link_flags",
   113              "default_link_flags",
   114              "linker_subsystem_flag",
   115              "linker_param_file",
   116              "msvc_env",
   117              "no_stripping",
   118              "has_configured_linker_path",
   119              "def_file",
   120          ],
   121          tools = [tool(path = "")],
   122      )
   123  
   124      cpp_link_static_library_action = action_config(
   125          action_name = ACTION_NAMES.cpp_link_static_library,
   126          implies = [
   127              "nologo",
   128              "archiver_flags",
   129              "input_param_flags",
   130              "linker_param_file",
   131              "msvc_env",
   132          ],
   133          tools = [tool(path = "")],
   134      )
   135  
   136      assemble_action = action_config(
   137          action_name = ACTION_NAMES.assemble,
   138          implies = [
   139              "compiler_input_flags",
   140              "compiler_output_flags",
   141              "nologo",
   142              "msvc_env",
   143              "sysroot",
   144          ],
   145          tools = [tool(path = "")],
   146      )
   147  
   148      preprocess_assemble_action = action_config(
   149          action_name = ACTION_NAMES.preprocess_assemble,
   150          implies = [
   151              "compiler_input_flags",
   152              "compiler_output_flags",
   153              "nologo",
   154              "msvc_env",
   155              "sysroot",
   156          ],
   157          tools = [tool(path = "")],
   158      )
   159  
   160      c_compile_action = action_config(
   161          action_name = ACTION_NAMES.c_compile,
   162          implies = [
   163              "compiler_input_flags",
   164              "compiler_output_flags",
   165              "default_compile_flags",
   166              "nologo",
   167              "msvc_env",
   168              "parse_showincludes",
   169              "user_compile_flags",
   170              "sysroot",
   171              "unfiltered_compile_flags",
   172          ],
   173          tools = [tool(path = "")],
   174      )
   175  
   176      cpp_compile_action = action_config(
   177          action_name = ACTION_NAMES.cpp_compile,
   178          implies = [
   179              "compiler_input_flags",
   180              "compiler_output_flags",
   181              "default_compile_flags",
   182              "nologo",
   183              "msvc_env",
   184              "parse_showincludes",
   185              "user_compile_flags",
   186              "sysroot",
   187              "unfiltered_compile_flags",
   188          ],
   189          tools = [tool(path = "")],
   190      )
   191  
   192      cpp_link_executable_action = action_config(
   193          action_name = ACTION_NAMES.cpp_link_executable,
   194          implies = [
   195              "nologo",
   196              "linkstamps",
   197              "output_execpath_flags",
   198              "input_param_flags",
   199              "user_link_flags",
   200              "default_link_flags",
   201              "linker_subsystem_flag",
   202              "linker_param_file",
   203              "msvc_env",
   204              "no_stripping",
   205          ],
   206          tools = [tool(path = "")],
   207      )
   208  
   209      cpp_link_dynamic_library_action = action_config(
   210          action_name = ACTION_NAMES.cpp_link_dynamic_library,
   211          implies = [
   212              "nologo",
   213              "shared_flag",
   214              "linkstamps",
   215              "output_execpath_flags",
   216              "input_param_flags",
   217              "user_link_flags",
   218              "default_link_flags",
   219              "linker_subsystem_flag",
   220              "linker_param_file",
   221              "msvc_env",
   222              "no_stripping",
   223              "has_configured_linker_path",
   224              "def_file",
   225          ],
   226          tools = [tool(path = "")],
   227      )
   228  
   229      action_configs = [
   230          assemble_action,
   231          preprocess_assemble_action,
   232          c_compile_action,
   233          cpp_compile_action,
   234          cpp_link_executable_action,
   235          cpp_link_dynamic_library_action,
   236          cpp_link_nodeps_dynamic_library_action,
   237          cpp_link_static_library_action,
   238      ]
   239  
   240      msvc_link_env_feature = feature(
   241          name = "msvc_link_env",
   242          env_sets = [
   243              env_set(
   244                  actions = all_link_actions +
   245                            [ACTION_NAMES.cpp_link_static_library],
   246                  env_entries = [env_entry(key = "LIB", value = "")],
   247              ),
   248          ],
   249      )
   250  
   251      shared_flag_feature = feature(
   252          name = "shared_flag",
   253          flag_sets = [
   254              flag_set(
   255                  actions = [
   256                      ACTION_NAMES.cpp_link_dynamic_library,
   257                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
   258                  ],
   259                  flag_groups = [flag_group(flags = ["/DLL"])],
   260              ),
   261          ],
   262      )
   263  
   264      determinism_feature = feature(
   265          name = "determinism",
   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(
   272                          flags = [
   273                              "/wd4117",
   274                              "-D__DATE__=\"redacted\"",
   275                              "-D__TIMESTAMP__=\"redacted\"",
   276                              "-D__TIME__=\"redacted\"",
   277                          ],
   278                      ),
   279                  ],
   280              ),
   281          ],
   282      )
   283  
   284      sysroot_feature = feature(
   285          name = "sysroot",
   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                      ACTION_NAMES.cpp_module_codegen,
   296                      ACTION_NAMES.cpp_link_executable,
   297                      ACTION_NAMES.cpp_link_dynamic_library,
   298                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
   299                  ],
   300                  flag_groups = [
   301                      flag_group(
   302                          flags = ["--sysroot=%{sysroot}"],
   303                          iterate_over = "sysroot",
   304                          expand_if_available = "sysroot",
   305                      ),
   306                  ],
   307              ),
   308          ],
   309      )
   310  
   311      unfiltered_compile_flags_feature = feature(
   312          name = "unfiltered_compile_flags",
   313          flag_sets = [
   314              flag_set(
   315                  actions = [
   316                      ACTION_NAMES.preprocess_assemble,
   317                      ACTION_NAMES.c_compile,
   318                      ACTION_NAMES.cpp_compile,
   319                      ACTION_NAMES.cpp_header_parsing,
   320                      ACTION_NAMES.cpp_module_compile,
   321                      ACTION_NAMES.cpp_module_codegen,
   322                  ],
   323                  flag_groups = [
   324                      flag_group(
   325                          flags = ["%{unfiltered_compile_flags}"],
   326                          iterate_over = "unfiltered_compile_flags",
   327                          expand_if_available = "unfiltered_compile_flags",
   328                      ),
   329                  ],
   330              ),
   331          ],
   332      )
   333  
   334      copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
   335  
   336      input_param_flags_feature = feature(
   337          name = "input_param_flags",
   338          flag_sets = [
   339              flag_set(
   340                  actions = [
   341                      ACTION_NAMES.cpp_link_dynamic_library,
   342                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
   343                  ],
   344                  flag_groups = [
   345                      flag_group(
   346                          flags = ["/IMPLIB:%{interface_library_output_path}"],
   347                          expand_if_available = "interface_library_output_path",
   348                      ),
   349                  ],
   350              ),
   351              flag_set(
   352                  actions = all_link_actions,
   353                  flag_groups = [
   354                      flag_group(
   355                          flags = ["%{libopts}"],
   356                          iterate_over = "libopts",
   357                          expand_if_available = "libopts",
   358                      ),
   359                  ],
   360              ),
   361              flag_set(
   362                  actions = all_link_actions +
   363                            [ACTION_NAMES.cpp_link_static_library],
   364                  flag_groups = [
   365                      flag_group(
   366                          iterate_over = "libraries_to_link",
   367                          flag_groups = [
   368                              flag_group(
   369                                  iterate_over = "libraries_to_link.object_files",
   370                                  flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])],
   371                                  expand_if_equal = variable_with_value(
   372                                      name = "libraries_to_link.type",
   373                                      value = "object_file_group",
   374                                  ),
   375                              ),
   376                              flag_group(
   377                                  flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],
   378                                  expand_if_equal = variable_with_value(
   379                                      name = "libraries_to_link.type",
   380                                      value = "object_file",
   381                                  ),
   382                              ),
   383                              flag_group(
   384                                  flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],
   385                                  expand_if_equal = variable_with_value(
   386                                      name = "libraries_to_link.type",
   387                                      value = "interface_library",
   388                                  ),
   389                              ),
   390                              flag_group(
   391                                  flag_groups = [
   392                                      flag_group(
   393                                          flags = ["%{libraries_to_link.name}"],
   394                                          expand_if_false = "libraries_to_link.is_whole_archive",
   395                                      ),
   396                                      flag_group(
   397                                          flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"],
   398                                          expand_if_true = "libraries_to_link.is_whole_archive",
   399                                      ),
   400                                  ],
   401                                  expand_if_equal = variable_with_value(
   402                                      name = "libraries_to_link.type",
   403                                      value = "static_library",
   404                                  ),
   405                              ),
   406                          ],
   407                          expand_if_available = "libraries_to_link",
   408                      ),
   409                  ],
   410              ),
   411          ],
   412      )
   413  
   414      fastbuild_feature = feature(
   415          name = "fastbuild",
   416          flag_sets = [
   417              flag_set(
   418                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   419                  flag_groups = [flag_group(flags = ["/Od", "/Z7"])],
   420              ),
   421              flag_set(
   422                  actions = all_link_actions,
   423                  flag_groups = [
   424                      flag_group(
   425                          flags = ["", "/INCREMENTAL:NO"],
   426                      ),
   427                  ],
   428              ),
   429          ],
   430          implies = ["generate_pdb_file"],
   431      )
   432  
   433      user_compile_flags_feature = feature(
   434          name = "user_compile_flags",
   435          flag_sets = [
   436              flag_set(
   437                  actions = [
   438                      ACTION_NAMES.preprocess_assemble,
   439                      ACTION_NAMES.c_compile,
   440                      ACTION_NAMES.cpp_compile,
   441                      ACTION_NAMES.cpp_header_parsing,
   442                      ACTION_NAMES.cpp_module_compile,
   443                      ACTION_NAMES.cpp_module_codegen,
   444                  ],
   445                  flag_groups = [
   446                      flag_group(
   447                          flags = ["%{user_compile_flags}"],
   448                          iterate_over = "user_compile_flags",
   449                          expand_if_available = "user_compile_flags",
   450                      ),
   451                  ],
   452              ),
   453          ],
   454      )
   455  
   456      archiver_flags_feature = feature(
   457          name = "archiver_flags",
   458          flag_sets = [
   459              flag_set(
   460                  actions = [ACTION_NAMES.cpp_link_static_library],
   461                  flag_groups = [
   462                      flag_group(
   463                          flags = ["/OUT:%{output_execpath}"],
   464                          expand_if_available = "output_execpath",
   465                      ),
   466                  ],
   467              ),
   468          ],
   469      )
   470  
   471      default_link_flags_feature = feature(
   472          name = "default_link_flags",
   473          enabled = True,
   474          flag_sets = [
   475              flag_set(
   476                  actions = all_link_actions,
   477                  flag_groups = [flag_group(flags = ["/MACHINE:X64"])],
   478              ),
   479          ],
   480      )
   481  
   482      static_link_msvcrt_feature = feature(name = "static_link_msvcrt")
   483  
   484      dynamic_link_msvcrt_debug_feature = feature(
   485          name = "dynamic_link_msvcrt_debug",
   486          flag_sets = [
   487              flag_set(
   488                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   489                  flag_groups = [flag_group(flags = ["/MDd"])],
   490              ),
   491              flag_set(
   492                  actions = all_link_actions,
   493                  flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])],
   494              ),
   495          ],
   496          requires = [feature_set(features = ["dbg"])],
   497      )
   498  
   499      dbg_feature = feature(
   500          name = "dbg",
   501          flag_sets = [
   502              flag_set(
   503                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   504                  flag_groups = [flag_group(flags = ["/Od", "/Z7"])],
   505              ),
   506              flag_set(
   507                  actions = all_link_actions,
   508                  flag_groups = [
   509                      flag_group(
   510                          flags = ["", "/INCREMENTAL:NO"],
   511                      ),
   512                  ],
   513              ),
   514          ],
   515          implies = ["generate_pdb_file"],
   516      )
   517  
   518      opt_feature = feature(
   519          name = "opt",
   520          flag_sets = [
   521              flag_set(
   522                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   523                  flag_groups = [flag_group(flags = ["/O2"])],
   524              ),
   525          ],
   526          implies = ["frame_pointer"],
   527      )
   528  
   529      supports_interface_shared_libraries_feature = feature(
   530          name = "supports_interface_shared_libraries",
   531          enabled = True,
   532      )
   533  
   534      user_link_flags_feature = feature(
   535          name = "user_link_flags",
   536          flag_sets = [
   537              flag_set(
   538                  actions = all_link_actions,
   539                  flag_groups = [
   540                      flag_group(
   541                          flags = ["%{user_link_flags}"],
   542                          iterate_over = "user_link_flags",
   543                          expand_if_available = "user_link_flags",
   544                      ),
   545                  ],
   546              ),
   547          ],
   548      )
   549  
   550      default_compile_flags_feature = feature(
   551          name = "default_compile_flags",
   552          enabled = True,
   553          flag_sets = [
   554              flag_set(
   555                  actions = [
   556                      ACTION_NAMES.assemble,
   557                      ACTION_NAMES.preprocess_assemble,
   558                      ACTION_NAMES.linkstamp_compile,
   559                      ACTION_NAMES.c_compile,
   560                      ACTION_NAMES.cpp_compile,
   561                      ACTION_NAMES.cpp_header_parsing,
   562                      ACTION_NAMES.cpp_module_compile,
   563                      ACTION_NAMES.cpp_module_codegen,
   564                      ACTION_NAMES.lto_backend,
   565                      ACTION_NAMES.clif_match,
   566                  ],
   567                  flag_groups = [
   568                      flag_group(
   569                          flags = [
   570                              "/DCOMPILER_MSVC",
   571                              "/DNOMINMAX",
   572                              "/D_WIN32_WINNT=0x0601",
   573                              "/D_CRT_SECURE_NO_DEPRECATE",
   574                              "/D_CRT_SECURE_NO_WARNINGS",
   575                              "/bigobj",
   576                              "/Zm500",
   577                              "/EHsc",
   578                              "/wd4351",
   579                              "/wd4291",
   580                              "/wd4250",
   581                              "/wd4996",
   582                          ],
   583                      ),
   584                  ],
   585              ),
   586          ],
   587      )
   588  
   589      msvc_compile_env_feature = feature(
   590          name = "msvc_compile_env",
   591          env_sets = [
   592              env_set(
   593                  actions = [
   594                      ACTION_NAMES.c_compile,
   595                      ACTION_NAMES.cpp_compile,
   596                      ACTION_NAMES.cpp_module_compile,
   597                      ACTION_NAMES.cpp_module_codegen,
   598                      ACTION_NAMES.cpp_header_parsing,
   599                      ACTION_NAMES.assemble,
   600                      ACTION_NAMES.preprocess_assemble,
   601                  ],
   602                  env_entries = [env_entry(key = "INCLUDE", value = "")],
   603              ),
   604          ],
   605      )
   606  
   607      preprocessor_defines_feature = feature(
   608          name = "preprocessor_defines",
   609          enabled = True,
   610          flag_sets = [
   611              flag_set(
   612                  actions = [
   613                      ACTION_NAMES.assemble,
   614                      ACTION_NAMES.preprocess_assemble,
   615                      ACTION_NAMES.c_compile,
   616                      ACTION_NAMES.cpp_compile,
   617                      ACTION_NAMES.cpp_header_parsing,
   618                      ACTION_NAMES.cpp_module_compile,
   619                  ],
   620                  flag_groups = [
   621                      flag_group(
   622                          flags = ["/D%{preprocessor_defines}"],
   623                          iterate_over = "preprocessor_defines",
   624                      ),
   625                  ],
   626              ),
   627          ],
   628      )
   629  
   630      generate_pdb_file_feature = feature(
   631          name = "generate_pdb_file",
   632          requires = [
   633              feature_set(features = ["dbg"]),
   634              feature_set(features = ["fastbuild"]),
   635          ],
   636      )
   637  
   638      output_execpath_flags_feature = feature(
   639          name = "output_execpath_flags",
   640          flag_sets = [
   641              flag_set(
   642                  actions = all_link_actions,
   643                  flag_groups = [
   644                      flag_group(
   645                          flags = ["/OUT:%{output_execpath}"],
   646                          expand_if_available = "output_execpath",
   647                      ),
   648                  ],
   649              ),
   650          ],
   651      )
   652  
   653      dynamic_link_msvcrt_no_debug_feature = feature(
   654          name = "dynamic_link_msvcrt_no_debug",
   655          flag_sets = [
   656              flag_set(
   657                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   658                  flag_groups = [flag_group(flags = ["/MD"])],
   659              ),
   660              flag_set(
   661                  actions = all_link_actions,
   662                  flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])],
   663              ),
   664          ],
   665          requires = [
   666              feature_set(features = ["fastbuild"]),
   667              feature_set(features = ["opt"]),
   668          ],
   669      )
   670  
   671      disable_assertions_feature = feature(
   672          name = "disable_assertions",
   673          enabled = True,
   674          flag_sets = [
   675              flag_set(
   676                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   677                  flag_groups = [flag_group(flags = ["/DNDEBUG"])],
   678                  with_features = [with_feature_set(features = ["opt"])],
   679              ),
   680          ],
   681      )
   682  
   683      has_configured_linker_path_feature = feature(name = "has_configured_linker_path")
   684  
   685      supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
   686  
   687      no_stripping_feature = feature(name = "no_stripping")
   688  
   689      linker_param_file_feature = feature(
   690          name = "linker_param_file",
   691          flag_sets = [
   692              flag_set(
   693                  actions = all_link_actions +
   694                            [ACTION_NAMES.cpp_link_static_library],
   695                  flag_groups = [
   696                      flag_group(
   697                          flags = ["@%{linker_param_file}"],
   698                          expand_if_available = "linker_param_file",
   699                      ),
   700                  ],
   701              ),
   702          ],
   703      )
   704  
   705      ignore_noisy_warnings_feature = feature(
   706          name = "ignore_noisy_warnings",
   707          enabled = True,
   708          flag_sets = [
   709              flag_set(
   710                  actions = [ACTION_NAMES.cpp_link_static_library],
   711                  flag_groups = [flag_group(flags = ["/ignore:4221"])],
   712              ),
   713          ],
   714      )
   715  
   716      no_legacy_features_feature = feature(name = "no_legacy_features")
   717  
   718      parse_showincludes_feature = feature(
   719          name = "parse_showincludes",
   720          flag_sets = [
   721              flag_set(
   722                  actions = [
   723                      ACTION_NAMES.preprocess_assemble,
   724                      ACTION_NAMES.c_compile,
   725                      ACTION_NAMES.cpp_compile,
   726                      ACTION_NAMES.cpp_module_compile,
   727                      ACTION_NAMES.cpp_header_parsing,
   728                  ],
   729                  flag_groups = [flag_group(flags = ["/showIncludes"])],
   730              ),
   731          ],
   732      )
   733  
   734      static_link_msvcrt_no_debug_feature = feature(
   735          name = "static_link_msvcrt_no_debug",
   736          flag_sets = [
   737              flag_set(
   738                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   739                  flag_groups = [flag_group(flags = ["/MT"])],
   740              ),
   741              flag_set(
   742                  actions = all_link_actions,
   743                  flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])],
   744              ),
   745          ],
   746          requires = [
   747              feature_set(features = ["fastbuild"]),
   748              feature_set(features = ["opt"]),
   749          ],
   750      )
   751  
   752      treat_warnings_as_errors_feature = feature(
   753          name = "treat_warnings_as_errors",
   754          flag_sets = [
   755              flag_set(
   756                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   757                  flag_groups = [flag_group(flags = ["/WX"])],
   758              ),
   759          ],
   760      )
   761  
   762      windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols")
   763  
   764      no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols")
   765  
   766      include_paths_feature = feature(
   767          name = "include_paths",
   768          enabled = True,
   769          flag_sets = [
   770              flag_set(
   771                  actions = [
   772                      ACTION_NAMES.assemble,
   773                      ACTION_NAMES.preprocess_assemble,
   774                      ACTION_NAMES.c_compile,
   775                      ACTION_NAMES.cpp_compile,
   776                      ACTION_NAMES.cpp_header_parsing,
   777                      ACTION_NAMES.cpp_module_compile,
   778                  ],
   779                  flag_groups = [
   780                      flag_group(
   781                          flags = ["/I%{quote_include_paths}"],
   782                          iterate_over = "quote_include_paths",
   783                      ),
   784                      flag_group(
   785                          flags = ["/I%{include_paths}"],
   786                          iterate_over = "include_paths",
   787                      ),
   788                      flag_group(
   789                          flags = ["/I%{system_include_paths}"],
   790                          iterate_over = "system_include_paths",
   791                      ),
   792                  ],
   793              ),
   794          ],
   795      )
   796  
   797      linkstamps_feature = feature(
   798          name = "linkstamps",
   799          flag_sets = [
   800              flag_set(
   801                  actions = all_link_actions,
   802                  flag_groups = [
   803                      flag_group(
   804                          flags = ["%{linkstamp_paths}"],
   805                          iterate_over = "linkstamp_paths",
   806                          expand_if_available = "linkstamp_paths",
   807                      ),
   808                  ],
   809              ),
   810          ],
   811      )
   812  
   813      targets_windows_feature = feature(
   814          name = "targets_windows",
   815          enabled = True,
   816          implies = ["copy_dynamic_libraries_to_binary"],
   817      )
   818  
   819      linker_subsystem_flag_feature = feature(
   820          name = "linker_subsystem_flag",
   821          flag_sets = [
   822              flag_set(
   823                  actions = all_link_actions,
   824                  flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])],
   825              ),
   826          ],
   827      )
   828  
   829      static_link_msvcrt_debug_feature = feature(
   830          name = "static_link_msvcrt_debug",
   831          flag_sets = [
   832              flag_set(
   833                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   834                  flag_groups = [flag_group(flags = ["/MTd"])],
   835              ),
   836              flag_set(
   837                  actions = all_link_actions,
   838                  flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])],
   839              ),
   840          ],
   841          requires = [feature_set(features = ["dbg"])],
   842      )
   843  
   844      frame_pointer_feature = feature(
   845          name = "frame_pointer",
   846          flag_sets = [
   847              flag_set(
   848                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   849                  flag_groups = [flag_group(flags = ["/Oy-"])],
   850              ),
   851          ],
   852      )
   853  
   854      compiler_output_flags_feature = feature(
   855          name = "compiler_output_flags",
   856          flag_sets = [
   857              flag_set(
   858                  actions = [ACTION_NAMES.assemble],
   859                  flag_groups = [
   860                      flag_group(
   861                          flag_groups = [
   862                              flag_group(
   863                                  flags = ["/Fo%{output_file}", "/Zi"],
   864                                  expand_if_available = "output_file",
   865                                  expand_if_not_available = "output_assembly_file",
   866                              ),
   867                          ],
   868                          expand_if_not_available = "output_preprocess_file",
   869                      ),
   870                  ],
   871              ),
   872              flag_set(
   873                  actions = [
   874                      ACTION_NAMES.preprocess_assemble,
   875                      ACTION_NAMES.c_compile,
   876                      ACTION_NAMES.cpp_compile,
   877                      ACTION_NAMES.cpp_header_parsing,
   878                      ACTION_NAMES.cpp_module_compile,
   879                      ACTION_NAMES.cpp_module_codegen,
   880                  ],
   881                  flag_groups = [
   882                      flag_group(
   883                          flag_groups = [
   884                              flag_group(
   885                                  flags = ["/Fo%{output_file}"],
   886                                  expand_if_not_available = "output_preprocess_file",
   887                              ),
   888                          ],
   889                          expand_if_available = "output_file",
   890                          expand_if_not_available = "output_assembly_file",
   891                      ),
   892                      flag_group(
   893                          flag_groups = [
   894                              flag_group(
   895                                  flags = ["/Fa%{output_file}"],
   896                                  expand_if_available = "output_assembly_file",
   897                              ),
   898                          ],
   899                          expand_if_available = "output_file",
   900                      ),
   901                      flag_group(
   902                          flag_groups = [
   903                              flag_group(
   904                                  flags = ["/P", "/Fi%{output_file}"],
   905                                  expand_if_available = "output_preprocess_file",
   906                              ),
   907                          ],
   908                          expand_if_available = "output_file",
   909                      ),
   910                  ],
   911              ),
   912          ],
   913      )
   914  
   915      nologo_feature = feature(
   916          name = "nologo",
   917          flag_sets = [
   918              flag_set(
   919                  actions = [
   920                      ACTION_NAMES.c_compile,
   921                      ACTION_NAMES.cpp_compile,
   922                      ACTION_NAMES.cpp_module_compile,
   923                      ACTION_NAMES.cpp_module_codegen,
   924                      ACTION_NAMES.cpp_header_parsing,
   925                      ACTION_NAMES.assemble,
   926                      ACTION_NAMES.preprocess_assemble,
   927                      ACTION_NAMES.cpp_link_executable,
   928                      ACTION_NAMES.cpp_link_dynamic_library,
   929                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
   930                      ACTION_NAMES.cpp_link_static_library,
   931                  ],
   932                  flag_groups = [flag_group(flags = ["/nologo"])],
   933              ),
   934          ],
   935      )
   936  
   937      smaller_binary_feature = feature(
   938          name = "smaller_binary",
   939          enabled = True,
   940          flag_sets = [
   941              flag_set(
   942                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
   943                  flag_groups = [flag_group(flags = ["/Gy", "/Gw"])],
   944                  with_features = [with_feature_set(features = ["opt"])],
   945              ),
   946              flag_set(
   947                  actions = all_link_actions,
   948                  flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])],
   949                  with_features = [with_feature_set(features = ["opt"])],
   950              ),
   951          ],
   952      )
   953  
   954      compiler_input_flags_feature = feature(
   955          name = "compiler_input_flags",
   956          flag_sets = [
   957              flag_set(
   958                  actions = [
   959                      ACTION_NAMES.assemble,
   960                      ACTION_NAMES.preprocess_assemble,
   961                      ACTION_NAMES.c_compile,
   962                      ACTION_NAMES.cpp_compile,
   963                      ACTION_NAMES.cpp_header_parsing,
   964                      ACTION_NAMES.cpp_module_compile,
   965                      ACTION_NAMES.cpp_module_codegen,
   966                  ],
   967                  flag_groups = [
   968                      flag_group(
   969                          flags = ["/c", "%{source_file}"],
   970                          expand_if_available = "source_file",
   971                      ),
   972                  ],
   973              ),
   974          ],
   975      )
   976  
   977      def_file_feature = feature(
   978          name = "def_file",
   979          flag_sets = [
   980              flag_set(
   981                  actions = all_link_actions,
   982                  flag_groups = [
   983                      flag_group(
   984                          flags = ["/DEF:%{def_file_path}", "/ignore:4070"],
   985                          expand_if_available = "def_file_path",
   986                      ),
   987                  ],
   988              ),
   989          ],
   990      )
   991  
   992      msvc_env_feature = feature(
   993          name = "msvc_env",
   994          env_sets = [
   995              env_set(
   996                  actions = [
   997                      ACTION_NAMES.c_compile,
   998                      ACTION_NAMES.cpp_compile,
   999                      ACTION_NAMES.cpp_module_compile,
  1000                      ACTION_NAMES.cpp_module_codegen,
  1001                      ACTION_NAMES.cpp_header_parsing,
  1002                      ACTION_NAMES.assemble,
  1003                      ACTION_NAMES.preprocess_assemble,
  1004                      ACTION_NAMES.cpp_link_executable,
  1005                      ACTION_NAMES.cpp_link_dynamic_library,
  1006                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1007                      ACTION_NAMES.cpp_link_static_library,
  1008                  ],
  1009                  env_entries = [
  1010                      env_entry(key = "PATH", value = ""),
  1011                      env_entry(key = "TMP", value = ""),
  1012                      env_entry(key = "TEMP", value = ""),
  1013                  ],
  1014              ),
  1015          ],
  1016          implies = ["msvc_compile_env", "msvc_link_env"],
  1017      )
  1018  
  1019      features = [
  1020          no_legacy_features_feature,
  1021          nologo_feature,
  1022          has_configured_linker_path_feature,
  1023          no_stripping_feature,
  1024          targets_windows_feature,
  1025          copy_dynamic_libraries_to_binary_feature,
  1026          default_compile_flags_feature,
  1027          msvc_env_feature,
  1028          msvc_compile_env_feature,
  1029          msvc_link_env_feature,
  1030          include_paths_feature,
  1031          preprocessor_defines_feature,
  1032          parse_showincludes_feature,
  1033          generate_pdb_file_feature,
  1034          shared_flag_feature,
  1035          linkstamps_feature,
  1036          output_execpath_flags_feature,
  1037          archiver_flags_feature,
  1038          input_param_flags_feature,
  1039          linker_subsystem_flag_feature,
  1040          user_link_flags_feature,
  1041          default_link_flags_feature,
  1042          linker_param_file_feature,
  1043          static_link_msvcrt_feature,
  1044          static_link_msvcrt_no_debug_feature,
  1045          dynamic_link_msvcrt_no_debug_feature,
  1046          static_link_msvcrt_debug_feature,
  1047          dynamic_link_msvcrt_debug_feature,
  1048          dbg_feature,
  1049          fastbuild_feature,
  1050          opt_feature,
  1051          frame_pointer_feature,
  1052          disable_assertions_feature,
  1053          determinism_feature,
  1054          treat_warnings_as_errors_feature,
  1055          smaller_binary_feature,
  1056          ignore_noisy_warnings_feature,
  1057          user_compile_flags_feature,
  1058          sysroot_feature,
  1059          unfiltered_compile_flags_feature,
  1060          compiler_output_flags_feature,
  1061          compiler_input_flags_feature,
  1062          def_file_feature,
  1063          windows_export_all_symbols_feature,
  1064          no_windows_export_all_symbols_feature,
  1065          supports_dynamic_linker_feature,
  1066          supports_interface_shared_libraries_feature,
  1067      ]
  1068  
  1069      artifact_name_patterns = [
  1070          artifact_name_pattern(
  1071              category_name = "object_file",
  1072              prefix = "",
  1073              extension = ".obj",
  1074          ),
  1075          artifact_name_pattern(
  1076              category_name = "static_library",
  1077              prefix = "",
  1078              extension = ".lib",
  1079          ),
  1080          artifact_name_pattern(
  1081              category_name = "alwayslink_static_library",
  1082              prefix = "",
  1083              extension = ".lo.lib",
  1084          ),
  1085          artifact_name_pattern(
  1086              category_name = "executable",
  1087              prefix = "",
  1088              extension = ".exe",
  1089          ),
  1090          artifact_name_pattern(
  1091              category_name = "dynamic_library",
  1092              prefix = "",
  1093              extension = ".dll",
  1094          ),
  1095          artifact_name_pattern(
  1096              category_name = "interface_library",
  1097              prefix = "",
  1098              extension = ".if.lib",
  1099          ),
  1100      ]
  1101  
  1102      make_variables = []
  1103  
  1104      tool_paths = [
  1105          tool_path(name = "ar", path = ""),
  1106          tool_path(name = "ml", path = ""),
  1107          tool_path(name = "cpp", path = ""),
  1108          tool_path(name = "gcc", path = ""),
  1109          tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"),
  1110          tool_path(name = "ld", path = ""),
  1111          tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"),
  1112          tool_path(
  1113              name = "objcopy",
  1114              path = "wrapper/bin/msvc_nop.bat",
  1115          ),
  1116          tool_path(
  1117              name = "objdump",
  1118              path = "wrapper/bin/msvc_nop.bat",
  1119          ),
  1120          tool_path(
  1121              name = "strip",
  1122              path = "wrapper/bin/msvc_nop.bat",
  1123          ),
  1124      ]
  1125  
  1126      return cc_common.create_cc_toolchain_config_info(
  1127          ctx = ctx,
  1128          features = features,
  1129          action_configs = action_configs,
  1130          artifact_name_patterns = artifact_name_patterns,
  1131          cxx_builtin_include_directories = cxx_builtin_include_directories,
  1132          toolchain_identifier = toolchain_identifier,
  1133          host_system_name = host_system_name,
  1134          target_system_name = target_system_name,
  1135          target_cpu = target_cpu,
  1136          target_libc = target_libc,
  1137          compiler = compiler,
  1138          abi_version = abi_version,
  1139          abi_libc_version = abi_libc_version,
  1140          tool_paths = tool_paths,
  1141          make_variables = make_variables,
  1142          builtin_sysroot = builtin_sysroot,
  1143          cc_target_os = None,
  1144      )
  1145  
  1146  def _windows_msys_mingw_impl(ctx):
  1147      toolchain_identifier = "msys_x64_mingw"
  1148      host_system_name = "local"
  1149      target_system_name = "local"
  1150      target_cpu = "x64_windows"
  1151      target_libc = "mingw"
  1152      compiler = "mingw-gcc"
  1153      abi_version = "local"
  1154      abi_libc_version = "local"
  1155      cc_target_os = None
  1156      builtin_sysroot = None
  1157      action_configs = []
  1158  
  1159      targets_windows_feature = feature(
  1160          name = "targets_windows",
  1161          implies = ["copy_dynamic_libraries_to_binary"],
  1162          enabled = True,
  1163      )
  1164  
  1165      copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
  1166  
  1167      gcc_env_feature = feature(
  1168          name = "gcc_env",
  1169          enabled = True,
  1170          env_sets = [
  1171              env_set(
  1172                  actions = [
  1173                      ACTION_NAMES.c_compile,
  1174                      ACTION_NAMES.cpp_compile,
  1175                      ACTION_NAMES.cpp_module_compile,
  1176                      ACTION_NAMES.cpp_module_codegen,
  1177                      ACTION_NAMES.cpp_header_parsing,
  1178                      ACTION_NAMES.assemble,
  1179                      ACTION_NAMES.preprocess_assemble,
  1180                      ACTION_NAMES.cpp_link_executable,
  1181                      ACTION_NAMES.cpp_link_dynamic_library,
  1182                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1183                      ACTION_NAMES.cpp_link_static_library,
  1184                  ],
  1185                  env_entries = [
  1186                      env_entry(key = "PATH", value = "NOT_USED"),
  1187                  ],
  1188              ),
  1189          ],
  1190      )
  1191  
  1192      msys_mingw_flags = [
  1193      ]
  1194      msys_mingw_link_flags = [
  1195      ]
  1196  
  1197      default_compile_flags_feature = feature(
  1198          name = "default_compile_flags",
  1199          enabled = True,
  1200          flag_sets = [
  1201              flag_set(
  1202                  actions = [
  1203                      ACTION_NAMES.assemble,
  1204                      ACTION_NAMES.preprocess_assemble,
  1205                      ACTION_NAMES.linkstamp_compile,
  1206                      ACTION_NAMES.c_compile,
  1207                      ACTION_NAMES.cpp_compile,
  1208                      ACTION_NAMES.cpp_header_parsing,
  1209                      ACTION_NAMES.cpp_module_compile,
  1210                      ACTION_NAMES.cpp_module_codegen,
  1211                      ACTION_NAMES.lto_backend,
  1212                      ACTION_NAMES.clif_match,
  1213                  ],
  1214              ),
  1215              flag_set(
  1216                  actions = [
  1217                      ACTION_NAMES.linkstamp_compile,
  1218                      ACTION_NAMES.cpp_compile,
  1219                      ACTION_NAMES.cpp_header_parsing,
  1220                      ACTION_NAMES.cpp_module_compile,
  1221                      ACTION_NAMES.cpp_module_codegen,
  1222                      ACTION_NAMES.lto_backend,
  1223                      ACTION_NAMES.clif_match,
  1224                  ],
  1225                  flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []),
  1226              ),
  1227          ],
  1228      )
  1229  
  1230      default_link_flags_feature = feature(
  1231          name = "default_link_flags",
  1232          enabled = True,
  1233          flag_sets = [
  1234              flag_set(
  1235                  actions = all_link_actions,
  1236                  flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []),
  1237              ),
  1238          ],
  1239      )
  1240  
  1241      supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1242  
  1243      features = [
  1244          targets_windows_feature,
  1245          copy_dynamic_libraries_to_binary_feature,
  1246          gcc_env_feature,
  1247          default_compile_flags_feature,
  1248          default_link_flags_feature,
  1249          supports_dynamic_linker_feature,
  1250      ]
  1251  
  1252      cxx_builtin_include_directories = [
  1253      ]
  1254  
  1255      artifact_name_patterns = [
  1256          artifact_name_pattern(
  1257              category_name = "executable",
  1258              prefix = "",
  1259              extension = ".exe",
  1260          ),
  1261      ]
  1262  
  1263      make_variables = []
  1264      tool_paths = [
  1265      ]
  1266  
  1267      return cc_common.create_cc_toolchain_config_info(
  1268          ctx = ctx,
  1269          features = features,
  1270          action_configs = action_configs,
  1271          artifact_name_patterns = artifact_name_patterns,
  1272          cxx_builtin_include_directories = cxx_builtin_include_directories,
  1273          toolchain_identifier = toolchain_identifier,
  1274          host_system_name = host_system_name,
  1275          target_system_name = target_system_name,
  1276          target_cpu = target_cpu,
  1277          target_libc = target_libc,
  1278          compiler = compiler,
  1279          abi_version = abi_version,
  1280          abi_libc_version = abi_libc_version,
  1281          tool_paths = tool_paths,
  1282          make_variables = make_variables,
  1283          builtin_sysroot = builtin_sysroot,
  1284          cc_target_os = cc_target_os,
  1285      )
  1286  
  1287  def _armeabi_impl(ctx):
  1288      toolchain_identifier = "stub_armeabi-v7a"
  1289      host_system_name = "armeabi-v7a"
  1290      target_system_name = "armeabi-v7a"
  1291      target_cpu = "armeabi-v7a"
  1292      target_libc = "armeabi-v7a"
  1293      compiler = "compiler"
  1294      abi_version = "armeabi-v7a"
  1295      abi_libc_version = "armeabi-v7a"
  1296      cc_target_os = None
  1297      builtin_sysroot = None
  1298      action_configs = []
  1299  
  1300      supports_pic_feature = feature(name = "supports_pic", enabled = True)
  1301      supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1302      features = [supports_dynamic_linker_feature, supports_pic_feature]
  1303  
  1304      cxx_builtin_include_directories = []
  1305      artifact_name_patterns = []
  1306      make_variables = []
  1307  
  1308      tool_paths = [
  1309          tool_path(name = "ar", path = "/bin/false"),
  1310          tool_path(name = "compat-ld", path = "/bin/false"),
  1311          tool_path(name = "cpp", path = "/bin/false"),
  1312          tool_path(name = "dwp", path = "/bin/false"),
  1313          tool_path(name = "gcc", path = "/bin/false"),
  1314          tool_path(name = "gcov", path = "/bin/false"),
  1315          tool_path(name = "ld", path = "/bin/false"),
  1316          tool_path(name = "nm", path = "/bin/false"),
  1317          tool_path(name = "objcopy", path = "/bin/false"),
  1318          tool_path(name = "objdump", path = "/bin/false"),
  1319          tool_path(name = "strip", path = "/bin/false"),
  1320      ]
  1321  
  1322      return cc_common.create_cc_toolchain_config_info(
  1323          ctx = ctx,
  1324          features = features,
  1325          action_configs = action_configs,
  1326          artifact_name_patterns = artifact_name_patterns,
  1327          cxx_builtin_include_directories = cxx_builtin_include_directories,
  1328          toolchain_identifier = toolchain_identifier,
  1329          host_system_name = host_system_name,
  1330          target_system_name = target_system_name,
  1331          target_cpu = target_cpu,
  1332          target_libc = target_libc,
  1333          compiler = compiler,
  1334          abi_version = abi_version,
  1335          abi_libc_version = abi_libc_version,
  1336          tool_paths = tool_paths,
  1337          make_variables = make_variables,
  1338          builtin_sysroot = builtin_sysroot,
  1339          cc_target_os = cc_target_os,
  1340      )
  1341  
  1342  def _impl(ctx):
  1343      if ctx.attr.cpu == "armeabi-v7a":
  1344          return _armeabi_impl(ctx)
  1345      elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "msvc-cl":
  1346          return _windows_msvc_impl(ctx)
  1347      elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc":
  1348          return _windows_msys_mingw_impl(ctx)
  1349  
  1350      tool_paths = [
  1351          tool_path(name = "ar", path = "/usr/bin/ar"),
  1352          tool_path(name = "ld", path = "/usr/bin/ld"),
  1353          tool_path(name = "cpp", path = "/usr/bin/cpp"),
  1354          tool_path(name = "gcc", path = "/dt7/usr/bin/gcc"),
  1355          tool_path(name = "dwp", path = "/usr/bin/dwp"),
  1356          tool_path(name = "gcov", path = "/usr/bin/gcov"),
  1357          tool_path(name = "nm", path = "/usr/bin/nm"),
  1358          tool_path(name = "objcopy", path = "/usr/bin/objcopy"),
  1359          tool_path(name = "objdump", path = "/usr/bin/objdump"),
  1360          tool_path(name = "strip", path = "/usr/bin/strip"),
  1361      ]
  1362  
  1363      cxx_builtin_include_directories = [
  1364          "/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include",
  1365          "/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include-fixed",
  1366          "/dt7/usr/include",
  1367          "/dt7/usr/include/c++/7",
  1368          "/dt7/usr/include/c++/7/x86_64-pc-linux-gnu",
  1369          "/dt7/usr/include/c++/7/backward",
  1370      ]
  1371  
  1372      action_configs = []
  1373  
  1374      compile_flags = [
  1375          "-U_FORTIFY_SOURCE",
  1376          "-fstack-protector",
  1377          "-Wall",
  1378          "-Wunused-but-set-parameter",
  1379          "-Wno-free-nonheap-object",
  1380          "-fno-omit-frame-pointer",
  1381      ]
  1382  
  1383      dbg_compile_flags = [
  1384          "-g",
  1385      ]
  1386  
  1387      opt_compile_flags = [
  1388          "-g0",
  1389          "-O2",
  1390          "-D_FORTIFY_SOURCE=1",
  1391          "-DNDEBUG",
  1392          "-ffunction-sections",
  1393          "-fdata-sections",
  1394      ]
  1395  
  1396      cxx_flags = [
  1397          "-std=c++0x",
  1398      ]
  1399  
  1400      link_flags = [
  1401          "-fuse-ld=gold",
  1402          "-Wl,-no-as-needed",
  1403          "-Wl,-z,relro,-z,now",
  1404          "-B/dt7/usr/bin",
  1405          "-pass-exit-codes",
  1406          "-lstdc++",
  1407          "-lm",
  1408      ]
  1409  
  1410      opt_link_flags = [
  1411          "-Wl,--gc-sections",
  1412      ]
  1413  
  1414      unfiltered_compile_flags = [
  1415          "-fno-canonical-system-headers",
  1416          "-Wno-builtin-macro-redefined",
  1417          "-D__DATE__=\"redacted\"",
  1418          "-D__TIMESTAMP__=\"redacted\"",
  1419          "-D__TIME__=\"redacted\"",
  1420      ]
  1421  
  1422      targets_windows_feature = feature(
  1423          name = "targets_windows",
  1424          implies = ["copy_dynamic_libraries_to_binary"],
  1425          enabled = True,
  1426      )
  1427  
  1428      copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")
  1429  
  1430      gcc_env_feature = feature(
  1431          name = "gcc_env",
  1432          enabled = True,
  1433          env_sets = [
  1434              env_set(
  1435                  actions = [
  1436                      ACTION_NAMES.c_compile,
  1437                      ACTION_NAMES.cpp_compile,
  1438                      ACTION_NAMES.cpp_module_compile,
  1439                      ACTION_NAMES.cpp_module_codegen,
  1440                      ACTION_NAMES.cpp_header_parsing,
  1441                      ACTION_NAMES.assemble,
  1442                      ACTION_NAMES.preprocess_assemble,
  1443                      ACTION_NAMES.cpp_link_executable,
  1444                      ACTION_NAMES.cpp_link_dynamic_library,
  1445                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1446                      ACTION_NAMES.cpp_link_static_library,
  1447                  ],
  1448                  env_entries = [
  1449                      env_entry(key = "PATH", value = "NOT_USED"),
  1450                  ],
  1451              ),
  1452          ],
  1453      )
  1454  
  1455      windows_features = [
  1456          targets_windows_feature,
  1457          copy_dynamic_libraries_to_binary_feature,
  1458          gcc_env_feature,
  1459      ]
  1460  
  1461      coverage_feature = feature(
  1462          name = "coverage",
  1463          provides = ["profile"],
  1464          flag_sets = [
  1465              flag_set(
  1466                  actions = [
  1467                      ACTION_NAMES.preprocess_assemble,
  1468                      ACTION_NAMES.c_compile,
  1469                      ACTION_NAMES.cpp_compile,
  1470                      ACTION_NAMES.cpp_header_parsing,
  1471                      ACTION_NAMES.cpp_module_compile,
  1472                  ],
  1473                  flag_groups = [
  1474                      flag_group(flags = ["--coverage"]),
  1475                  ],
  1476              ),
  1477              flag_set(
  1478                  actions = [
  1479                      ACTION_NAMES.cpp_link_dynamic_library,
  1480                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1481                      ACTION_NAMES.cpp_link_executable,
  1482                  ],
  1483                  flag_groups = [
  1484                      flag_group(flags = ["--coverage"]),
  1485                  ],
  1486              ),
  1487          ],
  1488      )
  1489  
  1490      supports_pic_feature = feature(
  1491          name = "supports_pic",
  1492          enabled = True,
  1493      )
  1494      supports_start_end_lib_feature = feature(
  1495          name = "supports_start_end_lib",
  1496          enabled = True,
  1497      )
  1498  
  1499      default_compile_flags_feature = feature(
  1500          name = "default_compile_flags",
  1501          enabled = True,
  1502          flag_sets = [
  1503              flag_set(
  1504                  actions = [
  1505                      ACTION_NAMES.assemble,
  1506                      ACTION_NAMES.preprocess_assemble,
  1507                      ACTION_NAMES.linkstamp_compile,
  1508                      ACTION_NAMES.c_compile,
  1509                      ACTION_NAMES.cpp_compile,
  1510                      ACTION_NAMES.cpp_header_parsing,
  1511                      ACTION_NAMES.cpp_module_compile,
  1512                      ACTION_NAMES.cpp_module_codegen,
  1513                      ACTION_NAMES.lto_backend,
  1514                      ACTION_NAMES.clif_match,
  1515                  ],
  1516                  flag_groups = ([flag_group(flags = compile_flags)] if compile_flags else []),
  1517              ),
  1518              flag_set(
  1519                  actions = [
  1520                      ACTION_NAMES.assemble,
  1521                      ACTION_NAMES.preprocess_assemble,
  1522                      ACTION_NAMES.linkstamp_compile,
  1523                      ACTION_NAMES.c_compile,
  1524                      ACTION_NAMES.cpp_compile,
  1525                      ACTION_NAMES.cpp_header_parsing,
  1526                      ACTION_NAMES.cpp_module_compile,
  1527                      ACTION_NAMES.cpp_module_codegen,
  1528                      ACTION_NAMES.lto_backend,
  1529                      ACTION_NAMES.clif_match,
  1530                  ],
  1531                  flag_groups = ([flag_group(flags = dbg_compile_flags)] if dbg_compile_flags else []),
  1532                  with_features = [with_feature_set(features = ["dbg"])],
  1533              ),
  1534              flag_set(
  1535                  actions = [
  1536                      ACTION_NAMES.assemble,
  1537                      ACTION_NAMES.preprocess_assemble,
  1538                      ACTION_NAMES.linkstamp_compile,
  1539                      ACTION_NAMES.c_compile,
  1540                      ACTION_NAMES.cpp_compile,
  1541                      ACTION_NAMES.cpp_header_parsing,
  1542                      ACTION_NAMES.cpp_module_compile,
  1543                      ACTION_NAMES.cpp_module_codegen,
  1544                      ACTION_NAMES.lto_backend,
  1545                      ACTION_NAMES.clif_match,
  1546                  ],
  1547                  flag_groups = ([flag_group(flags = opt_compile_flags)] if opt_compile_flags else []),
  1548                  with_features = [with_feature_set(features = ["opt"])],
  1549              ),
  1550              flag_set(
  1551                  actions = [
  1552                      ACTION_NAMES.linkstamp_compile,
  1553                      ACTION_NAMES.cpp_compile,
  1554                      ACTION_NAMES.cpp_header_parsing,
  1555                      ACTION_NAMES.cpp_module_compile,
  1556                      ACTION_NAMES.cpp_module_codegen,
  1557                      ACTION_NAMES.lto_backend,
  1558                      ACTION_NAMES.clif_match,
  1559                  ],
  1560                  flag_groups = ([flag_group(flags = cxx_flags)] if cxx_flags else []),
  1561              ),
  1562          ],
  1563      )
  1564  
  1565      default_link_flags_feature = feature(
  1566          name = "default_link_flags",
  1567          enabled = True,
  1568          flag_sets = [
  1569              flag_set(
  1570                  actions = all_link_actions,
  1571                  flag_groups = ([flag_group(flags = link_flags)] if link_flags else []),
  1572              ),
  1573              flag_set(
  1574                  actions = all_link_actions,
  1575                  flag_groups = ([flag_group(flags = opt_link_flags)] if opt_link_flags else []),
  1576                  with_features = [with_feature_set(features = ["opt"])],
  1577              ),
  1578          ],
  1579      )
  1580  
  1581      dbg_feature = feature(name = "dbg")
  1582  
  1583      opt_feature = feature(name = "opt")
  1584  
  1585      sysroot_feature = feature(
  1586          name = "sysroot",
  1587          enabled = True,
  1588          flag_sets = [
  1589              flag_set(
  1590                  actions = [
  1591                      ACTION_NAMES.preprocess_assemble,
  1592                      ACTION_NAMES.linkstamp_compile,
  1593                      ACTION_NAMES.c_compile,
  1594                      ACTION_NAMES.cpp_compile,
  1595                      ACTION_NAMES.cpp_header_parsing,
  1596                      ACTION_NAMES.cpp_module_compile,
  1597                      ACTION_NAMES.cpp_module_codegen,
  1598                      ACTION_NAMES.lto_backend,
  1599                      ACTION_NAMES.clif_match,
  1600                      ACTION_NAMES.cpp_link_executable,
  1601                      ACTION_NAMES.cpp_link_dynamic_library,
  1602                      ACTION_NAMES.cpp_link_nodeps_dynamic_library,
  1603                  ],
  1604                  flag_groups = [
  1605                      flag_group(
  1606                          flags = ["--sysroot=%{sysroot}"],
  1607                          expand_if_available = "sysroot",
  1608                      ),
  1609                  ],
  1610              ),
  1611          ],
  1612      )
  1613  
  1614      fdo_optimize_feature = feature(
  1615          name = "fdo_optimize",
  1616          flag_sets = [
  1617              flag_set(
  1618                  actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],
  1619                  flag_groups = [
  1620                      flag_group(
  1621                          flags = [
  1622                              "-fprofile-use=%{fdo_profile_path}",
  1623                              "-fprofile-correction",
  1624                          ],
  1625                          expand_if_available = "fdo_profile_path",
  1626                      ),
  1627                  ],
  1628              ),
  1629          ],
  1630          provides = ["profile"],
  1631      )
  1632  
  1633      supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
  1634  
  1635      user_compile_flags_feature = feature(
  1636          name = "user_compile_flags",
  1637          enabled = True,
  1638          flag_sets = [
  1639              flag_set(
  1640                  actions = [
  1641                      ACTION_NAMES.assemble,
  1642                      ACTION_NAMES.preprocess_assemble,
  1643                      ACTION_NAMES.linkstamp_compile,
  1644                      ACTION_NAMES.c_compile,
  1645                      ACTION_NAMES.cpp_compile,
  1646                      ACTION_NAMES.cpp_header_parsing,
  1647                      ACTION_NAMES.cpp_module_compile,
  1648                      ACTION_NAMES.cpp_module_codegen,
  1649                      ACTION_NAMES.lto_backend,
  1650                      ACTION_NAMES.clif_match,
  1651                  ],
  1652                  flag_groups = [
  1653                      flag_group(
  1654                          flags = ["%{user_compile_flags}"],
  1655                          iterate_over = "user_compile_flags",
  1656                          expand_if_available = "user_compile_flags",
  1657                      ),
  1658                  ],
  1659              ),
  1660          ],
  1661      )
  1662  
  1663      unfiltered_compile_flags_feature = feature(
  1664          name = "unfiltered_compile_flags",
  1665          enabled = True,
  1666          flag_sets = [
  1667              flag_set(
  1668                  actions = [
  1669                      ACTION_NAMES.assemble,
  1670                      ACTION_NAMES.preprocess_assemble,
  1671                      ACTION_NAMES.linkstamp_compile,
  1672                      ACTION_NAMES.c_compile,
  1673                      ACTION_NAMES.cpp_compile,
  1674                      ACTION_NAMES.cpp_header_parsing,
  1675                      ACTION_NAMES.cpp_module_compile,
  1676                      ACTION_NAMES.cpp_module_codegen,
  1677                      ACTION_NAMES.lto_backend,
  1678                      ACTION_NAMES.clif_match,
  1679                  ],
  1680                  flag_groups = ([flag_group(flags = unfiltered_compile_flags)] if unfiltered_compile_flags else []),
  1681              ),
  1682          ],
  1683      )
  1684  
  1685      features = [
  1686          supports_pic_feature,
  1687          supports_start_end_lib_feature,
  1688          coverage_feature,
  1689          default_compile_flags_feature,
  1690          default_link_flags_feature,
  1691          fdo_optimize_feature,
  1692          supports_dynamic_linker_feature,
  1693          dbg_feature,
  1694          opt_feature,
  1695          user_compile_flags_feature,
  1696          sysroot_feature,
  1697          unfiltered_compile_flags_feature,
  1698      ]
  1699  
  1700      artifact_name_patterns = [
  1701      ]
  1702  
  1703      make_variables = []
  1704  
  1705      return cc_common.create_cc_toolchain_config_info(
  1706          ctx = ctx,
  1707          features = features,
  1708          action_configs = action_configs,
  1709          artifact_name_patterns = artifact_name_patterns,
  1710          cxx_builtin_include_directories = cxx_builtin_include_directories,
  1711          toolchain_identifier = "linux_gnu_x86",
  1712          host_system_name = "i686-unknown-linux-gnu",
  1713          target_system_name = "x86_64-unknown-linux-gnu",
  1714          target_cpu = "k8",
  1715          target_libc = "glibc_2.19",
  1716          compiler = "/dt7/usr/bin/gcc",
  1717          abi_version = "gcc",
  1718          abi_libc_version = "glibc_2.19",
  1719          tool_paths = tool_paths,
  1720          make_variables = make_variables,
  1721          builtin_sysroot = "",
  1722          cc_target_os = None,
  1723      )
  1724  
  1725  cc_toolchain_config = rule(
  1726      implementation = _impl,
  1727      attrs = {
  1728          "cpu": attr.string(mandatory = True),
  1729          "compiler": attr.string(),
  1730      },
  1731      provides = [CcToolchainConfigInfo],
  1732  )