From 3b5e3b8557fa05f1a76a088cc3d52833f43211de Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Fri, 20 Nov 2020 18:01:04 +0000 Subject: [PATCH] Use rustc_codegen_llvm's get_dylib_metadata to unblock proc macros. --- 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 73904ab5ca..fce9dc4ca2 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -231,8 +231,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) } }