From d4fcd787a8f6f11b3ea4a7be786b06f7d06f799c Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Sat, 24 Oct 2026 15:38:37 -0500 Subject: [PATCH] Reference the unwinder weakly from the runtime's raise scr_unwind.c is linked into every Linux executable, and its references to _Unwind_ForcedUnwind and _Unwind_GetCFA pulled the unwinder out of libgcc_eh (or Zig's libunwind) even for programs that never raise, which grew a static hello world past its size ceiling. The references are now weak: programs that raise reference the personality routine from their landing pads, and its unit links the unwinder in. --- packages/runtime/src/scr_unwind.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime/src/scr_unwind.c b/packages/runtime/src/scr_unwind.c index 9bdf2dbd2..50474e82e 100644 --- a/packages/runtime/src/scr_unwind.c +++ b/packages/runtime/src/scr_unwind.c @@ -10,6 +10,13 @@ #include #include +/* Weak, so the runtime unit alone does not link the unwinder into every + * program: programs that raise reference the personality routine from + * their landing pads, and its unit references the unwinder's entry points, + * which link it in. */ +#pragma weak _Unwind_ForcedUnwind +#pragma weak _Unwind_GetCFA + #if defined(__SANITIZE_ADDRESS__) #define SCR_UNWIND_ASAN 1 #elif defined(__has_feature) @@ -69,7 +76,7 @@ void scr_unwind_raise(void) { #ifdef SCR_UNWIND_ASAN scr_unwind_low = (uintptr_t)__builtin_frame_address(0); #endif - _Unwind_ForcedUnwind(exc, scr_unwind_stop, NULL); + if (_Unwind_ForcedUnwind != NULL) _Unwind_ForcedUnwind(exc, scr_unwind_stop, NULL); fputs("scriptc: the native unwinder could not raise an exception\n", stderr); abort(); }