fn main() {
let context = Context::create();
let memory = MemoryBuffer::create_from_file("./sum.ll".as_ref()).unwrap();
let module = context.create_module_from_ir(memory).unwrap();
let ee = module
.create_jit_execution_engine(OptimizationLevel::None)
.unwrap();
unsafe {
let fn_hello = ee.get_function::<unsafe extern "C" fn()>("hello").unwrap();
fn_hello.call();
}
}
I first use rustc --emit=llvm-ir /home/kould/rust-llvm-practises/helloworld/src/example/sum.rs to convert sum.rs to LLVM IR sum.ll, and then call the hello method after importing it as a Module
Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
Expected Behavior
displayed in terminal
hello world
LLVM Version (please complete the following information):
LLVM Version: 16.0.0
Inkwell Branch Used: inkwell = { version = "0.2.0", features = ["llvm16-0"] }
rustc: 1.69.0
Desktop (please complete the following information):
Describe the Bug after importing LLVM IR, a segmentation fault occurs when calling its internal method
To Reproduce sum.rs
main.rs
I first use
rustc --emit=llvm-ir /home/kould/rust-llvm-practises/helloworld/src/example/sum.rs
to convertsum.rs
to LLVM IRsum.ll
, and then call thehello
method after importing it as a ModuleExpected Behavior displayed in terminal
LLVM Version (please complete the following information):
Desktop (please complete the following information):
Additional Context