Skip to content

Commit 28f604e

Browse files
authored
Use rustc_codegen_llvm's get_dylib_metadata to unblock proc macros. (EmbarkStudios#268)
1 parent a92d76a commit 28f604e

File tree

1 file changed

+10
-2
lines changed
  • crates/rustc_codegen_spirv/src

1 file changed

+10
-2
lines changed

crates/rustc_codegen_spirv/src/lib.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,16 @@ impl MetadataLoader for SpirvMetadataLoader {
230230
link::read_metadata(path)
231231
}
232232

233-
fn get_dylib_metadata(&self, _: &Target, _: &Path) -> Result<MetadataRef, String> {
234-
Err("TODO: implement get_dylib_metadata".to_string())
233+
fn get_dylib_metadata(&self, target: &Target, path: &Path) -> Result<MetadataRef, String> {
234+
// HACK(eddyb) this is needed to allow metadata loading for proc macros
235+
// (compiled as host dylibs); perhaps it'd be better to use the `object`
236+
// crate, like `rustc_codegen_cranelift` does.
237+
// NOTE(eddyb) while both `::new()` and `.metadata_loader()` call `Box::new`,
238+
// they only do so with ZST values, and so we don't pointlessly allocate.
239+
extern crate rustc_codegen_llvm;
240+
rustc_codegen_llvm::LlvmCodegenBackend::new()
241+
.metadata_loader()
242+
.get_dylib_metadata(target, path)
235243
}
236244
}
237245

0 commit comments

Comments
 (0)