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)
This commit is contained in:
1 parent
ba0d7625b4
commit
514d7f13bc
1 file changed
+9
-1
+9
-1
@@ -14,8 +14,16 @@ profile-rustflags = true
|
||||
# (`0`). Profile rustflags are added to `RUSTFLAGS` rather than replaced by it, so the GPU lanes'
|
||||
# `--cfg m2v_gpu` and CI's `-Dwarnings` keep it. `test`, `bench` and `debugger` inherit it from
|
||||
# `dev` and `release`.
|
||||
#
|
||||
# Dev and test builds take sync unwind tables (`-Zuse-sync-unwind`), which hold every rule an
|
||||
# unwind from a call needs (a panic's, a backtrace's). The async ones add each function's epilogue
|
||||
# rules, which Mach-O's compact unwind table cannot encode, so on macOS every such function took a
|
||||
# DWARF entry in `__eh_frame`: 24.3 MB of them in the validation lib test under `--cfg m2v_gpu`,
|
||||
# past the 16 MB the table can point into (ld: "__eh_frame section too large (max 16MB) to encode
|
||||
# dwarf unwind offsets in compact unwind table, performance of exception handling might be
|
||||
# affected"), against 3.6 MB, and a binary 23 MB smaller, with sync tables.
|
||||
[profile.dev]
|
||||
rustflags = ["-Zthreads=0"]
|
||||
rustflags = ["-Zthreads=0", "-Zuse-sync-unwind=yes"]
|
||||
|
||||
[profile.release]
|
||||
rustflags = ["-Zthreads=0"]
|
||||
Reference in new issue
Block a user