From 28f604eb77f5966bccd78d5885c78b2fc935a582 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 20 Nov 2020 20:37:01 +0200 Subject: [PATCH] Use rustc_codegen_llvm's get_dylib_metadata to unblock proc macros. (#268) --- crates/rustc_codegen_spirv/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 6536a7937f..c2398d3f94 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -230,8 +230,16 @@ impl MetadataLoader for SpirvMetadataLoader { link::read_metadata(path) } - fn get_dylib_metadata(&self, _: &Target, _: &Path) -> Result { - Err("TODO: implement get_dylib_metadata".to_string()) + fn get_dylib_metadata(&self, target: &Target, path: &Path) -> Result { + // HACK(eddyb) this is needed to allow metadata loading for proc macros + // (compiled as host dylibs); perhaps it'd be better to use the `object` + // crate, like `rustc_codegen_cranelift` does. + // NOTE(eddyb) while both `::new()` and `.metadata_loader()` call `Box::new`, + // they only do so with ZST values, and so we don't pointlessly allocate. + extern crate rustc_codegen_llvm; + rustc_codegen_llvm::LlvmCodegenBackend::new() + .metadata_loader() + .get_dylib_metadata(target, path) } }