Skip to content

Commit dbd2388

Browse files
aaronj0vgvassilev
authored andcommitted
Add llvm libunwind callback to suppress exceptions on apple silicon
See llvm/llvm-project#49036
1 parent d6471b9 commit dbd2388

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/CppInterOp/Compatibility.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ static inline char* GetEnv(const char* Var_Name) {
7171
#include "llvm/ADT/SmallString.h"
7272
#include "llvm/ADT/StringRef.h"
7373
#include "llvm/ADT/Twine.h"
74+
#include "llvm/BinaryFormat/MachO.h"
7475
#include "llvm/Config/llvm-config.h"
7576
#include "llvm/ExecutionEngine/JITSymbol.h"
7677
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
78+
#include "llvm/Object/MachO.h"
7779
#include "llvm/Support/Casting.h"
7880
#include "llvm/Support/Path.h"
7981

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,25 @@ if (llvm::sys::RunningOnValgrind())
311311
delete ExtInterp;
312312
#endif
313313
}
314+
315+
TEST(InterpreterTest, InterpreterExceptions) {
316+
Cpp::CreateInterpreter();
317+
EXPECT_TRUE(Cpp::Declare("int f() { throw 1; return 2; }") == 0);
318+
EXPECT_TRUE(
319+
Cpp::Process(
320+
"int ex() { try { f(); return 0; } catch(...){return 1;} }") == 0);
321+
EXPECT_EQ(Cpp::Evaluate("ex()"), 1)
322+
<< "Failed to catch exceptions in interpreter";
323+
}
324+
325+
TEST(InterpreterTest, InterpreterExceptionsCompiledCode) {
326+
Cpp::CreateInterpreter();
327+
bool caught = false;
328+
try {
329+
EXPECT_TRUE(Cpp::Declare("int f() { throw 1; return 2; }") == 0);
330+
EXPECT_TRUE(Cpp::Process("int res = f();") == 0);
331+
} catch (...) {
332+
caught = true;
333+
}
334+
EXPECT_TRUE(caught) << "Unable to catch exception coming from interpreter";
335+
}

0 commit comments

Comments
 (0)