aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-16 14:09:08 +0000
committer_ov4 <ov4@ov4.org>2026-10-16 14:09:08 +0000
commit3001dfeb97adebf0cb326d9aa664098e0aced5b5 (patch)
treee29122d246e8805aa54267b05c0f6071d3400e32
parente44bdc6a2a0cf624b08046ecc7e5c5d5d9d2d66c (diff)
fix(jit): always emit DWARF unwind frames on macOS
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
-rw-r--r--AGENTS/ARCH.md3
-rw-r--r--tools/driver/EmbeddedRunner.cc7
2 files changed, 10 insertions, 0 deletions
diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md
index 04edd24..58338f3 100644
--- a/AGENTS/ARCH.md
+++ b/AGENTS/ARCH.md
@@ -115,6 +115,9 @@ Driver behavior (`tools/driver/main.cc`):
The engine owns a clone of CodeGen's module; CodeGen retains the context and
must outlive the engine. Static C++ exception ABI symbols are explicitly
registered for JIT lookup; MCJIT registers the generated unwind frames.
+ On macOS the JIT explicitly emits DWARF unwind frames even when compact
+ unwind records would suffice for native linking; MCJIT does not register
+ compact unwind records. macOS execution still needs platform verification.
The host target is initialized for native output or embedded execution.
No external runner or PATH lookup is used; `-r` alone runs in memory.
- In NONE mode, `-r` returns 1 before compiling or writing output; native and IR
diff --git a/tools/driver/EmbeddedRunner.cc b/tools/driver/EmbeddedRunner.cc
index cad1f84..05890ac 100644
--- a/tools/driver/EmbeddedRunner.cc
+++ b/tools/driver/EmbeddedRunner.cc
@@ -7,6 +7,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
+#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <cstdio>
#include <cstdlib>
@@ -66,6 +67,12 @@ int runEmbedded(const cps::CodeGen &CG) {
llvm::EngineBuilder Builder(std::move(Module));
Builder.setEngineKind(llvm::EngineKind::JIT);
Builder.setErrorStr(&Error);
+#ifdef __APPLE__
+ // MCJIT registers DWARF frames, not Darwin's compact unwind records.
+ llvm::TargetOptions Options;
+ Options.MCOptions.EmitDwarfUnwind = llvm::EmitDwarfUnwindType::Always;
+ Builder.setTargetOptions(Options);
+#endif
Builder.setMCJITMemoryManager(std::make_unique<llvm::SectionMemoryManager>());
std::unique_ptr<llvm::ExecutionEngine> Engine(Builder.create());
if (!Engine) {