Skip to content

build: Windows support — build system, stack safety, heap allocation #181

@JF10R

Description

@JF10R

Problem

codedb does not compile or run on Windows. The build system, stack allocation, and heap allocation strategies are Linux/macOS-only:

  • Default Windows stack is 1MB vs Linux 8MB — LLVM merges all command branch frames into one ~128MB frame, causing STATUS_STACK_OVERFLOW
  • EventQueue stores 4096 × ~1KB FsEvent inline (~4MB on stack) — exceeds Windows stack
  • Frequency table working buffers ([256][256]u64 = 512KB + [256][256]u16 = 128KB) are stack-allocated
  • std.fs.max_path_bytes is 32KB on Windows vs 4KB on POSIX — path buffers blow the stack when multiplied across structs

Expected Behavior

zig build -Dtarget=x86_64-windows cross-compiles successfully. On Windows, codedb <root> tree runs without stack overflow.

Scope

  • build.zig: set exe.stack_size = 8MB for Windows targets
  • src/compat.zig: add path_buf_size constant (1024 on Windows, max_path_bytes elsewhere)
  • src/main.zig: noinline trampoline to prevent LLVM frame merging; fix double scan_thread.join() (UB on all platforms)
  • src/watcher.zig: heap-allocate EventQueue events array via page_allocator; use path_buf_size for FsEvent.path_buf
  • src/index.zig: heap-allocate frequency table counts and out buffers
  • src/tests.zig: update 3 EventQueue tests to use init()/deinit() API

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions