--- configure.ac.orig	2026-07-13 17:22:10.000000000 -0700
+++ configure.ac	2026-07-15 13:28:31.000000000 -0700
@@ -458,7 +458,8 @@ AS_CASE(["$build_os"],
 	      -e '^ld: warning: text-based stub file' \
 	      -e '^ld: warning: -multiply_defined is obsolete' \
 	   >/dev/null], [
-	suppress_ld_waring=yes
+	CC_WRAPPER=`cd -P "${tooldir}" && pwd`/darwin-cc
+	CC="$CC_WRAPPER $CC"
     ])
     rm -fr conftest*
     test $suppress_ld_waring = yes && warnflags="${warnflags:+${warnflags} }-Wl,-w"
@@ -4777,11 +4778,6 @@ AC_ARG_WITH(destdir,
 	    [DESTDIR="$withval"])
 AC_SUBST(DESTDIR)
 
-AS_IF([test "x$load_relative:$DESTDIR" = xyes:], [
-    AS_IF([test "x$prefix" = xNONE], [DESTDIR="$ac_default_prefix"], [DESTDIR="$prefix"])
-    prefix=/.
-])
-
 AC_OUTPUT
 }
 
--- file.c.orig	2026-07-13 17:22:10.000000000 -0700
+++ file.c	2026-07-15 13:28:31.000000000 -0700
@@ -291,9 +291,27 @@ static CFMutableStringRef
 mutable_CFString_new(CFStringRef *s, const char *ptr, long len)
 {
     const CFAllocatorRef alloc = kCFAllocatorDefault;
+
+/*
+ * The 'NoCopy' version of CFStringCreateWithBytes didn't appear until
+ * 10.5, though the original CFStringCreateWithBytes has been available
+ * since 10.0.  Hence, we need to use CFStringCreateWithBytes on OS versions
+ * earlier than 10.5.
+ *
+ * There's probably no significant benefit to using the 'NoCopy' version
+ * in this context, so making that substitution unconditionally would
+ * probably be fine (and simpler), but by the principle of least change,
+ * we limit the substitution to earlier OS versions (i.e., 10.4).
+ */
+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
     *s = CFStringCreateWithBytesNoCopy(alloc, (const UInt8 *)ptr, len,
                                        kCFStringEncodingUTF8, FALSE,
                                        kCFAllocatorNull);
+# else /* 10.4 */
+    *s = CFStringCreateWithBytes(alloc, (const UInt8 *)ptr, len,
+                                 kCFStringEncodingUTF8, FALSE);
+# endif /* 10.4 */
+
     return CFStringCreateMutableCopy(alloc, len, *s);
 }
 
--- lib/bundler/gem_helper.rb.orig	2026-07-13 17:22:10.000000000 -0700
+++ lib/bundler/gem_helper.rb	2026-07-15 13:28:31.000000000 -0700
@@ -231,7 +231,7 @@ module Bundler
     end
 
     def gem_command
-      ENV["GEM_COMMAND"]&.shellsplit || ["gem"]
+      ENV["GEM_COMMAND"]&.shellsplit || ["gem4.0"]
     end
   end
 end
--- template/Makefile.in.orig	2026-07-13 17:22:10.000000000 -0700
+++ template/Makefile.in	2026-07-15 13:28:31.000000000 -0700
@@ -513,7 +513,7 @@ _PREFIXED_SYMBOL = TOKEN_PASTE($(SYMBOL_
 
 .d.h:
 	@$(ECHO) translating probes $<
-	$(Q) $(DTRACE) -o $@.tmp -h -C $(INCFLAGS) $(CPPFLAGS) -s $<
+	$(Q) $(DTRACE) -o $@.tmp -h -C $(INCFLAGS) -s $<
 	$(Q) sed -e 's/RUBY_/RUBY_DTRACE_/g' -e 's/PROBES_H_TMP/RUBY_PROBES_H/' -e 's/(char \*/(const char */g' -e 's/, char \*/, const char */g' $@.tmp > $@
 	$(Q) $(RM) $@.tmp
 
--- thread_pthread.c.orig	2026-07-13 17:22:10.000000000 -0700
+++ thread_pthread.c	2026-07-15 13:28:31.000000000 -0700
@@ -42,6 +42,22 @@
 
 #if defined __APPLE__
 # include <AvailabilityMacros.h>
+
+/*
+ * This code is built with _XOPEN_SOURCE=1 and _DARWIN_C_SOURCE=1, which
+ * blocks the declaration of pthread_mach_thread_np() in pthread.h on 10.4.
+ * Overriding this by also defining _DARWIN_C_SOURCE didn't become available
+ * until 10.5.  The missing prototype went unnoticed until gcc14 started
+ * calling it an error.
+ *
+ * Note that many uses of Apple-specific functions with these settings are
+ * illegal (on 10.4), but for now we just fix the immediate problem by
+ * duplicating the missing declaration.  There's no need to make this
+ * conditional, since redundant prototypes are legal.
+ */
+#include <mach/port.h>
+mach_port_t 	pthread_mach_thread_np(pthread_t);
+
 #endif
 
 #if defined(HAVE_SYS_EVENTFD_H) && defined(HAVE_EVENTFD)
--- vm_dump.c.orig	2026-07-13 17:22:10.000000000 -0700
+++ vm_dump.c	2026-07-15 13:28:31.000000000 -0700
@@ -796,7 +796,7 @@ backtrace(void **trace, int size)
 
     unw_getcontext(&uc);
     unw_init_local(&cursor, &uc);
-#  if defined(__x86_64__)
+#  if defined(__x86_64__) || defined(__i386__)
     while (unw_step(&cursor) > 0) {
         unw_get_reg(&cursor, UNW_REG_IP, &ip);
         trace[n++] = (void *)ip;
@@ -811,6 +811,7 @@ backtrace(void **trace, int size)
     return n;
 darwin_sigtramp:
     /* darwin's bundled libunwind doesn't support signal trampoline */
+#   if defined(__x86_64__)  /* Only x86_64 case is implemented */
     {
         ucontext_t *uctx;
         char vec[1];
@@ -880,6 +881,8 @@ darwin_sigtramp:
         unw_get_reg(&cursor, UNW_REG_IP, &ip);
         trace[n++] = (void *)ip;
     }
+    /* TODO: Implement i386 equivalent of the above */
+#   endif  /* x86_64 (i386 currently just bails here) */
     return n;
 
 #  elif defined(__arm64__) || defined(__POWERPC__)
