Skip to content

Commit 938e348

Browse files
tjgqShreeM01
andauthored
[6.1.0] Rerun the artifact conflict check when --incompatible_strict_conflict_checks changes. (bazelbuild#17592)
Related to bazelbuild#16729. PiperOrigin-RevId: 511432374 Change-Id: I00b0bff5731a3468bf0a56c4a44e95590da7b463 Co-authored-by: kshyanashree <[email protected]>
1 parent aafe123 commit 938e348

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

src/main/java/com/google/devtools/build/lib/analysis/AnalysisOptions.java

-11
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,6 @@ public class AnalysisOptions extends OptionsBase {
9090
help = "Deprecated. No-op.")
9191
public boolean skyframePrepareAnalysis;
9292

93-
@Option(
94-
name = "incompatible_strict_conflict_checks",
95-
oldName = "experimental_strict_conflict_checks",
96-
defaultValue = "false",
97-
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
98-
metadataTags = OptionMetadataTag.INCOMPATIBLE_CHANGE,
99-
effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
100-
help =
101-
"Check for action prefix file path conflicts, regardless of action-specific overrides.")
102-
public boolean strictConflictChecks;
103-
10493
@Option(
10594
name = "experimental_skyframe_cpu_heavy_skykeys_thread_pool_size",
10695
defaultValue = "HOST_CPUS",

src/main/java/com/google/devtools/build/lib/analysis/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ java_library(
610610
":blaze_directories",
611611
":config/build_configuration",
612612
":config/build_options",
613+
":config/core_options",
613614
":config/invalid_configuration_exception",
614615
":configured_target",
615616
":constraints/platform_restrictions_result",

src/main/java/com/google/devtools/build/lib/analysis/BuildView.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
4444
import com.google.devtools.build.lib.analysis.config.BuildOptions;
4545
import com.google.devtools.build.lib.analysis.config.ConfigurationResolver.TopLevelTargetsAndConfigsResult;
46+
import com.google.devtools.build.lib.analysis.config.CoreOptions;
4647
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
4748
import com.google.devtools.build.lib.analysis.constraints.PlatformRestrictionsResult;
4849
import com.google.devtools.build.lib.analysis.constraints.RuleContextConstraintSemantics;
@@ -400,7 +401,7 @@ public AnalysisResult update(
400401
bugReporter,
401402
keepGoing,
402403
loadingPhaseThreads,
403-
viewOptions.strictConflictChecks,
404+
targetOptions.get(CoreOptions.class).strictConflictChecks,
404405
checkForActionConflicts,
405406
viewOptions.cpuHeavySkyKeysThreadPoolSize);
406407
setArtifactRoots(skyframeAnalysisResult.getPackageRoots());
@@ -426,7 +427,7 @@ public AnalysisResult update(
426427
Preconditions.checkNotNull(resourceManager), // non-null for skymeld.
427428
Preconditions.checkNotNull(buildResultListener), // non-null for skymeld.
428429
keepGoing,
429-
viewOptions.strictConflictChecks,
430+
targetOptions.get(CoreOptions.class).strictConflictChecks,
430431
checkForActionConflicts,
431432
loadingPhaseThreads,
432433
viewOptions.cpuHeavySkyKeysThreadPoolSize,

src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java

+12
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ public class CoreOptions extends FragmentOptions implements Cloneable {
170170
+ "disabled.")
171171
public boolean strictFilesets;
172172

173+
@Option(
174+
name = "incompatible_strict_conflict_checks",
175+
oldName = "experimental_strict_conflict_checks",
176+
defaultValue = "false",
177+
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
178+
metadataTags = OptionMetadataTag.INCOMPATIBLE_CHANGE,
179+
effectTags = {OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION},
180+
help =
181+
"Check for action prefix file path conflicts, regardless of action-specific overrides.")
182+
public boolean strictConflictChecks;
183+
173184
@Option(
174185
name = "experimental_strict_fileset_output",
175186
defaultValue = "false",
@@ -959,6 +970,7 @@ public FragmentOptions getHost() {
959970
host.includeRequiredConfigFragmentsProvider = includeRequiredConfigFragmentsProvider;
960971
host.debugSelectsAlwaysSucceed = debugSelectsAlwaysSucceed;
961972
host.checkTestonlyForOutputFiles = checkTestonlyForOutputFiles;
973+
host.strictConflictChecks = strictConflictChecks;
962974

963975
// === Runfiles ===
964976
host.buildRunfilesManifests = buildRunfilesManifests;

src/test/java/com/google/devtools/build/lib/buildtool/OutputArtifactConflictTest.java

+50
Original file line numberDiff line numberDiff line change
@@ -734,4 +734,54 @@ public void dependencyHasConflict_keepGoing_bothTopLevelTargetsFail(
734734
assertThat(eventListener.failedTargetNames)
735735
.containsExactly("//foo:top_level_a", "//foo:top_level_b");
736736
}
737+
738+
private void setupStrictConflictChecksTest() throws IOException {
739+
write(
740+
"foo/conflict.bzl",
741+
"def _impl(ctx):",
742+
" dir = ctx.actions.declare_directory(ctx.label.name + '.dir')",
743+
" file = ctx.actions.declare_file(ctx.label.name + '.dir/file.txt')",
744+
" ctx.actions.run_shell(",
745+
" outputs = [dir, file],",
746+
" command = 'mkdir -p $1 && touch $2',",
747+
" arguments = [dir.path, file.path],",
748+
" )",
749+
" return [DefaultInfo(files = depset([dir, file]))]",
750+
"",
751+
"my_rule = rule(implementation = _impl)");
752+
write("foo/BUILD", "load(':conflict.bzl', 'my_rule')", "my_rule(name = 'bar')");
753+
}
754+
755+
@Test
756+
public void laxFollowedByStrictConflictChecks(@TestParameter boolean mergedAnalysisExecution)
757+
throws Exception {
758+
setupStrictConflictChecksTest();
759+
addOptions("--experimental_merged_skyframe_analysis_execution=" + mergedAnalysisExecution);
760+
761+
addOptions("--noincompatible_strict_conflict_checks");
762+
buildTarget("//foo:bar");
763+
assertNoEvents(events.errors());
764+
765+
addOptions("--incompatible_strict_conflict_checks");
766+
assertThrows(ViewCreationFailedException.class, () -> buildTarget("//foo:bar"));
767+
events.assertContainsError("One of the output paths");
768+
events.assertContainsError("is a prefix of the other");
769+
}
770+
771+
@Test
772+
public void strictFollowedByLaxConflictChecks(@TestParameter boolean mergedAnalysisExecution)
773+
throws Exception {
774+
setupStrictConflictChecksTest();
775+
addOptions("--experimental_merged_skyframe_analysis_execution=" + mergedAnalysisExecution);
776+
777+
addOptions("--incompatible_strict_conflict_checks");
778+
assertThrows(ViewCreationFailedException.class, () -> buildTarget("//foo:bar"));
779+
events.assertContainsError("One of the output paths");
780+
events.assertContainsError("is a prefix of the other");
781+
782+
events.clear();
783+
addOptions("--noincompatible_strict_conflict_checks");
784+
buildTarget("//foo:bar");
785+
assertNoEvents(events.errors());
786+
}
737787
}

0 commit comments

Comments
 (0)