Skip to content

Commit

Permalink
Fix exponentiality in depend_on_deps_of_deps.
Browse files Browse the repository at this point in the history
goffrie committed Jun 24, 2019

Verified

This commit was signed with the committer’s verified signature.
davidwendt David Wendt
1 parent 4c1fa54 commit 1863aa2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
@@ -154,12 +154,12 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
let dependencies = cx.dep_targets(unit);
let mut queue_deps = dependencies
.iter()
.cloned()
.filter(|unit| {
// Binaries aren't actually needed to *compile* tests, just to run
// them, so we don't include this dependency edge in the job graph.
!unit.target.is_test() || !unit.target.is_bin()
})
.cloned()
.map(|dep| {
// Handle the case here where our `unit -> dep` dependency may
// only require the metadata, not the full compilation to
@@ -172,7 +172,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
};
(dep, artifact)
})
.collect::<Vec<_>>();
.collect::<HashMap<_, _>>();

// This is somewhat tricky, but we may need to synthesize some
// dependencies for this target if it requires full upstream
@@ -196,19 +196,18 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
// `Metadata` propagate upwards `All` dependencies to anything that
// transitively contains the `Metadata` edge.
if unit.requires_upstream_objects() {
for dep in dependencies.iter() {
for dep in dependencies {
depend_on_deps_of_deps(cx, &mut queue_deps, dep);
}

fn depend_on_deps_of_deps<'a>(
cx: &Context<'a, '_>,
deps: &mut Vec<(Unit<'a>, Artifact)>,
unit: &Unit<'a>,
deps: &mut HashMap<Unit<'a>, Artifact>,
unit: Unit<'a>,
) {
for dep in cx.dep_targets(unit) {
if cx.only_requires_rmeta(unit, &dep) {
deps.push((dep, Artifact::All));
depend_on_deps_of_deps(cx, deps, &dep);
for dep in cx.dep_targets(&unit) {
if deps.insert(dep, Artifact::All).is_none() {
depend_on_deps_of_deps(cx, deps, dep);
}
}
}

0 comments on commit 1863aa2

Please sign in to comment.