build: Fix undefined references

This commit is contained in:
WerWolv
2025-05-26 20:25:35 +02:00
parent b33cb07dc0
commit 1bc9277e3c
2 changed files with 12 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ if (NOT IMHEX_DISABLE_STACKTRACE)
}
" HAVE_STDCPPEXP)
if (HAVE_STDCPPEXP)
target_link_libraries(tracing PRIVATE stdc++exp)
target_link_libraries(tracing PUBLIC stdc++exp)
endif()
if (WIN32)
@@ -49,6 +49,7 @@ endif()
if (IMHEX_TRACE_EXCEPTIONS)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_link_options(tracing PUBLIC "-Wl,--wrap=__cxa_throw")
target_compile_definitions(tracing PRIVATE HEX_WRAP_CXA_THROW)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Not supported currently
endif()

View File

@@ -15,13 +15,16 @@ namespace hex::trace {
}
extern "C" {
#if defined(HEX_WRAP_CXA_THROW)
extern "C" {
[[noreturn]] void __real___cxa_throw(void* thrownException, void* type, void (*destructor)(void*));
[[noreturn]] void __wrap___cxa_throw(void* thrownException, void* type, void (*destructor)(void*)) {
hex::trace::s_lastExceptionStackTrace = hex::trace::getStackTrace();
__real___cxa_throw(thrownException, type, destructor);
}
[[noreturn]] void __real___cxa_throw(void* thrownException, void* type, void (*destructor)(void*));
[[noreturn]] void __wrap___cxa_throw(void* thrownException, void* type, void (*destructor)(void*)) {
hex::trace::s_lastExceptionStackTrace = hex::trace::getStackTrace();
__real___cxa_throw(thrownException, type, destructor);
}
}
#endif