Save pre-link bitcode to ModuleCodegen

This commit is contained in:
DianQK
2025-02-06 22:00:19 +08:00
parent 9431427cc3
commit da50297a6e
7 changed files with 33 additions and 22 deletions

View File

@@ -776,6 +776,10 @@ pub(crate) unsafe fn optimize_thin_module(
// that LLVM Context and Module.
let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx)?;
let mut module = ModuleCodegen::new_regular(thin_module.name(), module_llvm);
// Given that the newly created module lacks a thinlto buffer for embedding, we need to re-add it here.
if cgcx.config(ModuleKind::Regular).embed_bitcode() {
module.thin_lto_buffer = Some(thin_module.data().to_vec());
}
{
let target = &*module.module_llvm.tm;
let llmod = module.module_llvm.llmod();