提交 18d31cc1 编写于 作者: A Alex Crichton

rollup merge of #22150: nagisa/de-perm-frost

Fixes #22124
......@@ -658,14 +658,18 @@ pub fn run_passes(sess: &Session,
}
// Produce final compile outputs.
let copy_gracefully = |from: &Path, to: &Path| {
if let Err(e) = fs::copy(from, to) {
sess.err(&format!("could not copy {:?} to {:?}: {}", from, to, e));
}
};
let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| {
// Three cases:
if sess.opts.cg.codegen_units == 1 {
// 1) Only one codegen unit. In this case it's no difficulty
// to copy `foo.0.x` to `foo.x`.
fs::copy(&crate_output.with_extension(ext),
&crate_output.path(output_type)).unwrap();
copy_gracefully(&crate_output.with_extension(ext), &crate_output.path(output_type));
if !sess.opts.cg.save_temps && !keep_numbered {
// The user just wants `foo.x`, not `foo.0.x`.
remove(sess, &crate_output.with_extension(ext));
......@@ -687,8 +691,7 @@ pub fn run_passes(sess: &Session,
let link_obj = |output_path: &Path| {
// Running `ld -r` on a single input is kind of pointless.
if sess.opts.cg.codegen_units == 1 {
fs::copy(&crate_output.with_extension("0.o"),
output_path).unwrap();
copy_gracefully(&crate_output.with_extension("0.o"), output_path);
// Leave the .0.o file around, to mimic the behavior of the normal
// code path.
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册