diff -Paur --no-dereference -- perl.upstream/cnf/configure_args.sh perl/cnf/configure_args.sh
--- perl.upstream/cnf/configure_args.sh
+++ perl/cnf/configure_args.sh
@@ -91,18 +91,23 @@
 	esac
 	# split --set-foo and similar constructs into --set foo
 	# and things like --prefix=/foo into --prefix and /foo
+	# PATCH: Fix --foo= bar being parsed as --foo bar.
+	split=
 	case "$a" in
 		set-*|use-*|include-*)
 			k=`echo "$a" | sed -e 's/^[^-]*-//'`
 			a=`echo "$a" | sed -e 's/-.*//'`
+			split=1
 			;;
 		dont-use-*|dont-include-*)	
 			k=`echo "$a" | sed -e 's/^dont-[^-]*-//'`
 			a=`echo "$a" | sed -e 's/^\(dont-[^-]*\)-.*/\1/'`
+			split=1
 			;;
 		*=*)
 			k=`echo "$a" | sed -e 's/^[^=]*=//'`
 			a=`echo "$a" | sed -e 's/=.*//'`
+			split=1
 			;;
 	esac
 	# check whether kv is required
@@ -114,7 +119,7 @@
 	esac
 	# fetch argument if necessary (--set foo=bar)
 	# note that non-empty n means there must be no argument
-	if [ -n "$x" -a -z "$k" -a -z "$n" ]; then
+	if [ -z "$split" -a -n "$x" -a -z "$k" -a -z "$n" ]; then
 		eval k="\${$i}"; i=$((i+1))
 	fi
 	# split kv pair into k and v (k=foo v=bar)
@@ -155,7 +160,8 @@
 		help) mode="help" ;;
 		regen|regenerate) mode="regen" ;;
 		keeplog) defuser "$a" 1 ;;
-		prefix|html[13]dir|libsdir)	defuser $a "$v" ;;
+		# PATCH: At least recognize --exec-prefix even though it's ignored.        
+		prefix|exec-prefix|html[13]dir|libsdir)	defuser $a "$v" ;;
 		man[13]dir|otherlibsdir)	defuser $a "$v" ;;
 		siteprefix|sitehtml[13]dir)	defuser $a "$v" ;;
 		siteman[13]dir|vendorman[13]dir)defuser $a "$v" ;;
diff -Paur --no-dereference -- perl.upstream/cnf/configure_func_ext.sh perl/cnf/configure_func_ext.sh
--- perl.upstream/cnf/configure_func_ext.sh
+++ perl/cnf/configure_func_ext.sh
@@ -68,7 +68,8 @@
 mstart "Checking FD_SET macros"
 if not hinted d_fd_macros 'found' 'missing'; then
 	try_start
-	try_includes sys/time.h sys/types.h unistd.h
+	# PATCH: FD_SET is defined in <sys/select.h>.
+	try_includes sys/select.h sys/time.h sys/types.h unistd.h
 	try_cat <<END
 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
 #else
diff -Paur --no-dereference -- perl.upstream/cnf/configure_func.sh perl/cnf/configure_func.sh
--- perl.upstream/cnf/configure_func.sh
+++ perl/cnf/configure_func.sh
@@ -7,7 +7,8 @@
 		try_start
 		funcincludes "$3" "$4" "$includes"
 		try_add "int main(void) { $2($3); return 0; }"
-		try_link -O0 -fno-builtin
+		# PATCH: Work around tests for functions without prototypes.
+		try_link -O0 -fno-builtin -Wno-error=implicit-function-declaration
 		resdef $1 'found' 'missing'
 	fi
 }
@@ -184,7 +185,8 @@
 checkfunc d_pathconf 'pathconf'
 checkfunc d_pause 'pause'
 checkfunc d_pipe 'pipe' 'NULL' 'fcntl.h unistd.h'
-checkfunc d_pipe2 'pipe' 'NULL,0' 'fcntl.h unistd.h'
+# PATCH: pipe2 accidentally checked for pipe.
+checkfunc d_pipe2 'pipe2' 'NULL,0' 'fcntl.h unistd.h'
 checkfunc d_poll 'poll'
 checkfunc d_prctl 'prctl'
 checkfunc d_pthread_atfork 'pthread_atfork'
@@ -306,4 +308,6 @@
 checkfunc d_wcsxfrm 'wcsxfrm'
 checkfunc d_wctomb 'wctomb'
 checkfunc d_writev 'writev'
+# PATCH: Add missing check for whether nanosleep exists.
+checkfunc d_nanosleep 'nanosleep'
 unset includes
diff -Paur --no-dereference -- perl.upstream/cnf/configure_tool.sh perl/cnf/configure_tool.sh
--- perl.upstream/cnf/configure_tool.sh
+++ perl/cnf/configure_tool.sh
@@ -270,6 +270,10 @@
 			define osname "gnu"
 			result "GNU"
 			;;
+		*-sortix*)
+			define osname "sortix"
+			result "Sortix"
+			;;
 		*)
 			result "no"
 			;;
diff -Paur --no-dereference -- perl.upstream/cnf/configure_type.sh perl/cnf/configure_type.sh
--- perl.upstream/cnf/configure_type.sh
+++ perl/cnf/configure_type.sh
@@ -102,7 +102,8 @@
 test "$d_longdbl" = 'define'  && checksize longdblsize 'long double'
 test "$d_longlong" = 'define' && checksize longlongsize 'long long'
 
-checktype d_fd_set 'fd_set' 'sys/types.h'
+# PATCH: FD_SET is defined in <sys/select.h>.
+checktype d_fd_set 'fd_set' 'sys/select.h'
 checktype d_fpos64_t 'fpos64_t' 'stdio.h'
 checktype d_off64_t 'off64_t' 'sys/types.h'
 checktype d_ptrdiff_t 'ptrdiff_t' 'stddef.h'
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/constant.applied perl/cnf/diffs/perl5-5.32.0/constant.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/constant.applied
+++ perl/cnf/diffs/perl5-5.32.0/constant.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/dynaloader.applied perl/cnf/diffs/perl5-5.32.0/dynaloader.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/dynaloader.applied
+++ perl/cnf/diffs/perl5-5.32.0/dynaloader.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/findext.applied perl/cnf/diffs/perl5-5.32.0/findext.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/findext.applied
+++ perl/cnf/diffs/perl5-5.32.0/findext.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/installscripts.applied perl/cnf/diffs/perl5-5.32.0/installscripts.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/installscripts.applied
+++ perl/cnf/diffs/perl5-5.32.0/installscripts.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/liblist.applied perl/cnf/diffs/perl5-5.32.0/liblist.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/liblist.applied
+++ perl/cnf/diffs/perl5-5.32.0/liblist.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/makemaker.applied perl/cnf/diffs/perl5-5.32.0/makemaker.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/makemaker.applied
+++ perl/cnf/diffs/perl5-5.32.0/makemaker.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/posix-makefile.applied perl/cnf/diffs/perl5-5.32.0/posix-makefile.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/posix-makefile.applied
+++ perl/cnf/diffs/perl5-5.32.0/posix-makefile.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/test-checkcase.applied perl/cnf/diffs/perl5-5.32.0/test-checkcase.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/test-checkcase.applied
+++ perl/cnf/diffs/perl5-5.32.0/test-checkcase.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/test-commonsense.applied perl/cnf/diffs/perl5-5.32.0/test-commonsense.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/test-commonsense.applied
+++ perl/cnf/diffs/perl5-5.32.0/test-commonsense.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/cnf/diffs/perl5-5.32.0/xconfig.applied perl/cnf/diffs/perl5-5.32.0/xconfig.applied
--- perl.upstream/cnf/diffs/perl5-5.32.0/xconfig.applied
+++ perl/cnf/diffs/perl5-5.32.0/xconfig.applied
@@ -0,0 +1 @@
+
diff -Paur --no-dereference -- perl.upstream/config_h.SH perl/config_h.SH
--- perl.upstream/config_h.SH
+++ perl/config_h.SH
@@ -1230,6 +1230,9 @@
  *	function used to generate normalized random numbers.
  *	Values include 15, 16, 31, and 48.
  */
+#if defined(__sortix__) && !defined(__SORTIX_HAS_DRAND48__)
+double drand48(void);
+#endif
 #define Drand01()		$drand01		/**/
 #define Rand_seed_t		$randseedtype		/**/
 #define seedDrand01(x)	$seedfunc((Rand_seed_t)x)	/**/
diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-Constant/t/Constant.t perl/cpan/ExtUtils-Constant/t/Constant.t
--- perl.upstream/cpan/ExtUtils-Constant/t/Constant.t
+++ perl/cpan/ExtUtils-Constant/t/Constant.t
@@ -1,8 +1,18 @@
 #!/usr/bin/perl -w
 
 use Config;
+use IPC::Cmd qw(can_run);
+
 unless ($Config{usedl}) {
-    print "1..0 # no usedl, skipping\n";
+    print "1..0 # SKIP no usedl\n";
+    exit 0;
+}
+
+my $make = $Config{make};
+$make = $ENV{MAKE} if exists $ENV{MAKE};
+
+unless ( can_run($make) ) {
+    print "1..0 # SKIP make not available\n";
     exit 0;
 }
 
@@ -34,8 +44,6 @@
 # module from blib
 @INC = map {File::Spec->rel2abs($_)} @INC if $] < 5.007 && $] >= 5.006;
 
-my $make = $Config{make};
-$make = $ENV{MAKE} if exists $ENV{MAKE};
 if ($^O eq 'MSWin32' && $make eq 'nmake') { $make .= " -nologo"; }
 
 # VMS may be using something other than MMS/MMK
diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
--- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
+++ perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
@@ -20,9 +20,10 @@
 use File::Spec;
 
 sub ext {
-    if    ( $^O eq 'VMS' )     { return &_vms_ext; }
-    elsif ( $^O eq 'MSWin32' ) { return &_win32_ext; }
-    else                       { return &_unix_os2_ext; }
+  if   ($Config{usemmldlt}){ return &_ld_ext;       }
+  elsif($^O eq 'VMS')      { return &_vms_ext;      }
+  elsif($^O eq 'MSWin32')  { return &_win32_ext;    }
+  else                     { return &_unix_os2_ext; }
 }
 
 sub _unix_os2_ext {
@@ -652,4 +653,51 @@
     wantarray ? ( $lib, '', $ldlib, '', ( $give_libs ? \@flibs : () ) ) : $lib;
 }
 
+# A direct test for -l validity.
+# Because guessing real file names for -llib options when dealing
+# with a cross compiler is generally a BAD IDEA^tm.
+sub _ld_ext {
+    my($self,$potential_libs, $verbose, $give_libs) = @_;
+    $verbose ||= 0;
+
+    if ($^O =~ 'os2' and $Config{perllibs}) { 
+	# Dynamic libraries are not transitive, so we may need including
+	# the libraries linked against perl.dll again.
+
+	$potential_libs .= " " if $potential_libs;
+	$potential_libs .= $Config{perllibs};
+    }
+    return ("", "", "", "", ($give_libs ? [] : ())) unless $potential_libs;
+    warn "Potential libraries are '$potential_libs':\n" if $verbose;
+
+    my($ld)   = $Config{ld};
+    my($lddlflags)   = $Config{lddlflags};
+    my($libs) = defined $Config{perllibs} ? $Config{perllibs} : $Config{libs};
+
+    my $try = 'try_mm.c';
+    my $tryx = 'try_mm.x';
+    open(TRY, '>', $try) || die "Can't create MakeMaker test file $try: $!\n";
+    print TRY "int main(void) { return 0; }\n";
+    close(TRY);
+
+    my $testlibs = '';
+    my @testlibs = ();
+    foreach my $thislib (split ' ', $potential_libs) {
+        $testlibs = join(' ', @testlibs);
+	if($thislib =~ /^-L/) {
+		push(@testlibs, $thislib);
+		next
+	};
+	my $cmd = "$ld $lddlflags -o $tryx $try $testlibs $thislib >/dev/null 2>&1";
+	my $ret = system($cmd);
+	warn "Warning (mostly harmless): " . "No library found for $thislib\n" if $ret;
+	next if $ret;
+	push @testlibs, $thislib;
+    }
+    unlink($try);
+    unlink($tryx);
+
+    return (join(' ', @testlibs), '', join(' ', @testlibs), '');
+}
+
 1;
diff -Paur --no-dereference -- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm
--- perl.upstream/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm
+++ perl/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm
@@ -36,7 +36,7 @@
     $Is{BSD}     = ($^O =~ /^(?:free|net|open)bsd$/ or
                    grep( $^O eq $_, qw(bsdos interix dragonfly) )
                   );
-    $Is{Android} = $^O =~ /android/;
+    $Is{Android} = $^O =~ /android/ || $Config{osname} eq 'android';
     if ( $^O eq 'darwin' && $^X eq '/usr/bin/perl' ) {
       my @osvers = split /\./, $Config{osvers};
       $Is{ApplCor} = ( $osvers[0] >= 18 );
diff -Paur --no-dereference -- perl.upstream/dist/Safe/Safe.pm perl/dist/Safe/Safe.pm
--- perl.upstream/dist/Safe/Safe.pm
+++ perl/dist/Safe/Safe.pm
@@ -43,7 +43,10 @@
     }
 }
 
-use Opcode 1.01, qw(
+# PATCH: 'use Safe;' fails with '"%.*g" is not exported by the Opcode module'
+#        on Sortix without floating point support when a floating point version
+#        number is used here.
+use Opcode 1, qw(
     opset opset_to_ops opmask_add
     empty_opset full_opset invert_opset verify_opset
     opdesc opcodes opmask define_optag opset_to_hex
diff -Paur --no-dereference -- perl.upstream/ext/DynaLoader/hints/linux.pl perl/ext/DynaLoader/hints/linux.pl
--- perl.upstream/ext/DynaLoader/hints/linux.pl
+++ perl/ext/DynaLoader/hints/linux.pl
@@ -1,5 +1 @@
-# XXX Configure test needed.
-# Some Linux releases like to hide their <nlist.h>
-$self->{CCFLAGS} = $Config{ccflags} . ' -I/usr/include/libelf'
-	if -f "/usr/include/libelf/nlist.h";
 1;
diff -Paur --no-dereference -- perl.upstream/ext/Errno/Errno_pm.PL perl/ext/Errno/Errno_pm.PL
--- perl.upstream/ext/Errno/Errno_pm.PL
+++ perl/ext/Errno/Errno_pm.PL
@@ -2,6 +2,9 @@
 use Config;
 use strict;
 
+# PATCH: Recognize the right operating system when cross-compiling.
+$^O = $Config{osname};
+
 our $VERSION = "1.30";
 
 my %err = ();
@@ -167,6 +170,11 @@
 
 	close(CPPI);
 
+	# PATCH: Simply process errno.c rather then the special logic below to
+	# locate the system headers.
+	$file{"errno.c"} = 1;
+	return keys %file;
+
 	# invoke CPP and read the output
 	if ($IsMSWin32 || $^O eq 'NetWare') {
 	    open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
diff -Paur --no-dereference -- perl.upstream/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm perl/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm
--- perl.upstream/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm
+++ perl/ext/ExtUtils-Miniperl/lib/ExtUtils/Miniperl.pm
@@ -2,7 +2,8 @@
 package ExtUtils::Miniperl;
 use strict;
 require Exporter;
-use ExtUtils::Embed 1.31, qw(xsi_header xsi_protos xsi_body);
+# PATCH: "%.*g" is not exported by the ExtUtils::Embed module
+use ExtUtils::Embed 1, qw(xsi_header xsi_protos xsi_body);
 
 our @ISA = qw(Exporter);
 our @EXPORT = qw(writemain);
diff -Paur --no-dereference -- perl.upstream/ext/POSIX/Makefile.PL perl/ext/POSIX/Makefile.PL
--- perl.upstream/ext/POSIX/Makefile.PL
+++ perl/ext/POSIX/Makefile.PL
@@ -1,4 +1,9 @@
 # Expect this line to be read by t/posix.t, don't change it
+
+# Explicitly avoid including '.' in @INC; autoloader gets confused since it
+# can find POSIX.pm, but can't find autosplit.ix.
+BEGIN { pop @INC;}
+#
 use ExtUtils::MakeMaker;
 use ExtUtils::Constant 0.23 'WriteConstants';
 use Config;
diff -Paur --no-dereference -- perl.upstream/ext/POSIX/POSIX.xs perl/ext/POSIX/POSIX.xs
--- perl.upstream/ext/POSIX/POSIX.xs
+++ perl/ext/POSIX/POSIX.xs
@@ -1,3 +1,12 @@
+#if defined(__sortix__) && !defined(__SORTIX_HAS_PAUSE__)
+#include <stddef.h>
+#include <signal.h>
+int pause(void)
+{
+	return sigsuspend(NULL);
+}
+#endif
+
 #define PERL_EXT_POSIX
 #define PERL_EXT
 
@@ -1418,7 +1427,11 @@
 #      define mkfifo(a,b) not_here("mkfifo")
 #    else	/* !( defined OS2 ) */
 #      ifndef mkfifo
+#if defined(__sortix__)
+#        define mkfifo(path, mode) not_here("mkfifo")
+#else
 #        define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
+#endif
 #      endif
 #    endif
 #  endif /* !HAS_MKFIFO */
@@ -3820,12 +3833,19 @@
 ctermid(s = 0)
 	char *          s = 0;
     CODE:
+/* PATCH: Sortix doesn't have ctermid at this time. */
+#ifdef L_ctermid
 #ifdef I_TERMIOS
         /* On some systems L_ctermid is a #define; but not all; this code works
          * for all cases (so far...) */
 	s = (char *) safemalloc((size_t) L_ctermid);
 #endif
 	RETVAL = ctermid(s);
+#else
+	s = (char *) safemalloc(strlen("/dev/tty"));
+	strcpy(s, "/dev/tty");
+	RETVAL = s;
+#endif
     OUTPUT:
 	RETVAL
     CLEANUP:
diff -Paur --no-dereference -- perl.upstream/installman perl/installman
--- perl.upstream/installman
+++ perl/installman
@@ -1,8 +1,6 @@
 #!./perl -w
 
 BEGIN {
-    @INC = qw(lib);
-
     # This needs to be at BEGIN time, before any use of Config
     # install_lib itself loads and imports Config into main::
     require './install_lib.pl';
diff -Paur --no-dereference -- perl.upstream/installperl perl/installperl
--- perl.upstream/installperl
+++ perl/installperl
@@ -2,8 +2,6 @@
 
 BEGIN {
     chdir '..' if !-d 'lib' and -d '../lib';
-    @INC = 'lib';
-    $ENV{PERL5LIB} = 'lib';
 
     # This needs to be at BEGIN time, before any use of Config
     # install_lib itself loads and imports Config into main::
@@ -194,6 +192,7 @@
 
 # Fetch some frequently-used items from %Config
 my $installbin = "$opts{destdir}$Config{installbin}";
+my $installlib = "$opts{destdir}$Config{installlib}";
 my $installscript = "$opts{destdir}$Config{installscript}";
 my $installprivlib = "$opts{destdir}$Config{installprivlib}";
 my $installarchlib = "$opts{destdir}$Config{installarchlib}";
@@ -378,7 +377,8 @@
     @corefiles = <*.h>;
 } else {
     # [als] hard-coded 'libperl' name... not good!
-    @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>;
+    @corefiles = <*.h perl*$Config{lib_ext}>;
+    push(@corefiles, $Config{libperl}) if $Config{useshrplib} && !$Config{soname};
 
     # AIX needs perl.exp installed as well.
     push(@corefiles,'perl.exp') if $^O eq 'aix';
@@ -404,6 +404,29 @@
 	chmod($NON_SO_MODE, $dest) foreach @corefiles;
 }
 
+if($Config{useshrplib} && $Config{soname}) {
+    my $libperl = $Config{libperl};
+    my $soname = $Config{soname};
+    mkpath($installlib);
+    if (copy_if_diff($libperl, "$installlib/$libperl")) {
+        strip("-S", "$installlib/$libperl");
+        chmod(0555, "$installlib/$libperl");
+
+        # Normally this should be done by ldconfig.
+        safe_unlink("$installlib/$soname") unless $soname eq $libperl;
+        safe_unlink("$installlib/libperl.so") unless $soname eq 'libperl.so';
+        symlink($libperl, "$installlib/$soname") unless $soname eq $libperl;
+        symlink($libperl, "$installlib/libperl.so") unless $soname eq 'libperl.so';
+        # using $so here instead of .so hardly makes any sense,
+        # all systems supporting SONAME have $so=.so
+
+        # Backward compatibility: provide a symlink where people expect it
+        safe_unlink("$installarchlib/CORE/libperl.so");
+        symlink("$Config{installlib}/$libperl", "$installarchlib/CORE/libperl.so");
+        #        ^ without destdir here!
+    }
+}
+
 # Install main perl executables
 # Make links to ordinary names if installbin directory isn't current directory.
 
diff -Paur --no-dereference -- perl.upstream/lib/unicore/mktables perl/lib/unicore/mktables
--- perl.upstream/lib/unicore/mktables
+++ perl/lib/unicore/mktables
@@ -12629,10 +12629,12 @@
         if (   defined $nv_floating_to_rational{$float}
             && $nv_floating_to_rational{$float} ne $rational)
         {
-            die Carp::my_carp_bug("Both '$rational' and"
-                            . " '$nv_floating_to_rational{$float}' evaluate to"
-                            . " the same floating point number."
-                            . "  \$E_FLOAT_PRECISION must be increased");
+            # PATCH: This test fails on native Sortix due to lack of floating
+            #        point formatting support, but nothing is wrong.
+            #die Carp::my_carp_bug("Both '$rational' and"
+            #                . " '$nv_floating_to_rational{$float}' evaluate to"
+            #                . " the same floating point number."
+            #                . "  \$E_FLOAT_PRECISION must be increased");
         }
         $nv_floating_to_rational{$float} = $rational;
     }
diff -Paur --no-dereference -- perl.upstream/Makefile perl/Makefile
--- perl.upstream/Makefile
+++ perl/Makefile
@@ -61,7 +61,8 @@
 # Original versions are not saved anymore; patch generally takes care of this,
 # and if that fails, reaching for the source tarball is the safest option.
 $(CROSSPATCHED): %.applied: %.patch
-	patch -p1 -i $< && touch $@
+	# PATCH: The .applied files needs to be non-empty to be in the diff.
+	patch -p1 -i $< && echo > $@
 
 # ---[ common ]-----------------------------------------------------------------
 
@@ -243,14 +244,19 @@
 
 preplibrary: $(CONFIGPM) | miniperl$X lib/re.pm lib/lib.pm
 
+# PATCH: Set LINKTYPE to static or otherwise the all target depends on linkext
+#        that depends on dynamic, and thus both static and dynamic libraries
+#        gets built.
 dist/lib/Makefile: dist/lib/Makefile.PL cflags config.h $(CONFIGPM) | miniperl$X
 	$(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g'))
 	cd $(dir $@) && $(top)miniperl_top -I$(top)lib Makefile.PL \
+	 LINKTYPE=static \
 	 PERL_CORE=1 LIBPERL_A=$(LIBPERL) PERL="$(top)miniperl_top"
 
 %/Makefile: %/Makefile.PL preplibrary cflags config.h | $(XSUBPP) miniperl$X
 	$(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g'))
 	cd $(dir $@) && $(top)miniperl_top -I$(top)lib Makefile.PL \
+	 LINKTYPE=static \
 	 INSTALLDIRS=perl INSTALLMAN1DIR=none INSTALLMAN3DIR=none \
 	 PERL_CORE=1 LIBPERL_A=$(LIBPERL) PERL="$(top)miniperl_top"
 
@@ -319,7 +325,7 @@
 cpan/ExtUtils-ParseXS/Makefile cpan/ExtUtils-Constant/Makefile: \
 		%/Makefile: %/Makefile.PL preplibrary cflags | miniperl$X miniperl_top
 	$(eval top=$(shell echo $(dir $@) | sed -re 's![^/]+!..!g'))
-	cd $(dir $@) && $(top)miniperl_top Makefile.PL PERL_CORE=1 PERL=$(top)miniperl_top
+	cd $(dir $@) && $(top)miniperl_top Makefile.PL LINKTYPE=static PERL_CORE=1 PERL=$(top)miniperl_top
 
 cpan/List-Util/pm_to_blib: | dynaloader
 
@@ -432,7 +438,10 @@
 
 install.sym: # deprecated
 
-install.man: installman pod/perltoc.pod | miniperl$X
+# PATCH: Sever makefile dependency that tends to livelock make with 100% CPU
+#        usage after doing the static modules when building -j2 or more.
+#        pod/perltoc.pod and miniperl are already built by the main all target.
+install.man: installman # pod/perltoc.pod | miniperl$X
 	./miniperl_top installman --destdir=$(DESTDIR) $(INSTALLFLAGS)
 
 # ---[ testpack ]---------------------------------------------------------------
@@ -445,9 +454,10 @@
 	tar -zcvf $@ -T $<
 
 # ---[ clean ]------------------------------------------------------------------
+# PATCH: make doesn't work this way when make -j.
 # clean-modules must go BEFORE clean-generated-files because it depends on config.h!
 .PHONY: clean clean-obj clean-generated-files clean-subdirs clean-modules clean-testpack
-clean: clean-obj clean-modules clean-generated-files clean-subdirs clean-testpack
+clean: clean-obj clean-modules clean-subdirs clean-testpack
 
 clean-obj:
 	-test -n "$o" && rm -f *$o
@@ -458,7 +468,7 @@
 
 # assuming modules w/o Makefiles were never built and need no cleaning
 clean-modules: config.h
-	@for i in $(modules disabled); do \
+	@for i in $(modules) $(disabled) ext/DynaLoader; do \
 		test -f $$i/Makefile && \
 		touch $$i/Makefile && \
 		$(MAKE) -C $$i clean \
@@ -478,3 +488,307 @@
 clean-testpack:
 	-rm -fr TESTPACK
 	-rm -f TESTPACK.list
+
+# PATCH: perl is terrible at cleaning up properly.
+distclean: clean
+	$(MAKE) clean-generated-files # clean-modules needs config.h...
+	rm -f *.host.o
+	rm -f cflags
+	rm -f config.log
+	find cpan dist ext -name Makefile -delete
+	find cpan dist ext -name Makefile.old -delete
+	find cpan dist ext -name '*.fnm' -delete
+	rm -rf `grep -lr 'It will be deleted automatically by make realclean' cpan dist ext`
+	rm -rf `grep -lr 'This file is auto-generated by mkheader.' cpan dist | grep -E '\.h'`
+	rm -rf cpan/Compress-Raw-Bzip2/*.[ch]
+	rm -rf cpan/Compress-Raw-Zlib/*.[ch]
+	rm -f cpan/Compress-Raw-Bzip2/constants.xs
+	rm -f cpan/Compress-Raw-Zlib/constants.xs
+	rm -f cpan/Encode/Byte/Byte.xs
+	rm -f cpan/Encode/CN/CN.xs
+	rm -f cpan/Encode/EBCDIC/EBCDIC.xs
+	rm -f cpan/Encode/JP/JP.xs
+	rm -f cpan/Encode/KR/KR.xs
+	rm -f cpan/Encode/Symbol/Symbol.xs
+	rm -f cpan/Encode/TW/TW.xs
+	rm -f cpan/Pod-Checker/podchecker
+	rm -f cpan/Pod-Checker/podchecker.PL
+	rm -f cpan/podlators/scripts/pod2man
+	rm -f cpan/podlators/scripts/pod2text
+	rm -f cpan/Pod-Usage/pod2usage
+	rm -f cpan/Pod-Usage/pod2usage.PL
+	rm -f cpan/Socket/const-c.inc
+	rm -f cpan/Socket/const-xs.inc
+	rm -f cpan/Sys-Syslog/const-c.inc
+	rm -f cpan/Sys-Syslog/const-xs.inc
+	rm -rf cpan/Sys-Syslog/lib
+	rm -f cpan/Sys-Syslog/macros.all
+	rm -f dist/lib/lib.pm
+	rm -f dist/Time-HiRes/const-c.inc
+	rm -f dist/Time-HiRes/const-xs.inc
+	rm -f dist/Time-HiRes/xdefine
+	rm -f dist/Devel-PPPort/RealPPPort.xs
+	rm -f ext/B/const-c.inc
+	rm -f ext/B/const-xs.inc
+	rm -f ext/Errno/arch.txt
+	rm -f ext/Errno/Errno.pm
+	rm -f ext/Fcntl/const-c.inc
+	rm -f ext/Fcntl/const-xs.inc
+	rm -f ext/File-Glob/const-c.inc
+	rm -f ext/File-Glob/const-xs.inc
+	rm -f ext/I18N-Langinfo/const-c.inc
+	rm -f ext/I18N-Langinfo/const-xs.inc
+	rm -f ext/Pod-Functions/Functions.pm
+	rm -f ext/POSIX/const-c.inc
+	rm -f ext/POSIX/const-xs.inc
+	rm -f ext/re/dquote.c
+	rm -f ext/re/invlist_inline.h
+	rm -f ext/re/re_comp.c
+	rm -f ext/re/re_exec.c
+	rm -f ext/XS-APItest/const-c.inc
+	rm -f ext/XS-APItest/const-xs.inc
+	rm -f extra.pods
+	rm -f lib/.exists
+	rm -rf lib/App
+	rm -rf lib/Archive
+	rm -rf lib/Attribute
+	rm -f lib/AutoLoader.pm
+	rm -f lib/AutoSplit.pm
+	rm -f lib/B.pm
+	rm -f lib/B/Concise.pm
+	rm -f lib/B/Showlex.pm
+	rm -f lib/B/Terse.pm
+	rm -f lib/B/Xref.pm
+	rm -rf lib/CPAN
+	rm -f lib/CPAN.pm
+	rm -rf lib/Carp
+	rm -f lib/Carp.pm
+	rm -rf lib/Compress
+	rm -f lib/Config.pm
+	rm -f lib/Config.pod
+	rm -rf lib/Config/Perl
+	rm -f lib/Config_git.pl
+	rm -f lib/Config_heavy.pl
+	rm -f lib/Cwd.pm
+	rm -rf lib/Data
+	rm -rf lib/Devel
+	rm -rf lib/Digest
+	rm -f lib/Digest.pm
+	rm -f lib/Dumpvalue.pm
+	rm -f lib/DynaLoader.pm
+	rm -rf lib/Encode
+	rm -f lib/Encode.pm
+	rm -f lib/Env.pm
+	rm -f lib/Errno.pm
+	rm -rf lib/Exporter
+	rm -f lib/Exporter.pm
+	rm -f lib/ExtUtils/.exists
+	rm -rf lib/ExtUtils/CBuilder
+	rm -f lib/ExtUtils/CBuilder.pm
+	rm -rf lib/ExtUtils/Command
+	rm -f lib/ExtUtils/Command.pm
+	rm -rf lib/ExtUtils/Constant
+	rm -f lib/ExtUtils/Constant.pm
+	rm -f lib/ExtUtils/Install.pm
+	rm -f lib/ExtUtils/Installed.pm
+	rm -rf lib/ExtUtils/Liblist
+	rm -f lib/ExtUtils/Liblist.pm
+	rm -f lib/ExtUtils/MANIFEST.SKIP
+	rm -f lib/ExtUtils/MM.pm
+	rm -f lib/ExtUtils/MM_AIX.pm
+	rm -f lib/ExtUtils/MM_Any.pm
+	rm -f lib/ExtUtils/MM_BeOS.pm
+	rm -f lib/ExtUtils/MM_Cygwin.pm
+	rm -f lib/ExtUtils/MM_DOS.pm
+	rm -f lib/ExtUtils/MM_Darwin.pm
+	rm -f lib/ExtUtils/MM_MacOS.pm
+	rm -f lib/ExtUtils/MM_NW5.pm
+	rm -f lib/ExtUtils/MM_OS2.pm
+	rm -f lib/ExtUtils/MM_QNX.pm
+	rm -f lib/ExtUtils/MM_UWIN.pm
+	rm -f lib/ExtUtils/MM_Unix.pm
+	rm -f lib/ExtUtils/MM_VMS.pm
+	rm -f lib/ExtUtils/MM_VOS.pm
+	rm -f lib/ExtUtils/MM_Win32.pm
+	rm -f lib/ExtUtils/MM_Win95.pm
+	rm -f lib/ExtUtils/MY.pm
+	rm -rf lib/ExtUtils/MakeMaker
+	rm -f lib/ExtUtils/MakeMaker.pm
+	rm -f lib/ExtUtils/Manifest.pm
+	rm -f lib/ExtUtils/Miniperl.pm
+	rm -f lib/ExtUtils/Mkbootstrap.pm
+	rm -f lib/ExtUtils/Mksymlists.pm
+	rm -f lib/ExtUtils/Packlist.pm
+	rm -rf lib/ExtUtils/ParseXS
+	rm -f lib/ExtUtils/ParseXS.pm
+	rm -f lib/ExtUtils/ParseXS.pod
+	rm -rf lib/ExtUtils/Typemaps
+	rm -f lib/ExtUtils/Typemaps.pm
+	rm -f lib/ExtUtils/testlib.pm
+	rm -f lib/ExtUtils/xsubpp
+	rm -f lib/Fatal.pm
+	rm -f lib/Fcntl.pm
+	rm -f lib/File/.exists
+	rm -f lib/File/DosGlob.pm
+	rm -f lib/File/Fetch.pm
+	rm -f lib/File/Find.pm
+	rm -f lib/File/Glob.pm
+	rm -f lib/File/GlobMapper.pm
+	rm -f lib/File/Path.pm
+	rm -rf lib/File/Spec
+	rm -f lib/File/Spec.pm
+	rm -f lib/File/Temp.pm
+	rm -f lib/FileCache.pm
+	rm -rf lib/Filter
+	rm -f lib/FindBin.pm
+	rm -f lib/Getopt/.exists
+	rm -f lib/Getopt/Long.pm
+	rm -rf lib/HTTP
+	rm -rf lib/Hash
+	rm -rf lib/I18N
+	rm -rf lib/IO
+	rm -f lib/IO.pm
+	rm -rf lib/IPC
+	rm -rf lib/JSON
+	rm -rf lib/List
+	rm -rf lib/Locale
+	rm -rf lib/MIME
+	rm -rf lib/Math
+	rm -rf lib/Memoize
+	rm -f lib/Memoize.pm
+	rm -rf lib/Module
+	rm -f lib/NEXT.pm
+	rm -f lib/Net/.exists
+	rm -f lib/Net/Cmd.pm
+	rm -f lib/Net/Config.pm
+	rm -f lib/Net/Domain.pm
+	rm -rf lib/Net/FTP
+	rm -f lib/Net/FTP.pm
+	rm -f lib/Net/NNTP.pm
+	rm -f lib/Net/Netrc.pm
+	rm -f lib/Net/POP3.pm
+	rm -f lib/Net/Ping.pm
+	rm -f lib/Net/SMTP.pm
+	rm -f lib/Net/Time.pm
+	rm -f lib/Net/libnetFAQ.pod
+	rm -f lib/O.pm
+	rm -f lib/Opcode.pm
+	rm -f lib/POSIX.pm
+	rm -f lib/POSIX.pod
+	rm -rf lib/Params
+	rm -rf lib/Parse
+	rm -rf lib/Perl
+	rm -rf lib/PerlIO
+	rm -f lib/Pod/.exists
+	rm -f lib/Pod/Checker.pm
+	rm -f lib/Pod/Escapes.pm
+	rm -f lib/Pod/Functions.pm
+	rm -f lib/Pod/Html.pm
+	rm -f lib/Pod/Man.pm
+	rm -f lib/Pod/ParseLink.pm
+	rm -rf lib/Pod/Perldoc
+	rm -f lib/Pod/Perldoc.pm
+	rm -rf lib/Pod/Simple
+	rm -f lib/Pod/Simple.pm
+	rm -f lib/Pod/Simple.pod
+	rm -rf lib/Pod/Text
+	rm -f lib/Pod/Text.pm
+	rm -f lib/Pod/Usage.pm
+	rm -f lib/SDBM_File.pm
+	rm -f lib/Safe.pm
+	rm -rf lib/Scalar
+	rm -rf lib/Search
+	rm -f lib/SelfLoader.pm
+	rm -f lib/Socket.pm
+	rm -f lib/Storable.pm
+	rm -rf lib/Sub
+	rm -rf lib/Sys
+	rm -rf lib/TAP
+	rm -rf lib/Term
+	rm -rf lib/Test
+	rm -f lib/Test.pm
+	rm -rf lib/Test2
+	rm -f lib/Test2.pm
+	rm -rf lib/Text
+	rm -rf lib/Thread
+	rm -f lib/Tie/.exists
+	rm -f lib/Tie/File.pm
+	rm -rf lib/Tie/Hash
+	rm -f lib/Tie/Memoize.pm
+	rm -f lib/Tie/RefHash.pm
+	rm -f lib/Time/.exists
+	rm -f lib/Time/HiRes.pm
+	rm -f lib/Time/Local.pm
+	rm -f lib/Time/Piece.pm
+	rm -f lib/Time/Seconds.pm
+	rm -f lib/Unicode/.exists
+	rm -rf lib/Unicode/Collate
+	rm -f lib/Unicode/Collate.pm
+	rm -f lib/Unicode/Normalize.pm
+	rm -rf lib/XS
+	rm -f lib/XSLoader.pm
+	rm -f lib/attributes.pm
+	rm -rf lib/auto
+	rm -rf lib/autodie
+	rm -f lib/autodie.pm
+	rm -f lib/autouse.pm
+	rm -f lib/base.pm
+	rm -f lib/bigint.pm
+	rm -f lib/bignum.pm
+	rm -f lib/bigrat.pm
+	rm -f lib/constant.pm
+	rm -rf lib/encoding
+	rm -f lib/encoding.pm
+	rm -f lib/experimental.pm
+	rm -f lib/fields.pm
+	rm -f lib/if.pm
+	rm -f lib/lib.pm
+	rm -f lib/mro.pm
+	rm -f lib/ok.pm
+	rm -f lib/ops.pm
+	rm -f lib/parent.pm
+	rm -f lib/perldoc.pod
+	rm -f lib/perlfaq.pm
+	rm -f lib/perlfaq.pod
+	rm -f lib/perlfaq1.pod
+	rm -f lib/perlfaq2.pod
+	rm -f lib/perlfaq3.pod
+	rm -f lib/perlfaq4.pod
+	rm -f lib/perlfaq5.pod
+	rm -f lib/perlfaq6.pod
+	rm -f lib/perlfaq7.pod
+	rm -f lib/perlfaq8.pod
+	rm -f lib/perlfaq9.pod
+	rm -f lib/perlglossary.pod
+	rm -f lib/perlxs.pod
+	rm -f lib/perlxstut.pod
+	rm -f lib/perlxstypemap.pod
+	rm -rf lib/threads
+	rm -f lib/threads.pm
+	rm -f lib/unicore/CombiningClass.pl
+	rm -f lib/unicore/Decomposition.pl
+	rm -f lib/unicore/Name.pl
+	rm -f lib/unicore/Name.pm
+	rm -f lib/unicore/TestProp.pl
+	rm -rf lib/unicore/To
+	rm -f lib/unicore/UCD.pl
+	rm -rf lib/unicore/lib
+	rm -f lib/unicore/mktables.lst
+	rm -rf lib/version
+	rm -f lib/version.pm
+	rm -f lib/version.pod
+	rm -f libperl.a
+	rm -f mg_data.h
+	rm -f miniperl
+	rm -f perl
+	find pod -type l -delete
+	rm -f `grep -rl 'This file is built by' pod`
+	rm -f pod/perltoc.pod
+	rm -f pod/perluniprops.pod
+	rm -f pod/roffitall
+	rm -f try
+	rm -f try.c
+	rm -f try.h
+	rm -f try.out
+	rm -f xconfig.sh
+	rm -f Makefile.config config.sh
diff -Paur --no-dereference -- perl.upstream/perl.h perl/perl.h
--- perl.upstream/perl.h
+++ perl/perl.h
@@ -25,7 +25,11 @@
 #ifdef PERL_MICRO
 #   include "uconfig.h"
 #else
+#   ifndef USE_CROSS_COMPILE
 #   include "config.h"
+#   else
+#       include "xconfig.h"
+#   endif
 #endif
 
 /* this is used for functions which take a depth trailing
diff -Paur --no-dereference -- perl.upstream/perl_langinfo.h perl/perl_langinfo.h
--- perl.upstream/perl_langinfo.h
+++ perl/perl_langinfo.h
@@ -4,7 +4,11 @@
 #ifndef PERL_LANGINFO_H
 #define PERL_LANGINFO_H 1
 
+#ifdef USE_CROSS_COMPILE
+#include "xconfig.h"
+#else
 #include "config.h"
+#endif
 
 #if defined(HAS_NL_LANGINFO) && defined(I_LANGINFO)
 #   include <langinfo.h>
diff -Paur --no-dereference -- perl.upstream/pp.c perl/pp.c
--- perl.upstream/pp.c
+++ perl/pp.c
@@ -2866,6 +2866,13 @@
    --Jarkko Hietaniemi	27 September 1998
  */
 
+#if defined(__sortix__) && !defined(__SORTIX_HAS_DRAND48__)
+double drand48(void)
+{
+    return arc4random() / 4294967295.0;
+}
+#endif
+
 PP(pp_rand)
 {
     if (!PL_srand_called) {
diff -Paur --no-dereference -- perl.upstream/t/lib/commonsense.t perl/t/lib/commonsense.t
--- perl.upstream/t/lib/commonsense.t
+++ perl/t/lib/commonsense.t
@@ -18,7 +18,7 @@
   BAIL_OUT("Perl configured without IO module");
 }
 # hey, DOS users do not need this kind of common sense ;-)
-if ($^O ne 'dos' && ($Config{'extensions'} !~ /\bFile\/Glob\b/) ){
+if ($^O ne 'dos' && ($Config{'extensions'} !~ /\bFile.Glob\b/) ){
   BAIL_OUT("Perl configured without File::Glob module");
 }
 
diff -Paur --no-dereference -- perl.upstream/t/porting/checkcase.t perl/t/porting/checkcase.t
--- perl.upstream/t/porting/checkcase.t
+++ perl/t/porting/checkcase.t
@@ -25,6 +25,8 @@
 
 	   # Special exemption for Makefile, makefile
 	   return if $name =~ m!\A[Mm]akefile\z!;
+	   # same for Configure, configure in perl-cross
+	   return if $name =~ m!\A[Cc]onfigure\z!;
 
 	   if ($name eq '.git') {
 	       # Don't scan the .git directory, as its contents are outside
diff -Paur --no-dereference -- perl.upstream/util.c perl/util.c
--- perl.upstream/util.c
+++ perl/util.c
@@ -2094,7 +2094,7 @@
  * For Solaris, setenv() and unsetenv() were introduced in Solaris 9, so
  * testing for HAS UNSETENV is sufficient.
  */
-#  if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN)
+#  if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) || defined(__sortix__)
 #    define MY_HAS_SETENV
 #  endif
 
@@ -2102,7 +2102,7 @@
  * 'current' is non-null, with up to three sizes that are added together.
  * It handles integer overflow.
  */
-#  ifndef MY_HAS_SETENV
+/* PATCH: Support having only setenv/unsetenv and no putenv. */
 static char *
 S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size)
 {
@@ -2127,7 +2127,6 @@
   panic:
     croak_memory_wrap();
 }
-#  endif
 
 
 #  if !defined(WIN32) && !defined(NETWARE)
diff -Paur --no-dereference -- perl.upstream/vutil.c perl/vutil.c
--- perl.upstream/vutil.c
+++ perl/vutil.c
@@ -702,12 +702,25 @@
 #endif
 
 	if (sv) {
+/* PATCH: Sortix doesn't have floating point printing yet. */
+#if defined(__sortix__) && !defined(__SORTIX_HAS_FORMAT_FLOAT__)
+		double d = SvNVX(ver);
+                Perl_sv_catpvf(aTHX_ sv, "%d.%09d", (int) d,
+                               (int) ((long long)(d * 1000000000) % 1000000000));
+#else
                 Perl_sv_catpvf(aTHX_ sv, "%.9" NVff, SvNVX(ver));
+#endif
 	    len = SvCUR(sv);
 	    buf = SvPVX(sv);
 	}
 	else {
+#if defined(__sortix__) && !defined(__SORTIX_HAS_FORMAT_FLOAT__)
+		double d = SvNVX(ver);
+                len = my_snprintf(tbuf, sizeof(tbuf), "%d.%09d", (int) d,
+                                  (int) ((long long)(d * 1000000000) % 1000000000));
+#else
                 len = my_snprintf(tbuf, sizeof(tbuf), "%.9" NVff, SvNVX(ver));
+#endif
 	    buf = tbuf;
 	}
 
diff -Paur --no-dereference -- perl.upstream/win32/FindExt.pm perl/win32/FindExt.pm
--- perl.upstream/win32/FindExt.pm
+++ perl/win32/FindExt.pm
@@ -115,10 +115,6 @@
         $this_ext =~ s!-!/!g;
         $leaf =~ s/.*-//;
 
-        # List/Util.xs lives in Scalar-List-Utils, Cwd.xs lives in PathTools
-        $this_ext = 'List/Util' if $this_ext eq 'Scalar/List/Utils';
-        $this_ext = 'Cwd'       if $this_ext eq 'PathTools';
-
 	# Temporary hack to cope with smokers that are not clearing directories:
         next if $ext{$this_ext};
 
