Skip to content

Commit 6979449

Browse files
committed
Temporary fatch to be fixed for beta release
1 parent a2508e2 commit 6979449

File tree

3 files changed

+461
-457
lines changed

3 files changed

+461
-457
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ members = [
3131
"./jit",
3232
"./logging",
3333
]
34+
35+
[build-dependencies]
36+
pkg-config = "0.3"

jit/src/core.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct ExecutionEngine {
1616
impl ExecutionEngine {
1717
/// Constructs a new `ExecutionEngine`.
1818
///
19-
/// This method initializes a new LLVM context and module, configures the general target,
19+
/// This method initializes a new LLVM ExecutionEngine, configures the general target,
2020
/// and optionally sets up a logger for debugging information based on the `debug_info` parameter.
2121
///
2222
/// # Parameters
@@ -27,12 +27,13 @@ impl ExecutionEngine {
2727
/// A new instance of `ExecutionEngine`.
2828
pub fn new(module: Arc<RwLock<SafeLLVMPointer>>, debug_info: bool) -> Self {
2929
GeneralTargetConfigurator.configure();
30-
30+
3131
let mut engine_ref: execution_engine::LLVMExecutionEngineRef = std::ptr::null_mut();
3232
let mut out_error: *mut c_char = std::ptr::null_mut();
3333
let engine_ptr = &mut engine_ref;
3434

35-
module.read().unwrap().read(LLVMRefType::Module, |module_ref| {
35+
let module_rw_lock = module.try_read().expect("Failed to read module");
36+
module_rw_lock.write(LLVMRefType::Module, |module_ref| {
3637
if let LLVMRef::Module(module_ptr) = module_ref {
3738
unsafe {
3839
if execution_engine::LLVMCreateExecutionEngineForModule(engine_ptr, *module_ptr, &mut out_error) != 0 {
@@ -95,8 +96,8 @@ impl ExecutionEngine {
9596
ReturnType: 'static,
9697
ArgType: Any + Send + Sync,
9798
{
98-
let engine_lock = self.engine.read().map_err(|e| format!("Failed to obtain read lock on engine: {}", e))?;
99-
let result = engine_lock.read(LLVMRefType::ExecutionEngine, |engine_ref| {
99+
let engine_lock = self.engine.try_read().map_err(|e| format!("Failed to obtain read lock on engine: {}", e))?;
100+
let result = engine_lock.write(LLVMRefType::ExecutionEngine, |engine_ref| {
100101
if let LLVMRef::ExecutionEngine(engine_ptr) = engine_ref {
101102
let function_name_c = CString::new(function_name).map_err(|_| "Failed to create CString for function name.")?;
102103
let function_address = unsafe { execution_engine::LLVMGetFunctionAddress(*engine_ptr, function_name_c.as_ptr()) };

0 commit comments

Comments
 (0)