Skip linking if it is not required

This allows to use `--emit=metadata,obj` and other metadata
+ non-link combinations.

Fixes #81117.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
Miguel Ojeda 2021-01-17 15:06:47 +01:00
parent fc9944fe84
commit f9275e1092
3 changed files with 23 additions and 4 deletions

View file

@ -74,7 +74,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
}
});
if outputs.outputs.should_codegen() {
if outputs.outputs.should_link() {
let tmpdir = TempFileBuilder::new()
.prefix("rustc")
.tempdir()
@ -123,9 +123,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
}
};
if sess.opts.output_types.should_codegen()
&& !preserve_objects_for_their_debuginfo(sess)
{
if sess.opts.output_types.should_link() && !preserve_objects_for_their_debuginfo(sess) {
for module in &codegen_results.modules {
remove_temps_from_module(module);
}