From 3001dfeb97adebf0cb326d9aa664098e0aced5b5 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 16 Oct 2026 14:09:08 +0000 Subject: fix(jit): always emit DWARF unwind frames on macOS Co-Authored-By: Claude Fable 5.1 --- AGENTS/ARCH.md | 3 +++ tools/driver/EmbeddedRunner.cc | 7 +++++++ 2 files changed, 10 insertions(+) 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 #include @@ -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()); std::unique_ptr Engine(Builder.create()); if (!Engine) { -- cgit v1.3.1-4-g156e