diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-11-09 20:42:56 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-11-09 20:42:56 +0000 |
| commit | cb44c0c8b66e9033c77db69bc10443e20d8adc0b (patch) | |
| tree | f755238246d1e457df647c35b856dc6164c7a2f1 /compiler/rustc_codegen_ssa/src | |
| parent | b026d85107d4c33e7d2571c70115a29a5d2a4cf5 (diff) | |
| download | rust-cb44c0c8b66e9033c77db69bc10443e20d8adc0b.tar.gz rust-cb44c0c8b66e9033c77db69bc10443e20d8adc0b.zip | |
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.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/archive.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/backend.rs | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index e83bfa7b70d..d4836eb7a1d 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -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, diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 676fb181d67..e8e8ade4126 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -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. /// |
