On 14/11/2023 18:42, Bruno Haible wrote:
I can't find the time to think through the detailed results that you listed. I hope you can do that.
No worries, hopefully I wont end up being to much of a bother.
But in summary, my point was "the patch is odd, because it uses MIN in one place and MAX in the other place" and I guessed "it will not work for a range that includes both 10.4 and 10.5". Your answer is "this will not work anyway", right? Did I understand it right?
Correct.
If so, can you change your patch so that 1) it is symmetric w.r.t. to MIN and MAX, and/or 2) it at least compiles for a range that includes both 10.4 and 10.5, and ideally works on 10.5? I think that would be the best behaviour for MacPorts/Homebrew/Fink/etc.
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.
Sevan
diff --git a/lib/sigsegv.c b/lib/sigsegv.c index 9a1b8cc6c0..0656c6c107 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,19 @@ int libsigsegv_version = LIBSIGSEGV_VERSION; # elif defined __powerpc__ +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 +/* See the definitions of + - 'ucontext_t' and 'struct __darwin_ucontext' in <sys/_types.h>, + - 'struct __darwin_mcontext' in <ppc/ucontext.h>, and + - 'struct __darwin_ppc_thread_state' in <mach/ppc/_types.h>. */ +# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->ss.r1 +#else /* 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 +#endif # endif