Skip to content

Commit

Permalink
fix symbol not found on llvm>17
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Nov 26, 2023
1 parent 91279f9 commit 36422ac
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
7 changes: 7 additions & 0 deletions luisa_compute/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate self as luisa_compute;
use std::any::Any;
use std::backtrace::Backtrace;
use std::path::Path;
use std::ptr::null;
use std::sync::Arc;

pub mod lang;
Expand Down Expand Up @@ -117,6 +118,12 @@ impl Context {
/// if the current_exe() is in the same directory as libluisa-*, then
/// passing current_exe() is enough
pub fn new(lib_path: impl AsRef<Path>) -> Self {
// Thank you, llvm.
#[cfg(target_os = "linux")]
unsafe {
luisa_compute_sys::llvm_orc_deregisterEHFrameSectionWrapper(null(), 0);
luisa_compute_sys::llvm_orc_registerEHFrameSectionWrapper(null(), 0);
}
let mut lib_path = lib_path.as_ref().to_path_buf();
lib_path = lib_path.canonicalize().unwrap();
if lib_path.is_file() {
Expand Down
3 changes: 3 additions & 0 deletions luisa_compute_sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ metal = []
dx = []
oidn = []


[lib]
crate-type = ["dylib"]
47 changes: 47 additions & 0 deletions luisa_compute_sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
use std::{ffi::c_char, ptr::null};
// union CWrapperFunctionResultDataUnion {
// char *ValuePtr;
// char Value[sizeof(ValuePtr)];
// };

// typedef struct {
// CWrapperFunctionResultDataUnion Data;
// size_t Size;
// } CWrapperFunctionResult;
#[allow(non_snake_case)]
#[repr(C)]
pub union CWrapperFunctionResultDataUnion {
pub ValuePtr: *const c_char,
pub Value: [c_char; 8],
}
#[allow(non_snake_case)]
#[repr(C)]
pub struct CWrapperFunctionResult {
pub Data: CWrapperFunctionResultDataUnion,
pub Size: usize,
}

#[no_mangle]
#[inline(never)]
pub unsafe extern "C" fn llvm_orc_registerEHFrameSectionWrapper(
_data: *const c_char,
_size: u64,
) -> CWrapperFunctionResult {
let result = CWrapperFunctionResult {
Data: CWrapperFunctionResultDataUnion { ValuePtr: null() },
Size: 0,
};
result
}

#[no_mangle]
#[inline(never)]
pub unsafe extern "C" fn llvm_orc_deregisterEHFrameSectionWrapper(
_data: *const c_char,
_size: u64,
) -> CWrapperFunctionResult {
let result = CWrapperFunctionResult {
Data: CWrapperFunctionResultDataUnion { ValuePtr: null() },
Size: 0,
};
result
}

0 comments on commit 36422ac

Please sign in to comment.