From fd002825652523a5b5f39b8dead549f1575c724a Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 3 Aug 2026 12:53:50 -0400 Subject: [PATCH] fix(compile): keep force-unwind-tables when auto-optimize sets RUSTFLAGS (#7315) Setting RUSTFLAGS for the auto-optimize rebuild replaces .cargo/config.toml's [build] rustflags entirely, and that config file is the only place -C force-unwind-tables=yes lives. The rebuilt runtime therefore had no unwind tables, and #7305's check aborts on the first throw that crosses a runtime frame: 'unwind tables are missing from this runtime build (0 frame(s) visible to the unwinder)'. Append the flag explicitly, guarded on !panic_immediate since immediate-abort builds deliberately want the tables gone. Found independently by two agents while trying to run an auto-optimized sfw-registry; both had to work around it with PERRY_NO_AUTO_OPTIMIZE=1. --- changelog.d/7315-auto-optimize-unwind-tables.md | 1 + crates/perry/src/commands/compile/optimized_libs/driver.rs | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 changelog.d/7315-auto-optimize-unwind-tables.md diff --git a/changelog.d/7315-auto-optimize-unwind-tables.md b/changelog.d/7315-auto-optimize-unwind-tables.md new file mode 100644 index 0000000000..8e1c428971 --- /dev/null +++ b/changelog.d/7315-auto-optimize-unwind-tables.md @@ -0,0 +1 @@ +- fix(compile): auto-optimize no longer strips the runtime's unwind tables. Setting `RUSTFLAGS` for the rebuild replaced `.cargo/config.toml`'s `[build] rustflags`, the only place `-C force-unwind-tables=yes` lives, so any auto-optimized binary aborted on the first `throw` crossing a runtime frame. The flag is now appended explicitly, except under `panic_immediate` which deliberately wants the tables gone. (#7315) diff --git a/crates/perry/src/commands/compile/optimized_libs/driver.rs b/crates/perry/src/commands/compile/optimized_libs/driver.rs index bded177b15..0dbf1f4b2b 100644 --- a/crates/perry/src/commands/compile/optimized_libs/driver.rs +++ b/crates/perry/src/commands/compile/optimized_libs/driver.rs @@ -955,6 +955,13 @@ pub(crate) fn build_optimized_libs( // RUSTFLAGS from the parent environment, which is exactly the isolation a // pinned-baseline build needs. if !rustflags.is_empty() || requested_cpu.is_some() { + // #7315: setting RUSTFLAGS here replaces `.cargo/config.toml`'s + // `[build] rustflags`, which is where `-C force-unwind-tables=yes` + // lives. Without it the rebuilt runtime has no unwind tables and the + // first `throw` that crosses a runtime frame aborts. + if !panic_immediate { + rustflags.push("-C force-unwind-tables=yes".to_string()); + } cargo_cmd.env("RUSTFLAGS", rustflags.join(" ")); }