Skip to content

Commit 6753ee1

Browse files
committed
Add missing part
1 parent 360d6e5 commit 6753ee1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: lib/Interpreter/CppInterOp.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ int find_dynamic_unwind_sections(uintptr_t addr,
8585
typedef int (*unw_find_dynamic_unwind_sections)(
8686
uintptr_t addr, struct unw_dynamic_unwind_sections* info);
8787

88-
void removeFindDynamicUnwindSections() {
89-
if (auto* unw_remove_find_dynamic_unwind_sections = (int (*)(
90-
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
91-
dlsym(RTLD_DEFAULT, "__unw_remove_find_dynamic_unwind_sections"))
92-
unw_remove_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
93-
}
94-
9588
#endif // __APPLE__
9689

9790
namespace Cpp {
@@ -109,7 +102,10 @@ namespace Cpp {
109102
struct InterpDeleter {
110103
~InterpDeleter() {
111104
#ifdef __APPLE__
112-
removeFindDynamicUnwindSections();
105+
if (auto* unw_remove_find_dynamic_unwind_sections = (int (*)(
106+
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
107+
dlsym(RTLD_DEFAULT, "__unw_remove_find_dynamic_unwind_sections"))
108+
unw_remove_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
113109
#endif
114110
sInterpreter.release();
115111
}
@@ -2652,6 +2648,14 @@ namespace Cpp {
26522648
// FIXME: Enable this assert once we figure out how to fix the multiple
26532649
// calls to CreateInterpreter.
26542650
//assert(!sInterpreter && "Interpreter already set.");
2651+
#ifdef __APPLE__
2652+
// Add a handler to support exceptions from interpreted code.
2653+
// See llvm/llvm-project#49036
2654+
if (auto* unw_add_find_dynamic_unwind_sections = (int (*)(
2655+
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections))
2656+
dlsym(RTLD_DEFAULT, "__unw_add_find_dynamic_unwind_sections"))
2657+
unw_add_find_dynamic_unwind_sections(find_dynamic_unwind_sections);
2658+
#endif // __APPLE__
26552659
sInterpreter.reset(I);
26562660
return I;
26572661
}

0 commit comments

Comments
 (0)