diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-05-30 11:55:06 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-06-03 10:04:34 +0000 |
| commit | badabab01f15f156dbb6ce39df4a339006fbfae1 (patch) | |
| tree | fec9ba97cb1f0d7770f52316dfcab95e8bac589f /compiler/rustc_codegen_cranelift/src | |
| parent | c68032fd4c442d275f4daa571ba19c076106b490 (diff) | |
| download | rust-badabab01f15f156dbb6ce39df4a339006fbfae1.tar.gz rust-badabab01f15f156dbb6ce39df4a339006fbfae1.zip | |
Only borrow EncodedMetadata in codegen_crate
And move passing it to the linker to the driver code.
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/driver/aot.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/lib.rs | 9 |
2 files changed, 4 insertions, 18 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 5d07c94859f..58a0a380945 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -62,7 +62,6 @@ pub(crate) struct OngoingCodegen { modules: Vec<OngoingModuleCodegen>, allocator_module: Option<CompiledModule>, metadata_module: Option<CompiledModule>, - metadata: EncodedMetadata, crate_info: CrateInfo, concurrency_limiter: ConcurrencyLimiter, } @@ -135,7 +134,6 @@ impl OngoingCodegen { modules, allocator_module: self.allocator_module, metadata_module: self.metadata_module, - metadata: self.metadata, crate_info: self.crate_info, }; @@ -706,11 +704,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> { } } -pub(crate) fn run_aot( - tcx: TyCtxt<'_>, - metadata: EncodedMetadata, - need_metadata_module: bool, -) -> Box<OngoingCodegen> { +pub(crate) fn run_aot(tcx: TyCtxt<'_>, metadata: Option<&EncodedMetadata>) -> Box<OngoingCodegen> { // FIXME handle `-Ctarget-cpu=native` let target_cpu = match tcx.sess.opts.cg.target_cpu { Some(ref name) => name, @@ -727,7 +721,6 @@ pub(crate) fn run_aot( modules: vec![], allocator_module: None, metadata_module: None, - metadata, crate_info: CrateInfo::new(tcx, target_cpu), concurrency_limiter: ConcurrencyLimiter::new(0), }); @@ -787,14 +780,12 @@ pub(crate) fn run_aot( let allocator_module = emit_allocator_module(tcx); - let metadata_module = - if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None }; + let metadata_module = metadata.map(|metadata| emit_metadata_module(tcx, metadata)); Box::new(OngoingCodegen { modules, allocator_module, metadata_module, - metadata, crate_info: CrateInfo::new(tcx, target_cpu), concurrency_limiter: concurrency_limiter.0, }) diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 8ef623cde00..277d4f16f19 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -238,12 +238,7 @@ impl CodegenBackend for CraneliftCodegenBackend { println!("Cranelift version: {}", cranelift_codegen::VERSION); } - fn codegen_crate( - &self, - tcx: TyCtxt<'_>, - metadata: EncodedMetadata, - need_metadata_module: bool, - ) -> Box<dyn Any> { + fn codegen_crate(&self, tcx: TyCtxt<'_>, metadata: Option<&EncodedMetadata>) -> Box<dyn Any> { info!("codegen crate {}", tcx.crate_name(LOCAL_CRATE)); let config = self.config.clone().unwrap_or_else(|| { BackendConfig::from_opts(&tcx.sess.opts.cg.llvm_args) @@ -256,7 +251,7 @@ impl CodegenBackend for CraneliftCodegenBackend { #[cfg(not(feature = "jit"))] tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift"); } else { - driver::aot::run_aot(tcx, metadata, need_metadata_module) + driver::aot::run_aot(tcx, metadata) } } |
