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(" ")); }