|
16 | 16 |
|
17 | 17 | import com.google.common.annotations.VisibleForTesting; |
18 | 18 | import com.google.common.base.Functions; |
19 | | -import com.google.common.base.Joiner; |
20 | 19 | import com.google.common.collect.ImmutableList; |
21 | 20 | import com.google.common.collect.ImmutableMap; |
22 | | -import com.google.common.collect.ImmutableSet; |
23 | 21 | import com.google.common.collect.Multimap; |
24 | | -import com.google.common.collect.Sets; |
25 | 22 | import com.google.devtools.build.lib.analysis.ConfigurationsCollector; |
26 | 23 | import com.google.devtools.build.lib.analysis.ConfigurationsResult; |
27 | 24 | import com.google.devtools.build.lib.analysis.Dependency; |
|
37 | 34 | import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition; |
38 | 35 | import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition.TransitionException; |
39 | 36 | import com.google.devtools.build.lib.cmdline.Label; |
40 | | -import com.google.devtools.build.lib.events.Event; |
41 | 37 | import com.google.devtools.build.lib.events.ExtendedEventHandler; |
42 | 38 | import com.google.devtools.build.lib.events.StoredEventHandler; |
43 | 39 | import com.google.devtools.build.lib.packages.Attribute; |
|
47 | 43 | import com.google.devtools.build.lib.skyframe.BuildConfigurationValue; |
48 | 44 | import com.google.devtools.build.lib.skyframe.PackageValue; |
49 | 45 | import com.google.devtools.build.lib.skyframe.PlatformMappingValue; |
50 | | -import com.google.devtools.build.lib.skyframe.TransitiveTargetKey; |
51 | | -import com.google.devtools.build.lib.skyframe.TransitiveTargetValue; |
52 | 46 | import com.google.devtools.build.lib.util.OrderedSetMultimap; |
53 | 47 | import com.google.devtools.build.lib.vfs.PathFragment; |
54 | 48 | import com.google.devtools.build.skyframe.SkyFunction; |
|
59 | 53 | import java.util.Collection; |
60 | 54 | import java.util.Comparator; |
61 | 55 | import java.util.HashMap; |
62 | | -import java.util.HashSet; |
63 | 56 | import java.util.LinkedHashMap; |
64 | 57 | import java.util.LinkedHashSet; |
65 | 58 | import java.util.List; |
|
73 | 66 | * <p>This involves: |
74 | 67 | * |
75 | 68 | * <ol> |
76 | | - * <li>Patching a source configuration's options with the transition |
77 | | - * <li>If {@link BuildConfiguration#trimConfigurations} is true, trimming configuration fragments |
78 | | - * to only those needed by the destination target and its transitive dependencies |
79 | | - * <li>Getting the destination configuration from Skyframe |
| 69 | + * <li>Patching a source configuration's options with the transition. |
| 70 | + * <li>Getting the destination configuration from Skyframe. |
80 | 71 | * </ol> |
81 | 72 | * |
82 | 73 | * <p>For the work of determining the transition requests themselves, see {@link |
@@ -141,9 +132,7 @@ private BuildConfiguration getCurrentConfiguration() { |
141 | 132 | * order, but that involves more runtime in performance-critical code, so we won't make that |
142 | 133 | * change without a clear need. |
143 | 134 | * |
144 | | - * <p>If {@link BuildConfiguration#trimConfigurations()} is true, these configurations only |
145 | | - * contain the fragments needed by the dep and its transitive closure. Else they unconditionally |
146 | | - * include all fragments. |
| 135 | + * <p>These configurations unconditionally include all fragments. |
147 | 136 | * |
148 | 137 | * <p>This method is heavily performance-optimized. Because {@link |
149 | 138 | * com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction} calls it over every edge in |
@@ -185,18 +174,8 @@ private ImmutableList<Dependency> resolveConfiguration( |
185 | 174 | return ImmutableList.of(resolveHostTransition(dependencyBuilder, dependencyKey)); |
186 | 175 | } |
187 | 176 |
|
188 | | - // Figure out the required fragments for this dep and its transitive closure. |
189 | | - Set<Class<? extends Fragment>> depFragments = |
190 | | - getTransitiveFragments(dependencyKey.getLabel(), getCurrentConfiguration()); |
191 | | - |
192 | | - // TODO(gregce): remove the below call once we have confidence trimmed configurations always |
193 | | - // provide needed fragments. This unnecessarily drags performance on the critical path (up |
194 | | - // to 0.5% of total analysis time as profiled over a simple cc_binary). |
195 | | - if (getCurrentConfiguration().trimConfigurations()) { |
196 | | - checkForMissingFragments(dependencyKind.getAttribute(), dependencyKey, depFragments); |
197 | | - } |
198 | | - |
199 | | - return resolveGenericTransition(depFragments, dependencyBuilder, dependencyKey); |
| 177 | + return resolveGenericTransition( |
| 178 | + getCurrentConfiguration().getFragmentsMap().keySet(), dependencyBuilder, dependencyKey); |
200 | 179 | } |
201 | 180 |
|
202 | 181 | private Dependency resolveNullTransition( |
@@ -352,30 +331,6 @@ private ImmutableList<String> collectTransitionKeys(Attribute attribute) |
352 | 331 | return ImmutableList.of(); |
353 | 332 | } |
354 | 333 |
|
355 | | - /** |
356 | | - * Returns the configuration fragments required by a dep and its transitive closure. Returns null |
357 | | - * if Skyframe dependencies aren't yet available. |
358 | | - * |
359 | | - * @param dep label of the dep to check |
360 | | - * @param parentConfig configuration of the rule depending on the dep |
361 | | - */ |
362 | | - private ImmutableSet<Class<? extends Fragment>> getTransitiveFragments( |
363 | | - Label dep, BuildConfiguration parentConfig) |
364 | | - throws InterruptedException, ValueMissingException { |
365 | | - if (!parentConfig.trimConfigurations()) { |
366 | | - return parentConfig.getFragmentsMap().keySet(); |
367 | | - } |
368 | | - SkyKey fragmentsKey = TransitiveTargetKey.of(dep); |
369 | | - TransitiveTargetValue transitiveDepInfo = (TransitiveTargetValue) env.getValue(fragmentsKey); |
370 | | - if (transitiveDepInfo == null) { |
371 | | - // This should only be possible for tests. In actual runs, this was already called |
372 | | - // as a routine part of the loading phase. |
373 | | - // TODO(bazel-team): check this only occurs in a test context. |
374 | | - throw new ValueMissingException(); |
375 | | - } |
376 | | - return transitiveDepInfo.getTransitiveConfigFragments().toSet(); |
377 | | - } |
378 | | - |
379 | 334 | /** |
380 | 335 | * Applies a configuration transition over a set of build options. |
381 | 336 | * |
@@ -438,52 +393,17 @@ private static BuildOptions addDefaultStarlarkOptions( |
438 | 393 | return optionsWithDefaults == null ? fromOptions : optionsWithDefaults.build(); |
439 | 394 | } |
440 | 395 |
|
441 | | - /** |
442 | | - * Checks the config fragments required by a dep against the fragments in its actual |
443 | | - * configuration. If any are missing, triggers a descriptive "missing fragments" error. |
444 | | - */ |
445 | | - private void checkForMissingFragments( |
446 | | - Attribute attribute, DependencyKey dep, Set<Class<? extends Fragment>> expectedDepFragments) |
447 | | - throws DependencyEvaluationException { |
448 | | - Set<String> ctgFragmentNames = new HashSet<>(); |
449 | | - for (Fragment fragment : getCurrentConfiguration().getFragmentsMap().values()) { |
450 | | - ctgFragmentNames.add(fragment.getClass().getSimpleName()); |
451 | | - } |
452 | | - Set<String> depFragmentNames = new HashSet<>(); |
453 | | - for (Class<? extends Fragment> fragmentClass : expectedDepFragments) { |
454 | | - depFragmentNames.add(fragmentClass.getSimpleName()); |
455 | | - } |
456 | | - Set<String> missing = Sets.difference(depFragmentNames, ctgFragmentNames); |
457 | | - if (!missing.isEmpty()) { |
458 | | - String msg = |
459 | | - String.format( |
460 | | - "%s: dependency %s from attribute \"%s\" is missing required config fragments: %s", |
461 | | - ctgValue.getLabel(), |
462 | | - dep.getLabel(), |
463 | | - attribute == null ? "(null)" : attribute.getName(), |
464 | | - Joiner.on(", ").join(missing)); |
465 | | - env.getListener().handle(Event.error(msg)); |
466 | | - throw new DependencyEvaluationException(new InvalidConfigurationException(msg)); |
467 | | - } |
468 | | - } |
469 | | - |
470 | 396 | /** |
471 | 397 | * This method allows resolution of configurations outside of a skyfunction call. |
472 | 398 | * |
473 | 399 | * <p>Unlike {@link #resolveConfigurations}, this doesn't expect the current context to be |
474 | 400 | * evaluating dependencies of a parent target. So this method is also suitable for top-level |
475 | 401 | * targets. |
476 | 402 | * |
477 | | - * <p>Resolution consists of two steps: |
478 | | - * |
479 | | - * <ol> |
480 | | - * <li>Apply the per-target transitions specified in {@code targetsToEvaluate}. This can be |
481 | | - * used, e.g., to apply {@link |
482 | | - * com.google.devtools.build.lib.analysis.config.transitions.TransitionFactory}s over global |
483 | | - * top-level configurations. |
484 | | - * <li>(Optionally) trim configurations to only the fragments the targets actually need. This is |
485 | | - * triggered by {@link BuildConfiguration#trimConfigurations}. |
486 | | - * </ol> |
| 403 | + * <p>Resolution consists of applying the per-target transitions specified in {@code |
| 404 | + * targetsToEvaluate}. This can be used, e.g., to apply {@link |
| 405 | + * com.google.devtools.build.lib.analysis.config.transitions.TransitionFactory}s over global |
| 406 | + * top-level configurations. |
487 | 407 | * |
488 | 408 | * <p>Preserves the original input order (but merges duplicate nodes that might occur due to |
489 | 409 | * top-level configuration transitions) . Uses original (untrimmed, pre-transition) configurations |
|
0 commit comments