Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa

Use the object crate for metadata reading

This allows sharing the metadata reader between cg_llvm, cg_clif and other codegen backends.

This is not currently useful for rlib reading with cg_spirv ([rust-gpu](https://github.com/EmbarkStudios/rust-gpu/)) as it uses tar rather than ar as .rlib format, but it is useful for dylib reading required for loading proc macros. (cc `@eddyb)`

The object crate is already trusted as dependency of libstd through backtrace. As far as I know it supports reading all object file formats used by targets for which we support rust dylibs with crate metadata, but I am not certain. If this happens to not be the case, I could keep using LLVM for reading dylib metadata.

Marked as WIP for a perf run and as it is based on #83637.
This commit is contained in:
bors 2021-05-14 12:58:58 +00:00
commit 75da570d78
10 changed files with 98 additions and 195 deletions

View file

@ -165,7 +165,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
}
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
Box::new(crate::metadata::CraneliftMetadataLoader)
Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
}
fn provide(&self, _providers: &mut Providers) {}