Skip to content

Commit

Permalink
Add missing part
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvassilev committed May 3, 2024
1 parent 360d6e5 commit 6753ee1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ int find_dynamic_unwind_sections(uintptr_t addr,
typedef int (*unw_find_dynamic_unwind_sections)(
uintptr_t addr, struct unw_dynamic_unwind_sections* info);

void removeFindDynamicUnwindSections() {
if (auto* unw_remove_find_dynamic_unwind_sections = (int (*)(
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
dlsym(RTLD_DEFAULT, "__unw_remove_find_dynamic_unwind_sections"))
unw_remove_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
}

#endif // __APPLE__

namespace Cpp {
Expand All @@ -109,7 +102,10 @@ namespace Cpp {
struct InterpDeleter {
~InterpDeleter() {
#ifdef __APPLE__
removeFindDynamicUnwindSections();
if (auto* unw_remove_find_dynamic_unwind_sections = (int (*)(
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
dlsym(RTLD_DEFAULT, "__unw_remove_find_dynamic_unwind_sections"))
unw_remove_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
#endif
sInterpreter.release();
}
Expand Down Expand Up @@ -2652,6 +2648,14 @@ namespace Cpp {
// FIXME: Enable this assert once we figure out how to fix the multiple
// calls to CreateInterpreter.
//assert(!sInterpreter && "Interpreter already set.");
#ifdef __APPLE__
// Add a handler to support exceptions from interpreted code.
// See llvm/llvm-project#49036
if (auto* unw_add_find_dynamic_unwind_sections = (int (*)(
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
dlsym(RTLD_DEFAULT, "__unw_add_find_dynamic_unwind_sections"))
unw_add_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
#endif // __APPLE__
sInterpreter.reset(I);
return I;
}
Expand Down

0 comments on commit 6753ee1

Please sign in to comment.