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:
commit
75da570d78
10 changed files with 98 additions and 195 deletions
|
|
@ -28,23 +28,11 @@ use rustc_target::spec::Target;
|
|||
use std::any::Any;
|
||||
use std::path::Path;
|
||||
|
||||
pub struct NoLlvmMetadataLoader;
|
||||
|
||||
impl MetadataLoader for NoLlvmMetadataLoader {
|
||||
fn get_rlib_metadata(&self, _: &Target, filename: &Path) -> Result<MetadataRef, String> {
|
||||
unreachable!("some_crate.rs shouldn't depend on any external crates");
|
||||
}
|
||||
|
||||
fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<MetadataRef, String> {
|
||||
unreachable!("some_crate.rs shouldn't depend on any external crates");
|
||||
}
|
||||
}
|
||||
|
||||
struct TheBackend;
|
||||
|
||||
impl CodegenBackend for TheBackend {
|
||||
fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
|
||||
Box::new(NoLlvmMetadataLoader)
|
||||
Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
|
||||
}
|
||||
|
||||
fn provide(&self, providers: &mut Providers) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue