perf(size): Release 关闭异步展开表 + 修正 Debug 构建参数

1. Release 专用 `-fno-asynchronous-unwind-tables`(新增 RELEASE_ONLY_OPT,只加在
   Release 的两条编译规则上)。-fno-exceptions 下绝大多数函数不再需要 .pdata/.xdata:
   实测 829,440 -> 793,088 B(-36,352);.pdata 30,420 -> 12,684、.xdata 28,904 -> 10,156。
   Release 不再生成可靠的栈回溯(崩溃诊断);Debug 保留完整展开表。

2. 修正真实缺陷:Makefile 的 DEBUG_OPT = -O0 从未被使用 —— Debug 两条编译规则误用了
   $(RELEASE_OPT)(即 -Oz),且全程没有 -g,因此所谓 Debug 构建其实只是"不 strip 的
   Release"。现在 Debug 规则改用 $(DEBUG_OPT) -g,链接也加 -g。
   代价:Debug 产物 1,734,578 -> 5,992,064 B(真实 -O0 -g,属预期)。

release(全量)790KB 零警告;debug(全量 -O0 -g)零警告。
This commit is contained in:
DeepSeek-V4.1-Flash committed 2026-11-04 02:52:13 +08:00
1 parent 5de3763e72
commit 94fc1c45da
2 files changed
+41 -5

No files matched your search

+26
View File
@@ -28,3 +28,29 @@
## 节点记录
(下面按完成顺序追加)
### P1 移除 `dynamic_cast` + 关闭 RTTI —— ✅ 完成(提交 `5de3763`)
**改动**
1. `Toolbar::BuildBoxes` 里唯一的 `dynamic_cast` 是**多余强转**(`Button::widget` 本来就是
`UiButtonWidget*`)。改为直接遍历 `m_buttons`(与 `m_root->Children()` 同源同序)。
2. 仅关 RTTI **不够**:`cp-demangle.o` 仍在链接里。真凶是 libstdc++ 的 `vterminate.o`
(引用 `__cxa_demangle`),它被 `eh_terminate.o` 的 `std::terminate` 拉入。
⇒ 在 `Utilities/Src/MemProbe.cpp` 里**自行定义** `__gnu_cxx::__verbose_terminate_handler()`,
归档成员 `vterminate.o` 不再被拉入,demangler 整体消失。
应用启动后本来就会 `std::set_terminate` 换成自己的处理函数,行为等效。
3. `Makefile` 新增 `NO_RTTI=1`(默认开)→ `CXXFLAGS += -fno-rtti`。
**实测**
| 指标 | 改前 | 改后 | 差 |
| --- | --- | --- | --- |
| Release | 890,880 B | **829,440 B** | **−61,440 B** |
| `.text` | 753,136 B | 703,616 B | −49,520 B |
| `.rdata` | 36,936 B | 26,616 B | −10,320 B |
| Debug | 1,801,617 B | 1,734,578 B | −67,039 B |
**验证**:release + debug **全量重建**(删 `*.o`/`*.d`)零 error 零 warning;
map 中 `cp-demangle.o` 已无 `.text` 段分配。