diff --git a/src/backend/llvm/abi.rs b/src/backend/llvm/abi.rs index b84dbca..a4c4812 100644 --- a/src/backend/llvm/abi.rs +++ b/src/backend/llvm/abi.rs @@ -10,7 +10,7 @@ use llvm_sys::core::*; use llvm_sys::prelude::*; use std::collections::BTreeMap; -use std::ffi::CString; +use std::ffi::{CString, c_char}; use std::ptr; use crate::backend::BackendError; @@ -120,7 +120,7 @@ unsafe fn define_ot_call( builder, func_ptr_param, callee_ptr_ty, - b"callee\0".as_ptr() as *const i8, + b"callee\0".as_ptr() as *const c_char, ); let call_name = CString::new("result0").unwrap(); let result = LLVMBuildCall2( @@ -206,15 +206,15 @@ unsafe fn define_ot_console_log( builder, value_param, double_ty, - b"dval\0".as_ptr() as *const i8, + b"dval\0".as_ptr() as *const c_char, ); // Create format string "%g\n" as a global constant // Use LLVMBuildGlobalStringPtr for simpler string handling let fmt_ptr = LLVMBuildGlobalStringPtr( builder, - b"%g\n\0".as_ptr() as *const i8, - b".fmt\0".as_ptr() as *const i8, + b"%g\n\0".as_ptr() as *const c_char, + b".fmt\0".as_ptr() as *const c_char, ); // Call printf @@ -229,7 +229,7 @@ unsafe fn define_ot_console_log( printf_func, printf_args.as_mut_ptr(), 2, - b"printf_result\0".as_ptr() as *const i8, + b"printf_result\0".as_ptr() as *const c_char, ); } @@ -277,8 +277,18 @@ where let b_i64 = LLVMGetParam(func, 1); // Bitcast i64 to double - let a_fp = LLVMBuildBitCast(builder, a_i64, double_ty, b"a_fp\0".as_ptr() as *const i8); - let b_fp = LLVMBuildBitCast(builder, b_i64, double_ty, b"b_fp\0".as_ptr() as *const i8); + let a_fp = LLVMBuildBitCast( + builder, + a_i64, + double_ty, + b"a_fp\0".as_ptr() as *const c_char, + ); + let b_fp = LLVMBuildBitCast( + builder, + b_i64, + double_ty, + b"b_fp\0".as_ptr() as *const c_char, + ); // Perform operation let result_fp = op(builder, a_fp, b_fp, context); @@ -288,7 +298,7 @@ where builder, result_fp, i64_ty, - b"result\0".as_ptr() as *const i8, + b"result\0".as_ptr() as *const c_char, ); LLVMBuildRet(builder, result_i64); @@ -331,7 +341,12 @@ where let a_i64 = LLVMGetParam(func, 0); // Bitcast i64 to double - let a_fp = LLVMBuildBitCast(builder, a_i64, double_ty, b"a_fp\0".as_ptr() as *const i8); + let a_fp = LLVMBuildBitCast( + builder, + a_i64, + double_ty, + b"a_fp\0".as_ptr() as *const c_char, + ); // Perform operation let result_fp = op(builder, a_fp, context); @@ -341,7 +356,7 @@ where builder, result_fp, i64_ty, - b"result\0".as_ptr() as *const i8, + b"result\0".as_ptr() as *const c_char, ); LLVMBuildRet(builder, result_i64); @@ -456,7 +471,7 @@ unsafe fn define_simple_stubs( stubs.insert( "ot_add_any".to_string(), create_binary_fp_op(module, context, "ot_add_any", |builder, a, b, _ctx| { - LLVMBuildFAdd(builder, a, b, b"add\0".as_ptr() as *const i8) + LLVMBuildFAdd(builder, a, b, b"add\0".as_ptr() as *const c_char) })?, ); @@ -464,7 +479,7 @@ unsafe fn define_simple_stubs( stubs.insert( "ot_sub_any".to_string(), create_binary_fp_op(module, context, "ot_sub_any", |builder, a, b, _ctx| { - LLVMBuildFSub(builder, a, b, b"sub\0".as_ptr() as *const i8) + LLVMBuildFSub(builder, a, b, b"sub\0".as_ptr() as *const c_char) })?, ); @@ -472,7 +487,7 @@ unsafe fn define_simple_stubs( stubs.insert( "ot_mul_any".to_string(), create_binary_fp_op(module, context, "ot_mul_any", |builder, a, b, _ctx| { - LLVMBuildFMul(builder, a, b, b"mul\0".as_ptr() as *const i8) + LLVMBuildFMul(builder, a, b, b"mul\0".as_ptr() as *const c_char) })?, ); @@ -480,7 +495,7 @@ unsafe fn define_simple_stubs( stubs.insert( "ot_div_any".to_string(), create_binary_fp_op(module, context, "ot_div_any", |builder, a, b, _ctx| { - LLVMBuildFDiv(builder, a, b, b"div\0".as_ptr() as *const i8) + LLVMBuildFDiv(builder, a, b, b"div\0".as_ptr() as *const c_char) })?, ); @@ -488,7 +503,7 @@ unsafe fn define_simple_stubs( stubs.insert( "ot_mod_any".to_string(), create_binary_fp_op(module, context, "ot_mod_any", |builder, a, b, _ctx| { - LLVMBuildFRem(builder, a, b, b"mod\0".as_ptr() as *const i8) + LLVMBuildFRem(builder, a, b, b"mod\0".as_ptr() as *const c_char) })?, ); @@ -498,7 +513,7 @@ unsafe fn define_simple_stubs( create_unary_fp_op(module, context, "ot_neg", |builder, a, ctx| { let double_ty = LLVMDoubleTypeInContext(ctx); let zero = LLVMConstReal(double_ty, 0.0); - LLVMBuildFSub(builder, zero, a, b"neg\0".as_ptr() as *const i8) + LLVMBuildFSub(builder, zero, a, b"neg\0".as_ptr() as *const c_char) })?, ); diff --git a/src/backend/llvm/bitcode.rs b/src/backend/llvm/bitcode.rs index 55a9ea3..ec1683d 100644 --- a/src/backend/llvm/bitcode.rs +++ b/src/backend/llvm/bitcode.rs @@ -4,7 +4,7 @@ //! which are used for link-time optimization (LTO). use llvm_sys::prelude::*; -use std::ffi::{CStr, CString}; +use std::ffi::{CStr, CString, c_char}; use std::path::Path; use crate::backend::BackendError; @@ -19,7 +19,7 @@ pub unsafe fn emit_bitcode_file(module: LLVMModuleRef, path: &Path) -> Result<() } let path_cstr = CString::new(path.to_str().unwrap()).unwrap(); - let error_msg: *mut i8 = std::ptr::null_mut(); + let error_msg: *mut c_char = std::ptr::null_mut(); let result = llvm_sys::bit_writer::LLVMWriteBitcodeToFile(module, path_cstr.as_ptr()); @@ -54,7 +54,7 @@ pub unsafe fn read_bitcode_file( } let path_cstr = CString::new(path.to_str().unwrap()).unwrap(); - let mut error_msg: *mut i8 = std::ptr::null_mut(); + let mut error_msg: *mut c_char = std::ptr::null_mut(); let mut mem_buf: LLVMMemoryBufferRef = std::ptr::null_mut(); // Create a memory buffer from the bitcode file diff --git a/src/backend/llvm/codegen.rs b/src/backend/llvm/codegen.rs index 2710135..31846ca 100644 --- a/src/backend/llvm/codegen.rs +++ b/src/backend/llvm/codegen.rs @@ -8,7 +8,7 @@ use llvm_sys::prelude::*; use std::collections::{BTreeMap, HashMap}; -use std::ffi::CString; +use std::ffi::{CString, c_char}; use crate::backend::BackendError; use crate::ir::{ @@ -163,14 +163,14 @@ impl LlvmCodegen { ); llvm_sys::core::LLVMSetSection( used_global, - b"llvm.metadata\0".as_ptr() as *const i8, + b"llvm.metadata\0".as_ptr() as *const c_char, ); } // Create entry block and call ot_main let entry = llvm_sys::core::LLVMAppendBasicBlock( c_main, - b"entry\0".as_ptr() as *const i8, + b"entry\0".as_ptr() as *const c_char, ); let builder = llvm_sys::core::LLVMCreateBuilderInContext(self.context); llvm_sys::core::LLVMPositionBuilderAtEnd(builder, entry); @@ -182,7 +182,7 @@ impl LlvmCodegen { ot_main, std::ptr::null_mut(), 0, - b"call\0".as_ptr() as *const i8, + b"call\0".as_ptr() as *const c_char, ); // If there's a user-defined main() function, call it @@ -207,7 +207,7 @@ impl LlvmCodegen { user_main_func, std::ptr::null_mut(), 0, - b"user_main_call\0".as_ptr() as *const i8, + b"user_main_call\0".as_ptr() as *const c_char, ); } } @@ -334,7 +334,7 @@ impl LlvmCodegen { let block_name = format!("bb{}\0", block.id.0); let llvm_block = llvm_sys::core::LLVMAppendBasicBlock( func_val, - block_name.as_ptr() as *const i8, + block_name.as_ptr() as *const c_char, ); if llvm_block.is_null() { llvm_sys::core::LLVMDisposeBuilder(builder); @@ -356,7 +356,7 @@ impl LlvmCodegen { let alloca = llvm_sys::core::LLVMBuildAlloca( ctx.builder, i64_ty, - b"local\0".as_ptr() as *const i8, + b"local\0".as_ptr() as *const c_char, ); ctx.locals.push(alloca); } @@ -476,7 +476,7 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, func_ptr, i64_ty, - b"func_addr\0".as_ptr() as *const i8, + b"func_addr\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, ptr_as_int); return Ok(()); @@ -496,26 +496,26 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let result_fp = llvm_sys::core::LLVMBuildFAdd( ctx.builder, fa, fb, - b"add\0".as_ptr() as *const i8, + b"add\0".as_ptr() as *const c_char, ); // Bitcast back to i64 (NaN-boxed) let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -528,25 +528,25 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let result_fp = llvm_sys::core::LLVMBuildFSub( ctx.builder, fa, fb, - b"sub\0".as_ptr() as *const i8, + b"sub\0".as_ptr() as *const c_char, ); let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -559,25 +559,25 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let result_fp = llvm_sys::core::LLVMBuildFMul( ctx.builder, fa, fb, - b"mul\0".as_ptr() as *const i8, + b"mul\0".as_ptr() as *const c_char, ); let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -590,25 +590,25 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let result_fp = llvm_sys::core::LLVMBuildFDiv( ctx.builder, fa, fb, - b"div\0".as_ptr() as *const i8, + b"div\0".as_ptr() as *const c_char, ); let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -621,25 +621,25 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let result_fp = llvm_sys::core::LLVMBuildFRem( ctx.builder, fa, fb, - b"mod\0".as_ptr() as *const i8, + b"mod\0".as_ptr() as *const c_char, ); let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -651,20 +651,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let zero = llvm_sys::core::LLVMConstReal(double_ty, 0.0); let result_fp = llvm_sys::core::LLVMBuildFSub( ctx.builder, zero, fa, - b"neg\0".as_ptr() as *const i8, + b"neg\0".as_ptr() as *const c_char, ); let result = llvm_sys::core::LLVMBuildBitCast( ctx.builder, result_fp, i64_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, result); } @@ -676,7 +676,7 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, i64_ty, alloca, - b"load\0".as_ptr() as *const i8, + b"load\0".as_ptr() as *const c_char, ); ctx.values.insert(*dst, val); } else { @@ -699,20 +699,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealOLT, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -725,20 +725,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealOLE, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -751,20 +751,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealOGT, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -777,20 +777,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealOGE, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -805,20 +805,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealOEQ, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -832,20 +832,20 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let fb = llvm_sys::core::LLVMBuildBitCast( ctx.builder, vb, double_ty, - b"bitcast\0".as_ptr() as *const i8, + b"bitcast\0".as_ptr() as *const c_char, ); let cmp = llvm_sys::core::LLVMBuildFCmp( ctx.builder, llvm_sys::LLVMRealPredicate::LLVMRealONE, fa, fb, - b"cmp\0".as_ptr() as *const i8, + b"cmp\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, cmp)?; ctx.values.insert(*dst, result); @@ -861,7 +861,7 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba ctx.builder, va, one, - b"mask\0".as_ptr() as *const i8, + b"mask\0".as_ptr() as *const c_char, ); // Check if it's zero (falsy) let is_falsy = llvm_sys::core::LLVMBuildICmp( @@ -869,7 +869,7 @@ unsafe fn translate_op(ctx: &mut TranslationContext, op: &IrOp) -> Result<(), Ba llvm_sys::LLVMIntPredicate::LLVMIntEQ, masked, llvm_sys::core::LLVMConstInt(i64_ty, 0, 0), - b"is_falsy\0".as_ptr() as *const i8, + b"is_falsy\0".as_ptr() as *const c_char, ); let result = bool_to_ot_value(ctx, is_falsy)?; ctx.values.insert(*dst, result); @@ -1018,14 +1018,14 @@ unsafe fn translate_terminator( ctx.builder, cond_val, one, - b"mask\0".as_ptr() as *const i8, + b"mask\0".as_ptr() as *const c_char, ); let bool_val = llvm_sys::core::LLVMBuildICmp( ctx.builder, llvm_sys::LLVMIntPredicate::LLVMIntNE, masked, llvm_sys::core::LLVMConstInt(i64_ty, 0, 0), - b"bool\0".as_ptr() as *const i8, + b"bool\0".as_ptr() as *const c_char, ); let true_block = ctx.blocks[true_block]; let false_block = ctx.blocks[false_block]; @@ -1128,10 +1128,14 @@ unsafe fn bool_to_ot_value( ctx.builder, b, llvm_sys::core::LLVMInt64TypeInContext(ctx.context), - b"zext\0".as_ptr() as *const i8, + b"zext\0".as_ptr() as *const c_char, + ); + let result = llvm_sys::core::LLVMBuildOr( + ctx.builder, + base, + b_i64, + b"bool\0".as_ptr() as *const c_char, ); - let result = - llvm_sys::core::LLVMBuildOr(ctx.builder, base, b_i64, b"bool\0".as_ptr() as *const i8); Ok(result) } } @@ -1197,7 +1201,7 @@ unsafe fn call_indirect( ctx.builder, func_ptr, func_ptr_ty, - b"callee\0".as_ptr() as *const i8, + b"callee\0".as_ptr() as *const c_char, ); // Build the call with actual arguments diff --git a/src/backend/llvm/mod.rs b/src/backend/llvm/mod.rs index db69526..ca99b62 100644 --- a/src/backend/llvm/mod.rs +++ b/src/backend/llvm/mod.rs @@ -21,6 +21,7 @@ pub mod types; pub use codegen::LlvmCodegen; +use std::ffi::c_char; use std::path::Path; use crate::backend::{BackendConfig, BackendError}; @@ -147,7 +148,7 @@ pub fn compile_to_llvm_ir_file( let output_path_c = std::ffi::CString::new(output_path.to_string_lossy().as_ref()) .map_err(|e| BackendError::AotError(format!("Invalid output path: {}", e)))?; - let mut error_msg: *mut i8 = std::ptr::null_mut(); + let mut error_msg: *mut c_char = std::ptr::null_mut(); let result = unsafe { llvm_sys::core::LLVMPrintModuleToFile( codegen.module, diff --git a/src/backend/llvm/object.rs b/src/backend/llvm/object.rs index cf7ec13..ea8322a 100644 --- a/src/backend/llvm/object.rs +++ b/src/backend/llvm/object.rs @@ -5,7 +5,7 @@ use llvm_sys::analysis::*; use llvm_sys::prelude::*; use llvm_sys::target_machine::*; -use std::ffi::{CStr, CString}; +use std::ffi::{CStr, CString, c_char}; use std::path::Path; use std::ptr; @@ -41,7 +41,7 @@ pub unsafe fn create_target_machine( let triple_cstr = CString::new(target_triple).unwrap(); let mut target: LLVMTargetRef = ptr::null_mut(); - let mut error_msg: *mut i8 = ptr::null_mut(); + let mut error_msg: *mut c_char = ptr::null_mut(); if llvm_sys::target_machine::LLVMGetTargetFromTriple( triple_cstr.as_ptr(), @@ -139,12 +139,12 @@ pub unsafe fn emit_object_file( // Emit object file let path_cstr = CString::new(path.to_str().unwrap()).unwrap(); - let mut error_msg: *mut i8 = ptr::null_mut(); + let mut error_msg: *mut c_char = ptr::null_mut(); let result = llvm_sys::target_machine::LLVMTargetMachineEmitToFile( target_machine, module, - path_cstr.as_ptr() as *mut i8, + path_cstr.as_ptr() as *mut c_char, LLVMCodeGenFileType::LLVMObjectFile, &mut error_msg, );