Skip to content

Commit

Permalink
Remove --experimental_enable_cc_toolchain_config_info option
Browse files Browse the repository at this point in the history
    The cc_common.create_cc_toolchain_config_info() is stable now.

    Issue #5380

    RELNOTES: None.
    PiperOrigin-RevId: 232308719
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 07e8cef commit 0e7c3e6
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,6 @@
public class BazelRulesModule extends BlazeModule {
/** This is where deprecated options go to die. */
public static class GraveyardOptions extends OptionsBase {
@Option(
name = "incompatible_linkopts_in_user_link_flags",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "Deprecated no-op.")
public boolean enableLinkoptsInUserLinkFlags;

@Option(
name = "incompatible_disable_runtimes_filegroups",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "Deprecated no-op.")
public boolean disableRuntimesFilegroups;

@Option(
name = "incompatible_disable_tools_defaults_package",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.DEPRECATED,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
OptionMetadataTag.INCOMPATIBLE_CHANGE
},
help = "Deprecated no-op.")
public boolean incompatibleDisableInMemoryToolsDefaultsPackage;

@Option(
name = "experimental_enable_cc_toolchain_config_info",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
import com.google.devtools.build.lib.rules.cpp.CcToolchainVariables.StringValueParser;
import com.google.devtools.build.lib.rules.cpp.CppActionConfigs.CppPlatform;
import com.google.devtools.build.lib.rules.cpp.LibraryToLinkWrapper.CcLinkingContext;
import com.google.devtools.build.lib.skylarkbuildapi.SkylarkRuleContextApi;
import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcInfoApi;
import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcModuleApi;
import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.ParamType;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
import com.google.devtools.build.lib.syntax.Environment;
import com.google.devtools.build.lib.syntax.EvalException;
Expand Down Expand Up @@ -87,8 +91,7 @@ public class CcModule
CcLinkingContext,
LibraryToLinkWrapper,
CcToolchainVariables,
SkylarkRuleContext,
CcToolchainConfigInfo> {
SkylarkRuleContext> {

private enum RegisterActions {
ALWAYS,
Expand Down Expand Up @@ -751,7 +754,79 @@ private static <T> NestedSet<T> convertSkylarkListOrNestedSetToNestedSet(
: NestedSetBuilder.wrap(Order.COMPILE_ORDER, (SkylarkList<T>) o);
}

@Override
@SkylarkCallable(
name = "create_cc_toolchain_config_info",
documented = false,
parameters = {
@Param(
name = "ctx",
positional = false,
named = true,
type = SkylarkRuleContextApi.class,
doc = "The rule context."),
@Param(
name = "features",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "action_configs",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "artifact_name_patterns",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "cxx_builtin_include_directories",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "toolchain_identifier",
positional = false,
type = String.class,
named = true),
@Param(name = "host_system_name", positional = false, type = String.class, named = true),
@Param(name = "target_system_name", positional = false, type = String.class, named = true),
@Param(name = "target_cpu", positional = false, type = String.class, named = true),
@Param(name = "target_libc", positional = false, type = String.class, named = true),
@Param(name = "compiler", positional = false, type = String.class, named = true),
@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 = "tool_paths",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "make_variables",
positional = false,
named = true,
defaultValue = "[]",
type = SkylarkList.class),
@Param(
name = "builtin_sysroot",
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,
defaultValue = "None",
allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
named = true),
})
public CcToolchainConfigInfo ccToolchainConfigInfoFromSkylark(
SkylarkRuleContext skylarkRuleContext,
SkylarkList<Object> features,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,12 @@ private static Artifact getPrefetchHintsArtifact(
"fdo",
prefetchHintsFile.getAbsolutePath().getBaseName(),
ruleContext.getBinOrGenfilesDirectory());
ruleContext.registerAction(
SymlinkAction.toAbsolutePath(
ruleContext.getActionOwner(),
PathFragment.create(prefetchHintsFile.getAbsolutePath().getPathString()),
prefetchHintsArtifact,
"Symlinking LLVM Cache Prefetch Hints Profile "
+ prefetchHintsFile.getAbsolutePath().getPathString()));
ruleContext.registerAction(SymlinkAction.toAbsolutePath(
ruleContext.getActionOwner(),
PathFragment.create(prefetchHintsFile.getAbsolutePath().getPathString()),
prefetchHintsArtifact,
"Symlinking LLVM Cache Prefetch Hints Profile "
+ prefetchHintsFile.getAbsolutePath().getPathString()));
return prefetchHintsArtifact;
}

Expand Down Expand Up @@ -395,11 +394,13 @@ static CcToolchainProvider getCcToolchainProvider(
return null;
}


if (fdoInputs != null) {
fdoInputFile = fdoInputs.getFirst();
protoProfileArtifact = fdoInputs.getSecond();
}


CcSkyframeSupportValue ccSkyframeSupportValue = null;
SkyKey ccSupportKey = null;
CToolchain toolchain = null;
Expand Down Expand Up @@ -511,16 +512,28 @@ static CcToolchainProvider getCcToolchainProvider(
configuration.getBinFragment().getRelative(runtimeSolibDirBase);

// Static runtime inputs.
TransitiveInfoCollection staticRuntimeLib = attributes.getStaticRuntimeLib();
if (cppConfiguration.disableRuntimesFilegroups()
&& !attributes.getStaticRuntimesLibs().isEmpty()) {
ruleContext.ruleError(
"cc_toolchain.static_runtime_libs attribute is removed, please use "
+ "cc_toolchain.static_runtime_lib (singular) instead. See "
+ "https://github.com/bazelbuild/bazel/issues/6942 for details.");
}
TransitiveInfoCollection staticRuntimeLibDep =
attributes.getStaticRuntimeLib() != null
? attributes.getStaticRuntimeLib()
: selectDep(
attributes.getStaticRuntimesLibs(), toolchainInfo.getStaticRuntimeLibsLabel());
final NestedSet<Artifact> staticRuntimeLinkInputs;
final Artifact staticRuntimeLinkMiddleman;

if (staticRuntimeLib != null) {
staticRuntimeLinkInputs = staticRuntimeLib.getProvider(FileProvider.class).getFilesToBuild();
if (staticRuntimeLibDep != null) {
staticRuntimeLinkInputs =
staticRuntimeLibDep.getProvider(FileProvider.class).getFilesToBuild();
if (!staticRuntimeLinkInputs.isEmpty()) {
NestedSet<Artifact> staticRuntimeLinkMiddlemanSet =
CompilationHelper.getAggregatingMiddleman(
ruleContext, purposePrefix + "static_runtime_link", staticRuntimeLib);
ruleContext, purposePrefix + "static_runtime_link", staticRuntimeLibDep);
staticRuntimeLinkMiddleman =
staticRuntimeLinkMiddlemanSet.isEmpty()
? null
Expand All @@ -536,14 +549,25 @@ static CcToolchainProvider getCcToolchainProvider(
}

// Dynamic runtime inputs.
TransitiveInfoCollection dynamicRuntimeLib = attributes.getDynamicRuntimeLib();
if (cppConfiguration.disableRuntimesFilegroups()
&& !attributes.getDynamicRuntimesLibs().isEmpty()) {
ruleContext.ruleError(
"cc_toolchain.dynamic_runtime_libs attribute is removed, please use "
+ "cc_toolchain.dynamic_runtime_lib (singular) instead. See "
+ "https://github.com/bazelbuild/bazel/issues/6942 for details.");
}
TransitiveInfoCollection dynamicRuntimeLibDep =
attributes.getDynamicRuntimeLib() != null
? attributes.getDynamicRuntimeLib()
: selectDep(
attributes.getDynamicRuntimesLibs(), toolchainInfo.getDynamicRuntimeLibsLabel());
NestedSet<Artifact> dynamicRuntimeLinkSymlinks;
List<Artifact> dynamicRuntimeLinkInputs = new ArrayList<>();
Artifact dynamicRuntimeLinkMiddleman;
if (dynamicRuntimeLib != null) {
if (dynamicRuntimeLibDep != null) {
NestedSetBuilder<Artifact> dynamicRuntimeLinkSymlinksBuilder = NestedSetBuilder.stableOrder();
for (Artifact artifact :
dynamicRuntimeLib.getProvider(FileProvider.class).getFilesToBuild()) {
dynamicRuntimeLibDep.getProvider(FileProvider.class).getFilesToBuild()) {
if (CppHelper.SHARED_LIBRARY_FILETYPES.matches(artifact.getFilename())) {
dynamicRuntimeLinkInputs.add(artifact);
dynamicRuntimeLinkSymlinksBuilder.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ public static String getLegacyCrosstoolFieldErrorMessage(String field) {
+ "migration instructions).";
}

public boolean enableLinkoptsInUserLinkFlags() {
return cppOptions.enableLinkoptsInUserLinkFlags;
}

public boolean disableEmittingStaticLibgcc() {
return cppOptions.disableEmittingStaticLibgcc;
}
Expand All @@ -579,6 +583,10 @@ public static PathFragment computeDefaultSysroot(String builtInSysroot) {
return PathFragment.create(builtInSysroot);
}

boolean disableRuntimesFilegroups() {
return cppOptions.disableRuntimesFilegroups;
}

/**
* Returns the value of the libc top-level directory (--grte_top) as specified on the command line
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,21 @@ public Label getFdoPrefetchHintsLabel() {
+ "(see https://github.com/bazelbuild/bazel/issues/7008 for migration instructions).")
public boolean disableExpandIfAllAvailableInFlagSet;

@Option(
name = "incompatible_linkopts_in_user_link_flags",
oldName = "experimental_linkopts_in_user_link_flags",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If true, flags coming from --linkopt Bazel option will appear in user_link_flags "
+ "crosstool variable, not in legacy_link_flags.")
public boolean enableLinkoptsInUserLinkFlags;

@Option(
name = "incompatible_dont_emit_static_libgcc",
oldName = "experimental_dont_emit_static_libgcc",
Expand All @@ -742,6 +757,21 @@ public Label getFdoPrefetchHintsLabel() {
+ "the responsibility of the C++ toolchain to append this flag.")
public boolean disableEmittingStaticLibgcc;

@Option(
name = "incompatible_disable_runtimes_filegroups",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES, OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If true, cc_toolchain.static_runtime_libs and cc_toolchain.dynamic_runtime_libs are "
+ "replaced by cc_toolchain.static_runtime_lib and cc_toolchain.dynamic_runtime_lib "
+ "(see https://github.com/bazelbuild/bazel/issues/6942)")
public boolean disableRuntimesFilegroups;

@Option(
name = "incompatible_disable_crosstool_file",
defaultValue = "false",
Expand Down Expand Up @@ -879,6 +909,7 @@ public FragmentOptions getHost() {
host.disableGenruleCcToolchainDependency = disableGenruleCcToolchainDependency;
host.disableEmittingStaticLibgcc = disableEmittingStaticLibgcc;
host.disableDepsetInUserFlags = disableDepsetInUserFlags;
host.disableRuntimesFilegroups = disableRuntimesFilegroups;
host.disableExpandIfAllAvailableInFlagSet = disableExpandIfAllAvailableInFlagSet;
host.disableLegacyCcProvider = disableLegacyCcProvider;
host.removeCpuCompilerCcToolchainAttributes = removeCpuCompilerCcToolchainAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.platform.ToolchainInfo;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
Expand Down Expand Up @@ -216,7 +217,8 @@ private boolean usePicForBinariesWithConfiguration(String... configuration) thro
/* requestedFeatures= */ ImmutableSet.of(),
/* unsupportedFeatures= */ ImmutableSet.of(),
toolchainProvider);
return CppHelper.usePicForBinaries(toolchainProvider, featureConfiguration);
RuleContext ruleContext = getRuleContext(target);
return CppHelper.usePicForBinaries(ruleContext, toolchainProvider, featureConfiguration);
}

@Test
Expand Down
Loading

0 comments on commit 0e7c3e6

Please sign in to comment.