Skip to content

Commit 1c78488

Browse files
committed
add backend trait method
1 parent 782b482 commit 1c78488

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/librustc_codegen_llvm/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
9090
) {
9191
base::write_compressed_metadata(tcx, metadata, llvm_module)
9292
}
93+
fn write_idata_sections<'tcx>(
94+
&self,
95+
tcx: TyCtxt<'tcx>,
96+
raw_dylibs: &[RawDylibImports],
97+
module: &mut ModuleLlvm,
98+
){
99+
base::write_idata_sections(tcx, raw_dylibs, module)
100+
}
93101
fn codegen_allocator<'tcx>(
94102
&self,
95103
tcx: TyCtxt<'tcx>,

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ pub trait CodegenBackend {
8989
) -> Result<(), ErrorReported>;
9090
}
9191

92+
//TODO: Put this somewhere else?
93+
#[derive(Debug)]
94+
pub enum RawDylibImportName {
95+
Name(Symbol),
96+
Ordinal(u16),
97+
}
98+
99+
#[derive(Debug)]
100+
pub struct RawDylibImports {
101+
pub name: Symbol,
102+
pub items: Vec<RawDylibImportName>
103+
}
104+
105+
92106
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
93107
fn new_metadata(&self, sess: TyCtxt<'_>, mod_name: &str) -> Self::Module;
94108
fn write_compressed_metadata<'tcx>(
@@ -97,6 +111,12 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
97111
metadata: &EncodedMetadata,
98112
llvm_module: &mut Self::Module,
99113
);
114+
fn write_idata_sections<'tcx>(
115+
&self,
116+
tcx: TyCtxt<'tcx>,
117+
raw_dylib_imports: &[RawDylibImports],
118+
mods: &mut Self::Module,
119+
);
100120
fn codegen_allocator<'tcx>(
101121
&self,
102122
tcx: TyCtxt<'tcx>,

src/librustc_codegen_ssa/traits/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod write;
3030
pub use self::abi::AbiBuilderMethods;
3131
pub use self::asm::{AsmBuilderMethods, AsmMethods, InlineAsmOperandRef};
3232
pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods};
33+
pub use self::backend::{RawDylibImports, RawDylibImportName};
3334
pub use self::builder::{BuilderMethods, OverflowOp};
3435
pub use self::consts::ConstMethods;
3536
pub use self::debuginfo::{DebugInfoBuilderMethods, DebugInfoMethods};

0 commit comments

Comments
 (0)