Skip to content

Cli cleanup#46

Merged
cs01 merged 20 commits intomainfrom
cli-cleanup
Feb 23, 2026
Merged

Cli cleanup#46
cs01 merged 20 commits intomainfrom
cli-cleanup

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Feb 23, 2026

Summary

CLI cleanup: remove musl support, fix Mac issues, unify argument parsing, and fix cross-compilation.

Musl removal

  • Remove all musl/Alpine support from target resolution, compiler linking, SDK scripts, and CI
  • Remove build-linux-musl CI job (was Alpine-based)
  • Remove detect_libc() from installer — was incorrectly detecting musl on Ubuntu
  • Simplify LibC type to just "gnu" | "system"

Installer improvements

  • Fix platform detection (no longer misidentifies Ubuntu as musl)
  • Add export PATH after install so chad is available immediately without opening a new shell

CLI argument parsing

  • Migrate chad-node.ts from manual for-loop arg parsing to ArgumentParser (same parser the native binary uses)
  • Copy argparse.ts into src/ so tsc can compile it (rootDir restriction prevents importing from lib/)
  • Wire up the --verbose flag in the native binary (was declared but never connected to setVerbose)

Cross-compilation

  • Restrict --target to linux-x64 for build/run commands (the only supported cross-compile target)
  • chad ir can still target any platform since it only emits LLVM IR
  • Update help text in both CLI entry points
  • Package glibc sysroot in target SDK (CRT objects, system libraries, GCC support files)
  • Handle Ubuntu's .a linker scripts that contain absolute paths — resolve referenced archives and rewrite scripts with local filenames
  • Force -static when cross-compiling to avoid .so linker script relocation issues
  • Add explicit -L<sysroot>/usr/lib to bypass multiarch path detection

Fix chad run on Mac (native binary)

  • Root cause: cs_execSync uses popen() which captures stdout into a buffer. When the native chad run called child_process.execSync(cmd), the user program's output was captured and silently discarded
  • Fix: add cs_exec_passthrough() in child-process-bridge.c using system() which inherits stdin/stdout/stderr
  • Wire it through codegen (calls.ts, llvm-declarations.ts) and use it in chad-native.ts

Fix chad watch on Mac (native binary)

  • Root cause: kqueue only watched directories with NOTE_WRITE, but in-place file edits don't trigger NOTE_WRITE on the directory fd (only directory entry changes like create/delete/rename do)
  • Fix: watch both directories (for new file creation) AND individual source files (with NOTE_WRITE | NOTE_ATTRIB | NOTE_DELETE | NOTE_RENAME)
  • Handle the "write-to-temp-then-rename" editor pattern by detecting NOTE_DELETE/NOTE_RENAME and re-opening stale file descriptors

CI

  • Remove build-linux-musl job and all references to it
  • Add hello.ts creation step before cross-compile test (file doesn't exist in repo)
  • Cherry-pick e2e bridge linking tests: JSON, regex, child_process, hackernews smoke tests in test-artifact job
  • Add lib/ artifact verification step

Test plan

  • All unit tests pass (329 pass, 1 pre-existing network failure from missing multipart-bridge.o)

@cs01 cs01 merged commit ee3d51f into main Feb 23, 2026
12 checks passed
@cs01 cs01 deleted the cli-cleanup branch February 23, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant