ERR/E3.0 (slice 3d): --emit-obj + macOS lldb stepping verified

`sx build --emit-obj` keeps the DWARF-bearing object so a debugger can
step the binary, completing the deep-debug half of the trace story.

- --emit-obj flag + TargetConfig.emit_obj. Implies -O0 (DWARF only
  emits at opt none/less); keeps the object at its link-time path
  .sx-tmp/main.o so the binary's debug map resolves to it; skips the
  Level-1 binary cache; reports the object path. macOS resolves via the
  debug map -> .o; Linux carries DWARF in the binary. Build-flow only,
  no runtime/codegen change.
- tests/debug_stepping_smoke.sh (3e rung 1; macOS, lldb, not in
  run_examples): builds with --emit-obj, drives an lldb file:line
  breakpoint, asserts resolution + a source-mapped backtrace. Passing —
  proves the slice 1-2 DWARF drives real source-level stepping.

(Also normalizes the 253 .exit trailing newline from the 3c --update.)
Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
agra
2026-06-01 15:55:05 +03:00
parent 178449b548
commit 4cd641c946
5 changed files with 92 additions and 13 deletions

View File

@@ -71,6 +71,13 @@ pub const TargetConfig = struct {
/// `chdir` shouldn't run in JIT mode because it would mutate the host
/// sx process's CWD.
is_aot: bool = false,
/// Keep the DWARF-bearing object file after linking (`--emit-obj`) so a
/// debugger can step the binary: macOS resolves via the debug map → the
/// `.o`; Linux carries DWARF in the binary directly. Implies `-O0` unless
/// `--opt` is given explicitly (DWARF is only emitted at opt none/less).
/// The object is kept at `.sx-tmp/main.o` (its link-time path, so the
/// debug map resolves when lldb is run from the project root).
emit_obj: bool = false,
pub const OptLevel = enum {
none,