menios icon indicating copy to clipboard operation
menios copied to clipboard

Port TCC (Tiny C Compiler) to meniOS

Open pbalduino opened this issue 4 months ago • 1 comments

Context

Port TCC (Tiny C Compiler) as stepping stone to native compilation. Smaller and simpler than GCC.

UNBLOCKED - Ready to Implement!

ALL BLOCKERS ARE COMPLETE!

Both critical libc features that TCC requires are now implemented:

1. Signal Handling - COMPLETE

  • sigaction() with full flag support
  • sigemptyset(), sigfillset(), signal set operations
  • SA_SIGINFO, SA_RESTART, SA_RESETHAND flags
  • siginfo_t structure

Status: #337 - COMPLETE

2. Floating-Point Parsing - COMPLETE

  • strtod(), strtof(), strtold() - Parse string to float
  • ldexp(), frexp(), modf() - Float manipulation
  • Scientific notation support (e.g., "1.23e-4")
  • Hex float support (e.g., "0x1.8p3")

Status: #338 - COMPLETE

All Dependencies Complete

  • #29 - Cross-compiler toolchain - COMPLETE
  • #193 - Minimal libc functional - COMPLETE
  • #208 - Pipes (TCC uses pipes for preprocessor) - COMPLETE
  • #189 - FAT32 write support (save output) - COMPLETE
  • #205 - I/O scheduler (performance) - COMPLETE
  • #253 - Buddy allocator - COMPLETE
  • #337 - Signal handling API - COMPLETE
  • #338 - Float parsing - COMPLETE

Non-Blocking (TCC Doesn't Need)

These libc gaps exist but TCC doesn't use them:

  • termios - Not used by TCC
  • pthreads - TCC is single-threaded
  • networking - Not needed for compilation
  • locales - Not used by TCC
  • wide chars - Not used by TCC
  • poll/select - Not used by TCC

Requirements

  • Port TCC to meniOS userland
  • Support compilation to ELF
  • Integration with binutils (as, ld) - see #191
  • Basic optimization support

Acceptance Criteria

  • [ ] TCC compiles and runs on meniOS
  • [ ] Can compile simple C programs
  • [ ] Generated binaries execute correctly
  • [ ] Crash handlers work properly (sigaction)
  • [ ] Floating-point literals parse correctly (strtod/ldexp)

Implementation Plan

Phase 1: Initial Port (2-3 weeks)

  1. Download TCC source code
  2. Build TCC with meniOS cross-compiler
  3. Port TCC runtime/startup code
  4. Basic integration testing

Phase 2: Testing & Validation (2-3 weeks)

  1. Test compilation of simple C programs
  2. Verify crash handlers work (sigaction test)
  3. Verify float parsing works (compile code with floats)
  4. Test with increasingly complex programs
  5. Integration with binutils (#191)

Phase 3: Polish & Documentation (1 week)

  1. Test suite execution
  2. Real-world program compilation
  3. Performance benchmarking
  4. Documentation updates

Total Estimated Time: 4-6 weeks

Priority

CRITICAL - Ready to start immediately!

Critical path to native compilation and GCC milestone.

Current Status

READY TO IMPLEMENT

All dependencies are satisfied. TCC port can begin now.

Integration with binutils

#191 (binutils port) is also ready and can be developed in parallel. Having both TCC and binutils will enable:

  • Native compilation of C programs
  • Assembling and linking on meniOS
  • Foundation for eventual GCC port

Related Issues

  • #191 - binutils port (parallel track, also ready)
  • #337 - Signal handling API - COMPLETE
  • #338 - Float parsing - COMPLETE
  • #339 - Thread-safe libc (future enhancement)
  • #340 - Extended stdio (nice to have)

Next Steps

  1. Start TCC port implementation
  2. Test crash handler support
  3. Test float literal compilation
  4. Coordinate with binutils (#191) for integration

pbalduino avatar Oct 05 '25 03:10 pbalduino