On 14/11/2023 20:41, Sevan Janiyan wrote:
Ok, I reworked the patch so that it only relies on
MAC_OS_X_VERSION_MAX_ALLOWED to set SIGSEGV_FAULT_STACKPOINTER on 10.4 &
older. It falls through on the else case to set things up on 10.5.
Tested results as follows:
builds on tiger with just ./configure, tests fail, needing libsigsegv,
test-sigsegv-catch-stackoverflow1 & 2 fail, as expected
./configure with libsigsegv on tiger builds, tests pass
./configure with CFLAGS=-mmacosx-version-min=10.5 on tiger fails
sigsegv.c: In function ‘sigsegv_handler’:
sigsegv.c:1044: error: ‘struct mcontext’ has no member named ‘__ss’
./configure with libsigsegv CFLAGS=-mmacosx-version-min=10.5 on tiger
builds, but since it links to libsigsegv, needs that installed on 10.5
for test binaries to run there as well.
./configure with CFLAGS=-mmacosx-version-min=10.4 on leopard builds but
test binaries fail to run due to unresolvable symbols on tiger.
Rather than try and force things to compile on Tiger, opt to point to
libsigsegv on OS versions prior to 10.5 instead.
Tested on 10.4 (with & without libsigsegv) & 10.5 (without libsigsegv)
Sincerely,
Sevan
diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 45e1618c46..6cb9293353 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -649,6 +649,8 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
#if (defined __APPLE__ && defined __MACH__) /* macOS */
+#include <AvailabilityMacros.h>
+
# define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp
# define SIGSEGV_FAULT_ADDRESS sip->si_addr
# define SIGSEGV_FAULT_CONTEXT ((ucontext_t *) ucp)
@@ -680,11 +682,15 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
# elif defined __powerpc__
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
/* See the definitions of
- 'ucontext_t' and 'struct __darwin_ucontext' in <sys/_structs.h>,
- 'struct __darwin_mcontext' in <ppc/_structs.h>, and
- 'struct __darwin_ppc_thread_state' in <mach/ppc/_structs.h>. */
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *)
ucp)->uc_mcontext->__ss.__r1
+#else
+# error "On OS X 10.4 and older you need to link against libsigsegv instead"
+#endif
# endif