Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build-plan causes everything to need recompiling #7604

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,17 @@ fn rustc<'a, 'cfg>(
add_custom_env(&mut rustc, &script_outputs, current_id, kind)?;
}

for output in outputs.iter() {
// If there is both an rmeta and rlib, rustc will prefer to use the
// rlib, even if it is older. Therefore, we must delete the rlib to
// force using the new rmeta.
if output.path.extension() == Some(OsStr::new("rmeta")) {
let dst = root.join(&output.path).with_extension("rlib");
if dst.exists() {
paths::remove_file(&dst)?;
// Don't touch any file when we are generating build-plan
if !build_plan {
for output in outputs.iter() {
// If there is both an rmeta and rlib, rustc will prefer to use the
// rlib, even if it is older. Therefore, we must delete the rlib to
// force using the new rmeta.
if output.path.extension() == Some(OsStr::new("rmeta")) {
let dst = root.join(&output.path).with_extension("rlib");
if dst.exists() {
paths::remove_file(&dst)?;
}
}
}
}
Expand All @@ -277,10 +280,12 @@ fn rustc<'a, 'cfg>(
}

state.running(&rustc);
let timestamp = paths::set_invocation_time(&fingerprint_dir)?;
if build_plan {
let timestamp = if build_plan {
state.build_plan(buildkey, rustc.clone(), outputs.clone());
// Build plan should not touch the timestamp
None
} else {
let timestamp = paths::set_invocation_time(&fingerprint_dir)?;
exec.exec(
rustc,
package_id,
Expand All @@ -291,7 +296,8 @@ fn rustc<'a, 'cfg>(
)
.map_err(internal_if_simple_exit_code)
.chain_err(|| format!("could not compile `{}`.", name))?;
}
Some(timestamp)
};

if do_rename && real_name != crate_name {
let dst = &outputs[0].path;
Expand Down Expand Up @@ -324,7 +330,10 @@ fn rustc<'a, 'cfg>(
rustc_dep_info_loc.display()
))
})?;
filetime::set_file_times(dep_info_loc, timestamp, timestamp)?;

if let Some(timestamp) = timestamp {
filetime::set_file_times(dep_info_loc, timestamp, timestamp)?;
}
}

Ok(())
Expand Down