1
Fork 0

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

@ -403,6 +403,20 @@ impl OutputTypes {
OutputType::Metadata | OutputType::DepInfo => false,
})
}
// Returns `true` if any of the output types require linking.
pub fn should_link(&self) -> bool {
self.0.keys().any(|k| match *k {
OutputType::Bitcode
| OutputType::Assembly
| OutputType::LlvmAssembly
| OutputType::Mir
| OutputType::Metadata
| OutputType::Object
| OutputType::DepInfo => false,
OutputType::Exe => true,
})
}
}
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.