Remove legacy parameters from cc_common.create_cc_toolchain_config_info().

Exception is the need_pic field, until we figure out its story.

Dynamic linking depends on the presence of "dynamic_linking_mode" feature.

List of removed fields:                     | What we pass to CcToolchainConfigInfo
                                            | constructor instead:

supports_gold_linker                        | check for corresponding feature
supports_start_end_lib                      | check for corresponding feature
supports_interface_shared_objects           | check for corresponding feature
supports_embedded_runtimes                  | check for corresponding feature
supports_fission                            | check for corresponding feature
supports_dsym                               | unused, pass 'false'
static_runtime_filegroup                    | pass empty string
dynamic_runtime_filegroup                   | pass empty string
compiler_flags                              | pass empty list
cxx_flags                                   | pass empty list
unfiltered_cxx_flags                        | pass empty list
linker_flags                                | pass empty list
dynamic_library_linker_flags                | pass empty list
test_only_linker_flags                      | pass empty list
objcopy_embed_flags                         | pass empty list
ld_embed_flags                              | pass empty list
compilation_mode_compiler_flags             | pass empty list
compilation_mode_cxx_flags                  | pass empty list
compilation_mode_linker_flags               | pass empty list
mostly_static_linking_mode_flags            | pass empty list
dynamic_linking_mode_flags                  | pass empty list
fully_static_linking_mode_flags             | pass empty list
mostly_static_libraries_linking_mode_flags  | pass empty list
default_libc_top                            | pass empty string

Work towards issue #5380
RELNOTES: None.
PiperOrigin-RevId: 225978244
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java
index eb36ce0..3b15de2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java
@@ -22,7 +22,6 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.config.CompilationMode;
 import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
 import com.google.devtools.build.lib.analysis.platform.ToolchainInfo;
 import com.google.devtools.build.lib.analysis.skylark.SkylarkActionFactory;
@@ -79,17 +78,12 @@
 import com.google.devtools.build.lib.vfs.PathFragment;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationModeFlags;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.LinkingMode;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.LinkingModeFlags;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import javax.annotation.Nullable;
 
@@ -972,56 +966,6 @@
         @Param(name = "abi_version", positional = false, type = String.class, named = true),
         @Param(name = "abi_libc_version", positional = false, type = String.class, named = true),
         @Param(
-            name = "supports_gold_linker",
-            positional = false,
-            defaultValue = "False",
-            type = Boolean.class,
-            named = true),
-        @Param(
-            name = "supports_start_end_lib",
-            positional = false,
-            type = Boolean.class,
-            defaultValue = "False",
-            named = true),
-        @Param(
-            name = "supports_interface_shared_objects",
-            positional = false,
-            type = Boolean.class,
-            defaultValue = "False",
-            named = true),
-        @Param(
-            name = "supports_embedded_runtimes",
-            positional = false,
-            type = Boolean.class,
-            defaultValue = "False",
-            named = true),
-        @Param(
-            name = "static_runtime_filegroup",
-            positional = false,
-            noneable = true,
-            defaultValue = "None",
-            allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
-            named = true),
-        @Param(
-            name = "dynamic_runtime_filegroup",
-            positional = false,
-            noneable = true,
-            defaultValue = "None",
-            allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
-            named = true),
-        @Param(
-            name = "supports_fission",
-            positional = false,
-            type = Boolean.class,
-            defaultValue = "False",
-            named = true),
-        @Param(
-            name = "supports_dsym",
-            positional = false,
-            type = Boolean.class,
-            defaultValue = "False",
-            named = true),
-        @Param(
             name = "needs_pic",
             positional = false,
             type = Boolean.class,
@@ -1034,100 +978,6 @@
             defaultValue = "[]",
             type = SkylarkList.class),
         @Param(
-            name = "compiler_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "cxx_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "unfiltered_cxx_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "linker_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "dynamic_library_linker_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "test_only_linker_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "objcopy_embed_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "ld_embed_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "compilation_mode_compiler_flags",
-            positional = false,
-            named = true,
-            defaultValue = "{}",
-            type = SkylarkDict.class),
-        @Param(
-            name = "compilation_mode_cxx_flags",
-            positional = false,
-            named = true,
-            defaultValue = "{}",
-            type = SkylarkDict.class),
-        @Param(
-            name = "compilation_mode_linker_flags",
-            positional = false,
-            named = true,
-            defaultValue = "{}",
-            type = SkylarkDict.class),
-        @Param(
-            name = "mostly_static_linking_mode_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "dynamic_linking_mode_flags",
-            positional = false,
-            named = true,
-            defaultValue = "None",
-            noneable = true,
-            allowedTypes = {
-              @ParamType(type = SkylarkList.class),
-              @ParamType(type = NoneType.class)
-            }),
-        @Param(
-            name = "fully_static_linking_mode_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
-            name = "mostly_static_libraries_linking_mode_flags",
-            positional = false,
-            named = true,
-            defaultValue = "[]",
-            type = SkylarkList.class),
-        @Param(
             name = "make_variables",
             positional = false,
             named = true,
@@ -1141,13 +991,6 @@
             allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
             named = true),
         @Param(
-            name = "default_libc_top",
-            positional = false,
-            noneable = true,
-            defaultValue = "None",
-            allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
-            named = true),
-        @Param(
             name = "cc_target_os",
             positional = false,
             noneable = true,
@@ -1169,34 +1012,10 @@
       String compiler,
       String abiVersion,
       String abiLibcVersion,
-      Boolean supportsGoldLinker,
-      Boolean supportsStartEndLib,
-      Boolean supportsInterfaceSharedObjects,
-      Boolean supportsEmbeddedRuntimes,
-      Object staticRuntimesFilegroup,
-      Object dynamicRuntimesFilegroup,
-      Boolean supportsFission,
-      Boolean supportsDsym,
       Boolean needsPic,
       SkylarkList<Object> toolPaths,
-      SkylarkList<String> compilerFlags,
-      SkylarkList<String> cxxFlags,
-      SkylarkList<String> unfilteredCxxFlags,
-      SkylarkList<String> linkerFlags,
-      SkylarkList<String> dynamicLibraryLinkerFlags,
-      SkylarkList<String> testOnlyLinkerFlags,
-      SkylarkList<String> objcopyEmbedFlags,
-      SkylarkList<String> ldEmbedFlags,
-      Object compilationModeCompilerFlagsUnchecked,
-      Object compilationModeCxxFlagsUnchecked,
-      Object compilationModeLinkerFlagsUnchecked,
-      SkylarkList<String> mostlyStaticLinkingModeFlags,
-      Object dynamicLinkingModeFlags,
-      SkylarkList<String> fullyStaticLinkingModeFlags,
-      SkylarkList<String> mostlyStaticLibrariesLinkingModeFlags,
       SkylarkList<Object> makeVariables,
       Object builtinSysroot,
-      Object defaultLibcTop,
       Object ccTargetOs)
       throws InvalidConfigurationException, EvalException {
 
@@ -1223,6 +1042,14 @@
             .map(feature -> feature.getName())
             .collect(ImmutableSet.toImmutableSet());
 
+    boolean supportsGoldLinker = featureNames.contains("supports_gold_linker");
+    boolean supportsStartEndLib = featureNames.contains("supports_start_end_lib");
+    boolean supportsInterfaceSharedObjects =
+        featureNames.contains("supports_interface_shared_objects");
+    boolean supportsEmbeddedRuntimes = featureNames.contains("supports_embedded_runtimes");
+    boolean supportsFission = featureNames.contains("supports_fission");
+    boolean dynamicLinkingMode = featureNames.contains("dynamic_linking_mode");
+
     ImmutableList.Builder<ActionConfig> actionConfigBuilder = ImmutableList.builder();
     for (Object actionConfig : actionConfigs) {
       actionConfigBuilder.add(actionConfigFromSkylark((SkylarkInfo) actionConfig));
@@ -1347,10 +1174,6 @@
               .build());
     }
 
-    SkylarkList<String> dynamicModeFlags =
-        convertFromNoneable(dynamicLinkingModeFlags, /* defaultValue= */ null);
-    boolean hasDynamicLinkingModeFlags = dynamicModeFlags != null;
-
     cToolchain
         .addAllCxxBuiltinIncludeDirectory(cxxBuiltInIncludeDirectories)
         .setToolchainIdentifier(toolchainIdentifier)
@@ -1361,103 +1184,14 @@
         .setCompiler(compiler)
         .setAbiVersion(abiVersion)
         .setAbiLibcVersion(abiLibcVersion)
-        .setSupportsGoldLinker(supportsGoldLinker)
-        .setSupportsStartEndLib(supportsStartEndLib)
-        .setSupportsInterfaceSharedObjects(supportsInterfaceSharedObjects)
-        .setSupportsEmbeddedRuntimes(supportsEmbeddedRuntimes);
-
-    if (convertFromNoneable(staticRuntimesFilegroup, /* defaultValue= */ null) != null) {
-      cToolchain.setStaticRuntimesFilegroup((String) staticRuntimesFilegroup);
-    }
-    if (convertFromNoneable(dynamicRuntimesFilegroup, /* defaultValue= */ null) != null) {
-      cToolchain.setDynamicRuntimesFilegroup((String) dynamicRuntimesFilegroup);
-    }
-
-    cToolchain
-        .setSupportsFission(supportsFission)
-        .setSupportsDsym(supportsDsym)
         .setNeedsPic(needsPic);
 
-    cToolchain
-        .addAllCompilerFlag(compilerFlags)
-        .addAllCxxFlag(cxxFlags)
-        .addAllUnfilteredCxxFlag(unfilteredCxxFlags)
-        .addAllLinkerFlag(linkerFlags)
-        .addAllDynamicLibraryLinkerFlag(dynamicLibraryLinkerFlags)
-        .addAllTestOnlyLinkerFlag(testOnlyLinkerFlags)
-        .addAllObjcopyEmbedFlag(objcopyEmbedFlags)
-        .addAllLdEmbedFlag(ldEmbedFlags);
-
-    ImmutableList.Builder<CompilationModeFlags> compilationModeFlagsBuilder =
-        ImmutableList.builder();
-
-    ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeCompilerFlags =
-        getCompilationModeFlagsFromSkylark(
-            compilationModeCompilerFlagsUnchecked, "compilation_mode_compiler_flags");
-    ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeCxxFlags =
-        getCompilationModeFlagsFromSkylark(
-            compilationModeCxxFlagsUnchecked, "compilation_mode_cxx_flags");
-    ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeLinkerFlags =
-        getCompilationModeFlagsFromSkylark(
-            compilationModeLinkerFlagsUnchecked, "compilation_mode_linker_flags");
-
-    compilationModeFlagsBuilder.add(
-        getCompilationModeFlags(
-            CrosstoolConfig.CompilationMode.FASTBUILD,
-            compilationModeCompilerFlags,
-            compilationModeCxxFlags,
-            compilationModeLinkerFlags));
-    compilationModeFlagsBuilder.add(
-        getCompilationModeFlags(
-            CrosstoolConfig.CompilationMode.OPT,
-            compilationModeCompilerFlags,
-            compilationModeCxxFlags,
-            compilationModeLinkerFlags));
-    compilationModeFlagsBuilder.add(
-        getCompilationModeFlags(
-            CrosstoolConfig.CompilationMode.DBG,
-            compilationModeCompilerFlags,
-            compilationModeCxxFlags,
-            compilationModeLinkerFlags));
-
-    cToolchain.addAllCompilationModeFlags(compilationModeFlagsBuilder.build());
-
-    ImmutableList.Builder<CrosstoolConfig.LinkingModeFlags> linkingModeFlags =
-        ImmutableList.builder();
-    if (hasDynamicLinkingModeFlags) {
-      linkingModeFlags.add(
-          LinkingModeFlags.newBuilder()
-              .setMode(LinkingMode.DYNAMIC)
-              .addAllLinkerFlag(dynamicModeFlags)
-              .build());
-    }
-    linkingModeFlags.add(
-        LinkingModeFlags.newBuilder()
-            .setMode(LinkingMode.FULLY_STATIC)
-            .addAllLinkerFlag(fullyStaticLinkingModeFlags)
-            .build());
-    linkingModeFlags.add(
-        LinkingModeFlags.newBuilder()
-            .setMode(LinkingMode.MOSTLY_STATIC)
-            .addAllLinkerFlag(mostlyStaticLinkingModeFlags)
-            .build());
-    linkingModeFlags.add(
-        LinkingModeFlags.newBuilder()
-            .setMode(LinkingMode.MOSTLY_STATIC_LIBRARIES)
-            .addAllLinkerFlag(mostlyStaticLibrariesLinkingModeFlags)
-            .build());
-
-    cToolchain.addAllLinkingModeFlags(linkingModeFlags.build());
-
     if (convertFromNoneable(ccTargetOs, /* defaultValue= */ null) != null) {
       cToolchain.setCcTargetOs((String) ccTargetOs);
     }
     if (convertFromNoneable(builtinSysroot, /* defaultValue= */ null) != null) {
       cToolchain.setBuiltinSysroot((String) builtinSysroot);
     }
-    if (convertFromNoneable(defaultLibcTop, /* defaultValue= */ null) != null) {
-      cToolchain.setDefaultGrteTop((String) defaultLibcTop);
-    }
 
     return new CcToolchainConfigInfo(
         actionConfigList,
@@ -1476,54 +1210,35 @@
         supportsStartEndLib,
         supportsInterfaceSharedObjects,
         supportsEmbeddedRuntimes,
-        convertFromNoneable(staticRuntimesFilegroup, /* defaultValue= */ ""),
-        convertFromNoneable(dynamicRuntimesFilegroup, /* defaultValue= */ ""),
+        /* staticRuntimesFilegroup= */ "",
+        /* dynamicRuntimesFilegroup= */ "",
         supportsFission,
-        supportsDsym,
+        /* supportsDsym= */ false,
         needsPic,
         toolPathList,
-        ImmutableList.copyOf(compilerFlags),
-        ImmutableList.copyOf(cxxFlags),
-        ImmutableList.copyOf(unfilteredCxxFlags),
-        ImmutableList.copyOf(linkerFlags),
-        ImmutableList.copyOf(dynamicLibraryLinkerFlags),
-        ImmutableList.copyOf(testOnlyLinkerFlags),
-        ImmutableList.copyOf(objcopyEmbedFlags),
-        ImmutableList.copyOf(ldEmbedFlags),
-        compilationModeCompilerFlags,
-        compilationModeCxxFlags,
-        compilationModeLinkerFlags,
-        ImmutableList.copyOf(mostlyStaticLinkingModeFlags),
-        hasDynamicLinkingModeFlags ? ImmutableList.copyOf(dynamicModeFlags) : ImmutableList.of(),
-        ImmutableList.copyOf(fullyStaticLinkingModeFlags),
-        ImmutableList.copyOf(mostlyStaticLibrariesLinkingModeFlags),
+        /* compilerFlags= */ ImmutableList.of(),
+        /* cxxFlags= */ ImmutableList.of(),
+        /* unfilteredCxxFlags= */ ImmutableList.of(),
+        /* linkerFlags= */ ImmutableList.of(),
+        /* dynamicLibraryLinkerFlags= */ ImmutableList.of(),
+        /* testOnlyLinkerFlags= */ ImmutableList.of(),
+        /* objcopyEmbedFlags= */ ImmutableList.of(),
+        /* ldEmbedFlags= */ ImmutableList.of(),
+        /* compilationModeCompilerFlags= */ ImmutableMap.of(),
+        /* compilationModeCxxFlags= */ ImmutableMap.of(),
+        /* compilationModeLinkerFlags= */ ImmutableMap.of(),
+        /* mostlyStaticLinkingModeFlags= */ ImmutableList.of(),
+        /* dynamicLinkingModeFlags= */ ImmutableList.of(),
+        /* fullyStaticLinkingModeFlags= */ ImmutableList.of(),
+        /* mostlyStaticLibrariesLinkingModeFlags= */ ImmutableList.of(),
         makeVariablePairs.build(),
         convertFromNoneable(builtinSysroot, /* defaultValue= */ ""),
-        convertFromNoneable(defaultLibcTop, /* defaultValue= */ ""),
+        /* defaultLibcTop= */ "",
         convertFromNoneable(ccTargetOs, /* defaultValue= */ ""),
-        hasDynamicLinkingModeFlags,
+        dynamicLinkingMode,
         cToolchain.build().toString());
   }
 
-  private static CrosstoolConfig.CompilationModeFlags getCompilationModeFlags(
-      CrosstoolConfig.CompilationMode mode,
-      ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeCompilerFlags,
-      ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeCxxFlags,
-      ImmutableMap<CompilationMode, ImmutableList<String>> compilationModeLinkerFlags) {
-    return CompilationModeFlags.newBuilder()
-        .setMode(mode)
-        .addAllCompilerFlag(
-            compilationModeCompilerFlags.getOrDefault(
-                CppToolchainInfo.importCompilationMode(mode), ImmutableList.of()))
-        .addAllCxxFlag(
-            compilationModeCxxFlags.getOrDefault(
-                CppToolchainInfo.importCompilationMode(mode), ImmutableList.of()))
-        .addAllLinkerFlag(
-            compilationModeLinkerFlags.getOrDefault(
-                CppToolchainInfo.importCompilationMode(mode), ImmutableList.of()))
-        .build();
-  }
-
   /** Checks whether the {@link SkylarkInfo} is of the required type. */
   private static void checkRightProviderType(SkylarkInfo provider, String type)
       throws EvalException {
@@ -1983,23 +1698,6 @@
         .collect(ImmutableList.toImmutableList());
   }
 
-  private static ImmutableMap<CompilationMode, ImmutableList<String>>
-      getCompilationModeFlagsFromSkylark(Object compilationModeFlags, String field)
-          throws EvalException {
-    Map<String, SkylarkList> compilationModeLinkerFlagsMap =
-        SkylarkDict.castSkylarkDictOrNoneToDict(
-            compilationModeFlags, String.class, SkylarkList.class, field);
-    ImmutableMap.Builder<CompilationMode, ImmutableList<String>> compilationModeFlagsBuilder =
-        ImmutableMap.builder();
-    for (Entry<String, SkylarkList> entry : compilationModeLinkerFlagsMap.entrySet()) {
-      compilationModeFlagsBuilder.put(
-          CompilationMode.valueOf(entry.getKey()),
-          ImmutableList.copyOf(
-              convertSkylarkListOrNestedSetToList(entry.getValue(), String.class)));
-    }
-    return compilationModeFlagsBuilder.build();
-  }
-
   private static void getLegacyArtifactNamePatterns(
       ImmutableList.Builder<ArtifactNamePattern> patterns) {
     Set<ArtifactCategory> definedCategories = new HashSet<>();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
index 0194009..54c68b2 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
@@ -743,12 +743,9 @@
         "                target_system_name = 'target',",
         "                target_cpu = 'cpu',",
         "                target_libc = 'libc',",
-        "                default_libc_top = 'libc_top',",
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'banana',",
-        "                supports_gold_linker = True,",
-        "                supports_start_end_lib = True,",
         "                tool_paths = [",
         "                     tool_path(name = 'ar', path = '/absolute/path'),",
         "                     tool_path(name = 'cpp', path = 'relative/path'),",
@@ -764,12 +761,6 @@
         "                     tool_path(name = 'llvm_profdata', path = '/some/path'),",
         "                ],",
         "                cc_target_os = 'os',",
-        "                compiler_flags = ['flag1', 'flag2', 'flag3'],",
-        "                linker_flags = ['flag1'],",
-        "                compilation_mode_compiler_flags = {",
-        "                    'OPT' : ['flagopt'], 'FASTBUILD' : ['flagfast'] ",
-        "                },",
-        "                objcopy_embed_flags = ['flag1'],",
         "                needs_pic = True,",
         "                builtin_sysroot = 'sysroot')",
         "cc_toolchain_config_rule = rule(",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
index 7d0d5bc..ae5791f 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java
@@ -53,9 +53,6 @@
 import com.google.devtools.build.lib.util.Pair;
 import com.google.devtools.build.lib.vfs.PathFragment;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationModeFlags;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.LinkingMode;
-import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.LinkingModeFlags;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.MakeVariable;
 import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath;
 import com.google.protobuf.TextFormat;
@@ -4195,18 +4192,11 @@
         "                target_system_name = 'target',",
         "                target_cpu = 'cpu',",
         "                target_libc = 'libc',",
-        "                default_libc_top = 'libc_top',",
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'abi',",
-        "                supports_gold_linker = True,",
-        "                supports_start_end_lib = True,",
-        "                supports_embedded_runtimes = True,",
         "                tool_paths = [tool_path(name = 'name1', path = 'path1')],",
         "                cc_target_os = 'os',",
-        "                compiler_flags = ['flag1', 'flag2', 'flag3'],",
-        "                linker_flags = ['flag1'],",
-        "                objcopy_embed_flags = ['flag1'],",
         "                needs_pic = True,",
         "                builtin_sysroot = 'sysroot',",
         "                make_variables = [make_variable(name = 'acs', value = 'asd')])",
@@ -4371,7 +4361,6 @@
         "                target_system_name = 'target',",
         "                target_cpu = 'cpu',",
         "                target_libc = 'libc',",
-        "                default_libc_top = 'libc_top',",
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'abi')",
@@ -4441,7 +4430,6 @@
         "                target_system_name = 'target',",
         "                target_cpu = 'cpu',",
         "                target_libc = 'libc',",
-        "                default_libc_top = 'libc_top',",
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'abi')",
@@ -4565,43 +4553,10 @@
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'abi',",
-        "                supports_gold_linker = True,",
-        "                supports_start_end_lib = True,",
-        "                supports_interface_shared_objects = True,",
-        "                supports_embedded_runtimes = True,",
-        "                static_runtime_filegroup = 'static',",
-        "                dynamic_runtime_filegroup = 'dynamic',",
-        "                supports_fission = True,",
-        "                supports_dsym = True,",
         "                needs_pic = True,",
         "                tool_paths = [tool_path(name = 'name1', path = 'path1')],",
-        "                compiler_flags = ['flag1', 'flag2', 'flag3'],",
-        "                cxx_flags = ['cxx1', 'cxx2'],",
-        "                unfiltered_cxx_flags = ['ucxx1', 'ucxx2'],",
-        "                linker_flags = ['l2', 'l1'],",
-        "                dynamic_library_linker_flags = ['dll1', 'dll2'],",
-        "                test_only_linker_flags = ['t1', 't2'],",
-        "                objcopy_embed_flags = ['o1', 'o2'],",
-        "                ld_embed_flags = ['ld1', 'ld2'],",
-        "                compilation_mode_compiler_flags = {",
-        "                    'OPT' : ['opt1', 'opt2'],",
-        "                    'FASTBUILD' : ['fbd1', 'fbd2'],",
-        "                    'DBG' : ['dbg1', 'dbg2'] },",
-        "                compilation_mode_cxx_flags = {",
-        "                    'OPT' : ['optcxx1', 'optcxx2'],",
-        "                    'FASTBUILD' : ['fbdcxx1', 'fbdcxx2'],",
-        "                    'DBG' : ['dbgcxx1', 'dbgcxx2'] },",
-        "                compilation_mode_linker_flags = {",
-        "                    'OPT' : ['optl1', 'optl2'],",
-        "                    'FASTBUILD' : ['fbdl1', 'fbdl2'],",
-        "                    'DBG' : ['dbgl1', 'dbgl2'] },",
-        "                mostly_static_linking_mode_flags = ['ms1', 'ms2'],",
-        "                dynamic_linking_mode_flags = ['d1', 'd2'],",
-        "                fully_static_linking_mode_flags = ['fs1', 'fs2'],",
-        "                mostly_static_libraries_linking_mode_flags = ['msl1', 'msl2'],",
         "                make_variables = [make_variable(name = 'variable', value = '--a -b -c')],",
         "                builtin_sysroot = 'sysroot',",
-        "                default_libc_top = 'libc_top',",
         "                cc_target_os = 'os',",
         "        )",
         "cc_toolchain_config_rule = rule(",
@@ -4636,86 +4591,10 @@
     assertThat(toolchain.getCompiler()).isEqualTo("compiler");
     assertThat(toolchain.getAbiLibcVersion()).isEqualTo("abi_libc");
     assertThat(toolchain.getAbiVersion()).isEqualTo("abi");
-    assertThat(toolchain.getSupportsGoldLinker()).isTrue();
-    assertThat(toolchain.getSupportsStartEndLib()).isTrue();
-    assertThat(toolchain.getSupportsInterfaceSharedObjects()).isTrue();
-    assertThat(toolchain.getSupportsEmbeddedRuntimes()).isTrue();
-    assertThat(toolchain.getStaticRuntimesFilegroup()).isEqualTo("static");
-    assertThat(toolchain.getDynamicRuntimesFilegroup()).isEqualTo("dynamic");
-    assertThat(toolchain.getSupportsFission()).isTrue();
-    assertThat(toolchain.getSupportsDsym()).isTrue();
     assertThat(toolchain.getNeedsPic()).isTrue();
     ToolPath toolPath = Iterables.getOnlyElement(toolchain.getToolPathList());
     assertThat(toolPath.getName()).isEqualTo("name1");
     assertThat(toolPath.getPath()).isEqualTo("path1");
-    assertThat(toolchain.getCompilerFlagList())
-        .containsExactly("flag1", "flag2", "flag3")
-        .inOrder();
-    assertThat(toolchain.getCxxFlagList()).containsExactly("cxx1", "cxx2").inOrder();
-    assertThat(toolchain.getUnfilteredCxxFlagList()).containsExactly("ucxx1", "ucxx2").inOrder();
-    assertThat(toolchain.getLinkerFlagList()).containsExactly("l2", "l1").inOrder();
-    assertThat(toolchain.getTestOnlyLinkerFlagList()).containsExactly("t1", "t2");
-    assertThat(toolchain.getObjcopyEmbedFlagList()).containsExactly("o1", "o2").inOrder();
-    assertThat(toolchain.getLdEmbedFlagList()).containsExactly("ld1", "ld2").inOrder();
-    assertThat(toolchain.getCompilationModeFlagsCount()).isEqualTo(3);
-    for (CompilationModeFlags compilationModeFlags : toolchain.getCompilationModeFlagsList()) {
-      switch (compilationModeFlags.getMode()) {
-        case OPT:
-          assertThat(compilationModeFlags.getCompilerFlagList())
-              .containsExactly("opt1", "opt2")
-              .inOrder();
-          assertThat(compilationModeFlags.getCxxFlagList())
-              .containsExactly("optcxx1", "optcxx2")
-              .inOrder();
-          assertThat(compilationModeFlags.getLinkerFlagList())
-              .containsExactly("optl1", "optl2")
-              .inOrder();
-          break;
-        case FASTBUILD:
-          assertThat(compilationModeFlags.getCompilerFlagList())
-              .containsExactly("fbd1", "fbd2")
-              .inOrder();
-          assertThat(compilationModeFlags.getCxxFlagList())
-              .containsExactly("fbdcxx1", "fbdcxx2")
-              .inOrder();
-          assertThat(compilationModeFlags.getLinkerFlagList())
-              .containsExactly("fbdl1", "fbdl2")
-              .inOrder();
-          break;
-        case DBG:
-          assertThat(compilationModeFlags.getCompilerFlagList())
-              .containsExactly("dbg1", "dbg2")
-              .inOrder();
-          assertThat(compilationModeFlags.getCxxFlagList())
-              .containsExactly("dbgcxx1", "dbgcxx2")
-              .inOrder();
-          assertThat(compilationModeFlags.getLinkerFlagList())
-              .containsExactly("dbgl1", "dbgl2")
-              .inOrder();
-          break;
-        default:
-          // COVERAGE mode is ignored
-      }
-    }
-    assertThat(toolchain.getLinkingModeFlagsCount()).isEqualTo(4);
-    for (LinkingModeFlags linkingModeFlags : toolchain.getLinkingModeFlagsList()) {
-      switch (linkingModeFlags.getMode()) {
-        case MOSTLY_STATIC:
-          assertThat(linkingModeFlags.getLinkerFlagList()).containsExactly("ms1", "ms2").inOrder();
-          break;
-        case DYNAMIC:
-          assertThat(linkingModeFlags.getLinkerFlagList()).containsExactly("d1", "d2").inOrder();
-          break;
-        case FULLY_STATIC:
-          assertThat(linkingModeFlags.getLinkerFlagList()).containsExactly("fs1", "fs2").inOrder();
-          break;
-        case MOSTLY_STATIC_LIBRARIES:
-          assertThat(linkingModeFlags.getLinkerFlagList())
-              .containsExactly("msl1", "msl2")
-              .inOrder();
-          break;
-      }
-    }
     MakeVariable makeVariable = Iterables.getOnlyElement(toolchain.getMakeVariableList());
     assertThat(makeVariable.getName()).isEqualTo("variable");
     assertThat(makeVariable.getValue()).isEqualTo("--a -b -c");
@@ -4823,22 +4702,17 @@
     assertThat(ccToolchainConfigInfo).isNotNull();
     CToolchain.Builder toolchainBuilder = CToolchain.newBuilder();
     TextFormat.merge(ccToolchainConfigInfo.getProto(), toolchainBuilder);
-    CToolchain toolchain = toolchainBuilder.build();
-
-    // Our generated CToolchain must not have a LinkingModeFlags entry with DYNAMIC mode, even
-    // if the list of flags for that entry is empty.
-    assertThat(
-            toolchain.getLinkingModeFlagsList().stream()
-                .noneMatch(
-                    linkingModeFlags -> linkingModeFlags.getMode().equals(LinkingMode.DYNAMIC)))
-        .isTrue();
+    assertNoEvents();
   }
 
   @Test
-  public void testCcToolchainInfoToProtoDynamicLinkingModeEnabledWithEmptyList() throws Exception {
+  public void testCcToolchainConfigInfooDynamicLinkingModeEnabledWithFeature() throws Exception {
     loadCcToolchainConfigLib();
     scratch.file(
         "foo/crosstool.bzl",
+        "load('//tools/cpp:cc_toolchain_config_lib.bzl',",
+        "        'feature')",
+        "",
         "def _impl(ctx):",
         "    return cc_common.create_cc_toolchain_config_info(",
         "                ctx = ctx,",
@@ -4850,7 +4724,7 @@
         "                compiler = 'compiler',",
         "                abi_libc_version = 'abi_libc',",
         "                abi_version = 'abi',",
-        "                dynamic_linking_mode_flags = [],",
+        "                features = [feature(name = 'dynamic_linking_mode')],",
         "        )",
         "cc_toolchain_config_rule = rule(",
         "    implementation = _impl,",
@@ -4870,17 +4744,10 @@
     CcToolchainConfigInfo ccToolchainConfigInfo =
         (CcToolchainConfigInfo) target.get(CcToolchainConfigInfo.PROVIDER.getKey());
     assertThat(ccToolchainConfigInfo).isNotNull();
-    CToolchain.Builder toolchainBuilder = CToolchain.newBuilder();
-    TextFormat.merge(ccToolchainConfigInfo.getProto(), toolchainBuilder);
-    CToolchain toolchain = toolchainBuilder.build();
 
-    // If parameter dynamic_linking_mode_flags is passed to the create_cc_toolchain_config_info
+    // If a feature named 'dynamic_linking_mode' is passed to the create_cc_toolchain_config_info
     // method, the corresponding CToolchain should have an entry in its linking_mode_flags list
     // that has dynamic linking mode.
-    assertThat(
-            toolchain.getLinkingModeFlagsList().stream()
-                .filter(linkingModeFlags -> linkingModeFlags.getMode().equals(LinkingMode.DYNAMIC))
-                .count())
-        .isEqualTo(1);
+    assertThat(ccToolchainConfigInfo.hasDynamicLinkingModeFlags()).isTrue();
   }
 }