From 3a1795ea303ebcc5eaec2ada5ab04a160b57de1d Mon Sep 17 00:00:00 2001 From: Torgil Svensson Date: Wed, 17 Nov 2021 14:44:44 +0100 Subject: [PATCH] Add experimental flag to make cpp compile actions shareable --- .../lib/analysis/config/BuildConfigurationValue.java | 4 ++++ .../build/lib/analysis/config/CoreOptions.java | 11 +++++++++++ .../build/lib/rules/cpp/CppCompileActionBuilder.java | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) 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 5fde096e002f9a..1aa21c76e1237a 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 @@ -689,6 +689,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 589ac7ef7282f1..c95a8c5ea66476 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 @@ -827,6 +827,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 configuration.") + public boolean experimentalShareableCppCompileActions; + /** Ways configured targets may provide the {@link Fragment}s they require. */ public enum IncludeConfigFragmentsEnum { /** @@ -867,6 +877,7 @@ public FragmentOptions getHost() { host.cpu = hostCpu; host.includeRequiredConfigFragmentsProvider = includeRequiredConfigFragmentsProvider; host.debugSelectsAlwaysSucceed = debugSelectsAlwaysSucceed; + 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 5ccf6a477f6d74..391ffac593b9e9 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 @@ -90,7 +90,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();