Skip to content

Comments

Argparse library improvements, cross-compilation support, and several compiler fixes.#9

Merged
cs01 merged 1 commit intomainfrom
argparse-improvements
Feb 19, 2026
Merged

Argparse library improvements, cross-compilation support, and several compiler fixes.#9
cs01 merged 1 commit intomainfrom
argparse-improvements

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Feb 19, 2026

Summary

Argparse library improvements, cross-compilation support, and several compiler fixes.

Argparse

  • Add subcommand support (parser.addSubcommand()) and migrate chad-native.ts CLI to use it
  • Add --key=value equals syntax for options
  • Add -- double-dash support to stop flag parsing
  • Simplify setFlagValue/setOptionValue to use direct arr[i] = value instead of rebuilding arrays

Cross-compilation

  • Add --target flag with short names (linux-x64, macos-arm64, etc.) and full LLVM triple support
  • Thread target triple through opt, llc, and clang invocations
  • Use target OS (not host) for platform-specific IR symbols and linker flags
  • Add --target-cpu flag and default CI to x86-64 to fix SIGILL on runners
  • Add cross-compile CI workflow that builds on Linux→macOS and macOS→Linux, then links and runs on the target

Compiler fixes

  • Enum values: getEnumMemberValue() was returning the loop index instead of the declared value — enum { OK = 200 } produced 0 instead of 200
  • Discriminated unions: Generalize type guard narrowing to work with any discriminant field, not just type. Enables patterns like if (shape.kind === "circle").
  • Union common fields: getUnionCommonFields was returning TS types instead of LLVM types, causing type mismatches

Other

  • Site and build fixes
  • Installer updates

Test plan

  • All 295 unit tests pass (including 4 new: enum values, 3 discriminated union variants)
  • Self-hosting verification passes (Stage 0 + Stage 1)
  • New argparse fixtures: subcommand, equals syntax, double-dash
  • New enum fixture: explicit values (200, 404, 500), auto-increment, mixed
  • New union fixtures: basic discriminant, function params, custom kind field

@cs01 cs01 merged commit 7482033 into main Feb 19, 2026
18 checks passed
@cs01 cs01 deleted the argparse-improvements branch February 19, 2026 05:43
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