From e035216a9888c988e11a083ca0306b9d17c1ef54 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Wed, 5 Mar 2025 03:35:42 -0800 Subject: [PATCH] Declare header extern functions as weak on macOS. Fixes crashes on x86_64 builds with LTO enabled. --- XenonUtils/ppc_context.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/XenonUtils/ppc_context.h b/XenonUtils/ppc_context.h index bc427c9..e171e2a 100644 --- a/XenonUtils/ppc_context.h +++ b/XenonUtils/ppc_context.h @@ -26,8 +26,13 @@ #define PPC_STRINGIFY(x) PPC_XSTRINGIFY(x) #define PPC_FUNC(x) void x(PPCContext& __restrict ctx, uint8_t* base) #define PPC_FUNC_IMPL(x) extern "C" PPC_FUNC(x) -#define PPC_EXTERN_FUNC(x) extern PPC_FUNC(x) #define PPC_WEAK_FUNC(x) __attribute__((weak,noinline)) PPC_FUNC(x) +#ifdef __APPLE__ +// Declare header declaration as weak as well to make sure LTO is correct. +#define PPC_EXTERN_FUNC(x) extern PPC_WEAK_FUNC(x) +#else +#define PPC_EXTERN_FUNC(x) extern PPC_FUNC(x) +#endif #define PPC_FUNC_PROLOGUE() __builtin_assume(((size_t)base & 0xFFFFFFFF) == 0)