Add a default implementation for CodegenBackend::link
As a side effect this should add raw-dylib support to cg_gcc as the default ArchiveBuilderBuilder that is used implements create_dll_import_lib. I haven't tested if the raw-dylib support actually works however.
This commit is contained in:
parent
b026d85107
commit
cb44c0c8b6
6 changed files with 14 additions and 64 deletions
|
@ -304,6 +304,14 @@ pub trait ArchiveBuilder {
|
|||
fn build(self: Box<Self>, output: &Path) -> bool;
|
||||
}
|
||||
|
||||
pub struct ArArchiveBuilderBuilder;
|
||||
|
||||
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
|
||||
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
||||
Box::new(ArArchiveBuilder::new(sess, &DEFAULT_OBJECT_READER))
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use = "must call build() to finish building the archive"]
|
||||
pub struct ArArchiveBuilder<'a> {
|
||||
sess: &'a Session,
|
||||
|
|
|
@ -16,6 +16,8 @@ use rustc_span::symbol::Symbol;
|
|||
|
||||
use super::CodegenObject;
|
||||
use super::write::WriteBackendMethods;
|
||||
use crate::back::archive::ArArchiveBuilderBuilder;
|
||||
use crate::back::link::link_binary;
|
||||
use crate::back::write::TargetMachineFactoryFn;
|
||||
use crate::{CodegenResults, ModuleCodegen};
|
||||
|
||||
|
@ -87,7 +89,9 @@ pub trait CodegenBackend {
|
|||
sess: &Session,
|
||||
codegen_results: CodegenResults,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(), ErrorGuaranteed>;
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
link_binary(sess, &ArArchiveBuilderBuilder, &codegen_results, outputs)
|
||||
}
|
||||
|
||||
/// Returns `true` if this backend can be safely called from multiple threads.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue