From 36422ac73f811738456da0ed562463e84f87ce96 Mon Sep 17 00:00:00 2001 From: Xiaochun Tong Date: Sun, 26 Nov 2023 13:55:24 -0500 Subject: [PATCH] fix symbol not found on llvm>17 --- luisa_compute/src/lib.rs | 7 +++++ luisa_compute_sys/Cargo.toml | 3 +++ luisa_compute_sys/LuisaCompute | 2 +- luisa_compute_sys/src/lib.rs | 47 ++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/luisa_compute/src/lib.rs b/luisa_compute/src/lib.rs index 851e3a08..193aa289 100644 --- a/luisa_compute/src/lib.rs +++ b/luisa_compute/src/lib.rs @@ -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; @@ -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) -> 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() { diff --git a/luisa_compute_sys/Cargo.toml b/luisa_compute_sys/Cargo.toml index 8e3d7619..2d0207b7 100644 --- a/luisa_compute_sys/Cargo.toml +++ b/luisa_compute_sys/Cargo.toml @@ -27,3 +27,6 @@ metal = [] dx = [] oidn = [] + +[lib] +crate-type = ["dylib"] diff --git a/luisa_compute_sys/LuisaCompute b/luisa_compute_sys/LuisaCompute index 778d80aa..5a3c8ed3 160000 --- a/luisa_compute_sys/LuisaCompute +++ b/luisa_compute_sys/LuisaCompute @@ -1 +1 @@ -Subproject commit 778d80aa418dfa760e7feb36f0b88e9da91b0baa +Subproject commit 5a3c8ed3b838f0991e434994371c894b84977820 diff --git a/luisa_compute_sys/src/lib.rs b/luisa_compute_sys/src/lib.rs index 8b137891..a104c387 100644 --- a/luisa_compute_sys/src/lib.rs +++ b/luisa_compute_sys/src/lib.rs @@ -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 +}