Add a safe wrapper for LLVMAppendModuleInlineAsm

This patch also changes the Rust-side declaration to take `*const c_uchar`
instead of `*const c_char`, to avoid the need for `AsCCharPtr`.
This commit is contained in:
Zalathar
2025-05-10 18:26:57 +10:00
parent d1bb310a7a
commit b1094f6a0a
4 changed files with 17 additions and 11 deletions

View File

@@ -1148,9 +1148,9 @@ unsafe fn embed_bitcode(
// We need custom section flags, so emit module-level inline assembly.
let section_flags = if cgcx.is_pe_coff { "n" } else { "e" };
let asm = create_section_with_flags_asm(".llvmbc", section_flags, bitcode);
llvm::LLVMAppendModuleInlineAsm(llmod, asm.as_c_char_ptr(), asm.len());
llvm::append_module_inline_asm(llmod, &asm);
let asm = create_section_with_flags_asm(".llvmcmd", section_flags, cmdline.as_bytes());
llvm::LLVMAppendModuleInlineAsm(llmod, asm.as_c_char_ptr(), asm.len());
llvm::append_module_inline_asm(llmod, &asm);
}
}
}