--- Makefile.in.orig 2022-04-12 04:50:11.000000000 -0700 +++ Makefile.in 2023-01-26 16:33:48.000000000 -0800 @@ -206,7 +206,7 @@ AR = @AR@ ARFLAGS = @ARFLAGS@$(empty) RANLIB = @RANLIB@ AS = @AS@ -ASFLAGS = @ASFLAGS@ $(INCFLAGS) +ASFLAGS = @ASFLAGS@ $(ARCH_FLAG) $(INCFLAGS) IFCHANGE = $(srcdir)/tool/ifchange OBJDUMP = @OBJDUMP@ OBJCOPY = @OBJCOPY@ --- addr2line.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ addr2line.c 2023-01-26 16:33:48.000000000 -0800 @@ -66,8 +66,8 @@ void *alloca(); #endif #ifdef HAVE_MACH_O_LOADER_H +# include # include -# include # include # include # include @@ -1900,6 +1900,7 @@ fill_lines(int num_traces, void **traces p = file; } else if (header->magic == FAT_CIGAM) { + struct LP(mach_header) *mhp = _NSGetMachExecuteHeader(); struct fat_header *fat = (struct fat_header *)file; char *q = file + sizeof(*fat); uint32_t nfat_arch = __builtin_bswap32(fat->nfat_arch); @@ -1909,9 +1910,9 @@ fill_lines(int num_traces, void **traces cpu_type_t cputype = __builtin_bswap32(arch->cputype); cpu_subtype_t cpusubtype = __builtin_bswap32(arch->cpusubtype); uint32_t offset = __builtin_bswap32(arch->offset); - /* fprintf(stderr,"%d: fat %d %x/%x %x/%x\n",__LINE__, i, _mh_execute_header.cputype,_mh_execute_header.cpusubtype, cputype,cpusubtype); */ - if (_mh_execute_header.cputype == cputype && - (_mh_execute_header.cpusubtype & ~CPU_SUBTYPE_MASK) == cpusubtype) { + /* fprintf(stderr,"%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */ + if (mhp->cputype == cputype && + (mhp->cpusubtype & ~CPU_SUBTYPE_MASK) == cpusubtype) { p = file + offset; file = p; header = (struct LP(mach_header) *)p; --- configure.ac.orig 2022-04-12 04:50:11.000000000 -0700 +++ configure.ac 2023-01-26 16:33:48.000000000 -0800 @@ -2747,7 +2747,15 @@ AS_IF([test "$with_dln_a_out" != yes], [ AS_IF([test "$rb_cv_dlopen" = yes], [ AS_CASE(["$target_os"], [darwin*], [ + # The -no_fixup_chains is needed on macOS 12+ to avoid getting a + # warning on the -undefined dynamic_lookup, which in turn disables + # the latter here and breaks the build of ext/bigdecimal/util. + # Since options aren't cumulative here, the two options need to be + # tested together. Older linkers may not support the added option, + # so we then try the original option alone. This may result in + # a harmless duplicate. for flag in \ + "-undefined dynamic_lookup -no_fixup_chains" \ "-undefined dynamic_lookup" \ "-multiply_defined suppress" \ ; do @@ -3797,8 +3805,8 @@ AS_IF([test "${universal_binary-no}" = y AC_SUBST(UNIVERSAL_ARCHNAMES, "${universal_archnames}") AC_SUBST(UNIVERSAL_INTS, "${ints}") AC_DEFINE_UNQUOTED(RUBY_PLATFORM_OS, "${target_os}") - AC_DEFINE_UNQUOTED(RUBY_ARCH, "universal-"RUBY_PLATFORM_OS) - AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS) + AC_DEFINE_UNQUOTED(RUBY_ARCH, "universal-" RUBY_PLATFORM_OS) + AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "universal." RUBY_PLATFORM_CPU "-" RUBY_PLATFORM_OS) ], [ arch="${target_cpu}-${target_os}" AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch") --- dln.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ dln.c 2023-01-26 16:33:48.000000000 -0800 @@ -1347,8 +1347,7 @@ dln_load(const char *file) if (dln_incompatible_library_p(handle)) { # if defined __APPLE__ && \ - defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ - (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11) + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101100 /* dlclose() segfaults */ rb_fatal("%s - %s", incompatible, file); # else --- error.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ error.c 2023-01-26 16:33:48.000000000 -0800 @@ -478,7 +478,7 @@ preface_dump(FILE *out) "-- Crash Report log information " "--------------------------------------------\n" " See Crash Report log file under the one of following:\n" -# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 +# if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 " * ~/Library/Logs/CrashReporter\n" " * /Library/Logs/CrashReporter\n" # endif @@ -503,7 +503,7 @@ postscript_dump(FILE *out) "[IMPORTANT]" /*" ------------------------------------------------"*/ "\n""Don't forget to include the Crash Report log file under\n" -# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 +# if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 "CrashReporter or " # endif "DiagnosticReports directory in bug reports.\n" --- ext/openssl/extconf.rb.orig 2022-04-12 04:50:11.000000000 -0700 +++ ext/openssl/extconf.rb 2023-01-26 16:33:48.000000000 -0800 @@ -38,7 +38,9 @@ if $mswin || $mingw end Logging::message "=== Checking for required stuff... ===\n" -result = pkg_config("openssl") && have_header("openssl/ssl.h") +# mkmf#pkg_config() looks to ignore PKG_CONFIG_PATH +#result = pkg_config("openssl") && have_header("openssl/ssl.h") +result = nil def find_openssl_library if $mswin || $mingw --- signal.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ signal.c 2023-01-26 16:33:48.000000000 -0800 @@ -862,7 +862,8 @@ check_stack_overflow(int sig, const uint const greg_t bp = mctx->gregs[REG_EBP]; # endif # elif defined __APPLE__ -# if __DARWIN_UNIX03 +# include +# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 # define MCTX_SS_REG(reg) __ss.__##reg # else # define MCTX_SS_REG(reg) ss.reg --- test/fiddle/helper.rb.orig 2022-04-12 04:50:11.000000000 -0700 +++ test/fiddle/helper.rb 2023-01-26 16:33:48.000000000 -0800 @@ -95,6 +95,13 @@ end libc_so = nil if !libc_so || (libc_so[0] == ?/ && !File.file?(libc_so)) libm_so = nil if !libm_so || (libm_so[0] == ?/ && !File.file?(libm_so)) +# https://github.com/ruby/fiddle/commit/b9e7c7b6e32088e8e02d952b4240b3665859af6b +# Use libSystem.B.dylib instead of libm.dylib and libc.dylib +# macOS 11.0+ removed libSystem.B.dylib from /usr/lib. But It works with dlopen. +if RUBY_PLATFORM =~ /darwin/ + libc_so = libm_so = "/usr/lib/libSystem.B.dylib" +end + if !libc_so || !libm_so ruby = EnvUtil.rubybin ldd = `ldd #{ruby}` --- tool/transform_mjit_header.rb.orig 2022-04-12 04:50:11.000000000 -0700 +++ tool/transform_mjit_header.rb 2023-01-26 16:33:48.000000000 -0800 @@ -176,7 +176,9 @@ module MJITHeader def self.conflicting_types?(code, cc, cflags) with_code(code) do |path| cmd = "#{cc} #{cflags} #{path}" - out = IO.popen(cmd, err: [:child, :out], &:read) + # As per gcc docs, set LC_ALL=C to avoid curly quotes in messages + cmd_env = {"LC_ALL" => "C"} + out = IO.popen(cmd_env, cmd, err: [:child, :out], &:read) !$?.success? && (out.match?(/error: conflicting types for '[^']+'/) || out.match?(/error: redefinition of parameter '[^']+'/)) --- vm.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ vm.c 2023-01-26 16:33:48.000000000 -0800 @@ -27,6 +27,8 @@ #include "probes_helper.h" VALUE rb_str_concat_literals(size_t, const VALUE*); +/* https://bugs.ruby-lang.org/issues/17777 */ +void rb_native_mutex_destroy(rb_nativethread_lock_t *lock); PUREFUNC(static inline const VALUE *VM_EP_LEP(const VALUE *)); static inline const VALUE * --- vm_dump.c.orig 2022-04-12 04:50:11.000000000 -0700 +++ vm_dump.c 2023-01-26 16:33:48.000000000 -0800 @@ -411,7 +411,8 @@ rb_vmdebug_thread_dump_state(VALUE self) } #if defined __APPLE__ -# if __DARWIN_UNIX03 +# include +# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 # define MCTX_SS_REG(reg) __ss.__##reg # else # define MCTX_SS_REG(reg) ss.reg @@ -422,7 +423,8 @@ rb_vmdebug_thread_dump_state(VALUE self) # ifdef HAVE_LIBUNWIND # undef backtrace # define backtrace unw_backtrace -# elif defined(__APPLE__) && defined(__x86_64__) && defined(HAVE_LIBUNWIND_H) +# elif defined(__APPLE__) && defined(__x86_64__) && defined(HAVE_LIBUNWIND_H) \ + && MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 # define UNW_LOCAL_ONLY # include # include