Files
Anees Iqbal 514d7f13bc Build dev and test binaries with sync unwind tables
Linking metal2vulkan-validation's lib tests under --cfg m2v_gpu on the M3 Max printed, through
rustc's `linker_messages` lint, ld's "__eh_frame section too large (max 16MB) to encode dwarf
unwind offsets in compact unwind table, performance of exception handling might be affected".
The binary is 342.6 MB, its `__eh_frame` 24.3 MB: 472,841 DWARF FDEs, most of them functions
under 1 KiB (core and alloc generics instantiated in the workspace's crates). Nearly every FDE
holds epilogue rules (`DW_CFA_remember_state`, `DW_CFA_def_cfa`, `DW_CFA_restore_state`): rustc
emits async unwind tables by default, LLVM then describes each epilogue, and Mach-O's compact
unwind encoding has no form for those rules, so the function falls back to a DWARF FDE that the
compact table points to by a 24-bit offset. The plain build's binary (no cfg), the one macOS CI
links, holds 12.1 MB of them.

Unwinding in these builds starts only at calls (a panic, a backtrace; the lanes' fatal-signal
handler walks frame records), and sync unwind tables describe every call site. With
`-Zuse-sync-unwind=yes` the same binary holds 75,320 FDEs, 3.6 MB of `__eh_frame` (1.6 MB of
`__unwind_info` against 3.9), and is 319.4 MB, and ld prints nothing. The flag goes in
`[profile.dev]`'s profile rustflags, which `test` and `debugger` inherit and which add to
`RUSTFLAGS` (the lanes' `--cfg m2v_gpu`); release builds keep async tables.

CI's `-Dwarnings` cannot catch the warning: rustc notes that "the `linker_messages` lint ignores
`-D warnings`" (checked: the lib test built with `-D warnings` linked, exit 0, the warning a
warning), and macOS CI links no `--cfg m2v_gpu` binary (it runs clippy there).

Verified on the M3 Max: the --cfg m2v_gpu validation lib test built with the flag (102 s), its
section sizes and FDE count read by `size -m` and `llvm-dwarfdump --eh-frame`, no linker
output; under it a should_panic test, the catch_unwind tests of `build_support_tests` (20 tests,
all passed) and a RUST_BACKTRACE=1 panic's symbolized frames.

(cherry picked from commit 4c6a4cc778c8bdc2e8c5bf1d107d6d836544b347)
2026-11-05 11:25:48 -08:00
..