menios
menios copied to clipboard
Port TCC (Tiny C Compiler) to meniOS
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)
- Download TCC source code
- Build TCC with meniOS cross-compiler
- Port TCC runtime/startup code
- Basic integration testing
Phase 2: Testing & Validation (2-3 weeks)
- Test compilation of simple C programs
- Verify crash handlers work (sigaction test)
- Verify float parsing works (compile code with floats)
- Test with increasingly complex programs
- Integration with binutils (#191)
Phase 3: Polish & Documentation (1 week)
- Test suite execution
- Real-world program compilation
- Performance benchmarking
- 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
- Start TCC port implementation
- Test crash handler support
- Test float literal compilation
- Coordinate with binutils (#191) for integration