diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java index f537693c06e711..42cb4376843f84 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationValue.java @@ -811,6 +811,10 @@ public BuildOptions getOptions() { return buildOptions; } + public CoreOptions getCoreOptions() { + return options; + } + public String getCpu() { return options.cpu; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java index 7d4aeef0580a1d..c71ad76dc62a07 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java @@ -894,6 +894,16 @@ public OutputPathsConverter() { + " of failing. This is to help use cquery diagnose failures in select.") public boolean debugSelectsAlwaysSucceed; + @Option( + name = "experimental_shareable_cpp_compile_actions", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION}, + help = + "If true, cpp actions will be shareable. This will make Bazel not fail with action" + + " conflicts if it finds two identical actions with different configurations.") + public boolean experimentalShareableCppCompileActions; + /** Ways configured targets may provide the {@link Fragment}s they require. */ public enum IncludeConfigFragmentsEnum { /** @@ -936,6 +946,7 @@ public FragmentOptions getHost() { host.includeRequiredConfigFragmentsProvider = includeRequiredConfigFragmentsProvider; host.debugSelectsAlwaysSucceed = debugSelectsAlwaysSucceed; host.checkTestonlyForOutputFiles = checkTestonlyForOutputFiles; + host.experimentalShareableCppCompileActions = experimentalShareableCppCompileActions; // === Runfiles === host.buildRunfilesManifests = buildRunfilesManifests; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java index 7a9305a34dd21e..2bf4399f3924a8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java @@ -92,7 +92,7 @@ public CppCompileActionBuilder( CcToolchainProvider ccToolchain, BuildConfigurationValue configuration) { this.owner = actionConstructionContext.getActionOwner(); - this.shareable = false; + this.shareable = configuration.getCoreOptions().experimentalShareableCppCompileActions; this.configuration = configuration; this.cppConfiguration = configuration.getFragment(CppConfiguration.class); this.mandatoryInputsBuilder = NestedSetBuilder.stableOrder();