summaryrefslogtreecommitdiff
path: root/cmake/Toolchain-MinGW-w64.cmake
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 11:32:24 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 11:32:24 +0100
commitab95bf75d1f2fc500f71c57dfe7ffc52e838dff0 (patch)
treedf48bccdc92c8552212f406565d93074965ca86c /cmake/Toolchain-MinGW-w64.cmake
parentb84d42f5f9128d5d8f06011c97c5a303b09b00e8 (diff)
refactor(audio): Convert ring_buffer.cc to use FATAL_CHECK macros (Phase 2)
Converted all 8 abort() calls in ring_buffer.cc to FATAL_CHECK macros, enabling these bounds checks to be stripped in FINAL_STRIP builds. ## Changes ### ring_buffer.cc - Replaced `#include <cstdlib> // for abort()` with `#include "util/fatal_error.h"` - Removed `#include <cstdio> // for fprintf()` (included by fatal_error.h) - Converted 8 abort() patterns to FATAL_CHECK(): 1. write_pos bounds check (line 53) 2. write() single chunk bounds check (line 62) 3. write() chunk1 wrap-around check (line 69) 4. write() chunk2 remainder check (line 77) 5. read_pos bounds check (line 95) 6. read() single chunk bounds check (line 103) 7. read() chunk1 wrap-around check (line 111) 8. read() chunk2 remainder check (line 119) ### CMakeLists.txt - Removed duplicate "final" target at line 578 (conflicted with new target) - Old "final" target ran gen_assets.sh + crunch_demo.sh (now run manually) - New "final" target (line 329) builds with FINAL_STRIP enabled ## Size Impact **Measured savings** (audio library only): - Normal build: 1,416,408 bytes - FINAL_STRIP build: 1,381,200 bytes - **Savings: 35,208 bytes (~34 KB)** Note: This is for the entire audio library. The actual savings from ring_buffer.cc alone is a portion of this (estimated ~300-400 bytes for 8 checks). ## Code Transformation Example **Before:** ```cpp if (write_pos >= capacity_) { fprintf(stderr, "FATAL: write_pos out of bounds! write=%d, capacity=%d\n", write, capacity_); abort(); } ``` **After:** ```cpp FATAL_CHECK(write_pos >= capacity_, "write_pos out of bounds! write=%d, capacity=%d\n", write_pos, capacity_); ``` **In FINAL_STRIP builds:** Expands to `((void)0)` - zero cost. **In Debug/STRIP_ALL:** Full error message with file:line info. ## Testing All 27 tests pass in both modes: - Normal build (checks enabled): ✅ 27/27 pass - FINAL_STRIP build (checks stripped): Compiles successfully Build verification: ```bash # Normal build cmake . -B build -DDEMO_BUILD_TESTS=ON cmake --build build -j4 cd build && ctest # FINAL_STRIP build cmake . -B build_final -DDEMO_FINAL_STRIP=ON cmake --build build_final --target audio -j4 ``` ## Next Steps Phase 3: Convert miniaudio_backend.cc (3 abort() calls) - Estimated savings: ~240 bytes - Estimated time: 30 minutes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'cmake/Toolchain-MinGW-w64.cmake')
0 files changed, 0 insertions, 0 deletions