diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-13 15:56:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-13 15:56:55 +0100 |
| commit | 448bad9eba322a11bd5ff25e1f898284ded22946 (patch) | |
| tree | 1f42c99e065a9d4372d315af0e9a63628d073d3c /compiler/rustc_codegen_llvm/src | |
| parent | 3ff1b6410e87a237559ab76ecd50f180afbe861f (diff) | |
| parent | 694950d73c420a01c96c08e2f93836ae08616780 (diff) | |
| download | rust-448bad9eba322a11bd5ff25e1f898284ded22946.tar.gz rust-448bad9eba322a11bd5ff25e1f898284ded22946.zip | |
Rollup merge of #133752 - klensy:cp, r=davidtwco
replace copypasted ModuleLlvm::parse replaced code same as in https://github.com/rust-lang/rust/blob/bd36e69d2533ee750e2d805915b8ca88d2825e0f/compiler/rustc_codegen_llvm/src/lib.rs#L426-L445 except before error message was emitted via `write::llvm_err`, which returned other error kind, but it still ok?
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 08b774f8d6e..78c759bbe8c 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use std::ffi::{CStr, CString}; use std::fs::File; -use std::mem::ManuallyDrop; use std::path::Path; use std::sync::Arc; use std::{io, iter, slice}; @@ -9,7 +8,7 @@ use std::{io, iter, slice}; use object::read::archive::ArchiveFile; use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared}; use rustc_codegen_ssa::back::symbol_export; -use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, TargetMachineFactoryConfig}; +use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::fx::FxHashMap; @@ -706,18 +705,15 @@ pub(crate) unsafe fn optimize_thin_module( let dcx = dcx.handle(); let module_name = &thin_module.shared.module_names[thin_module.idx]; - let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap()); - let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(dcx, e))?; // Right now the implementation we've got only works over serialized // modules, so we create a fresh new LLVM context and parse the module // into that context. One day, however, we may do this for upstream // crates but for locally codegened modules we may be able to reuse // that LLVM Context and Module. - let llcx = unsafe { llvm::LLVMRustContextCreate(cgcx.fewer_names) }; - let llmod_raw = parse_module(llcx, module_name, thin_module.data(), dcx)? as *const _; + let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx)?; let mut module = ModuleCodegen { - module_llvm: ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) }, + module_llvm, name: thin_module.name().to_string(), kind: ModuleKind::Regular, }; |
