diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-07 11:24:56 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-07 11:24:56 +0100 |
| commit | b84d42f5f9128d5d8f06011c97c5a303b09b00e8 (patch) | |
| tree | 823b55ccf25ed3ecda2275a7998448a95a75a49a /doc/TRACKER.md | |
| parent | 13e41ff17ba91c07197e318b3235373aef845023 (diff) | |
feat(build): Add FINAL_STRIP mode for maximum size optimization
Implemented systematic fatal error checking infrastructure that can be
stripped for final builds. This addresses the need to remove all error
checking (abort() calls) from the production binary while maintaining
safety during development.
## New Infrastructure
### 1. CMake Option: DEMO_FINAL_STRIP
- New build mode for absolute minimum binary size
- Implies DEMO_STRIP_ALL (stricter superset)
- NOT included in DEMO_ALL_OPTIONS (manual opt-in only)
- Message printed during configuration
### 2. Header: src/util/fatal_error.h
- Systematic macro-based error checking
- Zero cost when FINAL_STRIP enabled (compiles to ((void)0))
- Full error messages with file:line info when enabled
- Five macros for different use cases:
- FATAL_CHECK(cond, msg, ...): Conditional checks (most common)
- FATAL_ERROR(msg, ...): Unconditional errors
- FATAL_UNREACHABLE(): Unreachable code markers
- FATAL_ASSERT(cond): Assertion-style invariants
- FATAL_CODE_BEGIN/END: Complex validation blocks
### 3. CMake Target: make final
- Convenience target for triggering final build
- Reconfigures with FINAL_STRIP and rebuilds demo64k
- Only available when NOT in FINAL_STRIP mode (prevents recursion)
### 4. Script: scripts/build_final.sh
- Automated final build workflow
- Creates build_final/ directory
- Shows size comparison with STRIP_ALL build (if available)
- Comprehensive warnings about stripped error checking
## Build Mode Hierarchy
| Mode | Error Checks | Debug Features | Size Opt |
|-------------|--------------|----------------|----------|
| Debug | ✅ | ✅ | ❌ |
| STRIP_ALL | ✅ | ❌ | ✅ |
| FINAL_STRIP | ❌ | ❌ | ✅✅ |
## Design Decisions (All Agreed Upon)
1. **FILE:LINE Info**: ✅ Include (worth 200 bytes for debugging)
2. **ALL_OPTIONS**: ❌ Manual opt-in only (too dangerous for testing)
3. **FATAL_ASSERT**: ✅ Add macro (semantic clarity for invariants)
4. **Strip Hierarchy**: ✅ STRIP_ALL keeps checks, FINAL_STRIP removes all
5. **Naming**: ✅ FATAL_* prefix (clear intent, conventional)
## Size Impact
Current: 10 abort() calls in production code
- ring_buffer.cc: 7 checks (~350 bytes)
- miniaudio_backend.cc: 3 checks (~240 bytes)
Estimated savings with FINAL_STRIP: ~500-600 bytes
## Documentation
Updated:
- doc/HOWTO.md: Added FINAL_STRIP build instructions
- doc/CONTRIBUTING.md: Added fatal error checking guidelines
- src/util/fatal_error.h: Comprehensive usage documentation
## Next Steps (Not in This Commit)
Phase 2: Convert ring_buffer.cc abort() calls to FATAL_CHECK()
Phase 3: Convert miniaudio_backend.cc abort() calls to FATAL_CHECK()
Phase 4: Systematic scan for remaining abort() calls
Phase 5: Verify size reduction with actual measurements
## Usage
# Convenience methods
make final # From normal build directory
./scripts/build_final.sh # Creates build_final/
# Manual
cmake -S . -B build_final -DDEMO_FINAL_STRIP=ON
cmake --build build_final
⚠️ WARNING: FINAL_STRIP builds have NO error checking.
Use ONLY for final release, never for development/testing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'doc/TRACKER.md')
0 files changed, 0 insertions, 0 deletions
