diff --git a/config/perl.m4 b/config/perl.m4
index e44ca943132426e0e58b5c435f6022d6d4e084ee..8c21d0fb395df4a669669ef499f29266fcc73ab3 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -56,7 +56,9 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
 # to a different libc ABI than core Postgres uses.  The available information
 # says that all the symbols that affect Perl's own ABI begin with letters,
 # so it should be sufficient to adopt -D switches for symbols not beginning
-# with underscore.
+# with underscore.  An exception is that we need to let through
+# -D_USE_32BIT_TIME_T if it's present.  (We probably could restrict that to
+# only get through on Windows, but for the moment we let it through always.)
 # For debugging purposes, let's have the configure output report the raw
 # ccflags value as well as the set of flags we chose to adopt.
 AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
@@ -65,7 +67,7 @@ AC_MSG_CHECKING([for CFLAGS recommended by Perl])
 perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
 AC_MSG_RESULT([$perl_ccflags])
 AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
-perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}']`
+perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
 AC_SUBST(perl_embed_ccflags)dnl
 AC_MSG_RESULT([$perl_embed_ccflags])
 ])# PGAC_CHECK_PERL_EMBED_CCFLAGS
diff --git a/configure b/configure
index cc6471bba6fe2027c3896f2fffee087be6c7d39a..52834e95451634f6352c0e4ffa6ca5ae08d75bc5 100755
--- a/configure
+++ b/configure
@@ -7866,7 +7866,7 @@ perl_ccflags=`$PERL -MConfig -e 'print $Config{ccflags}'`
 $as_echo "$perl_ccflags" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS to compile embedded Perl" >&5
 $as_echo_n "checking for CFLAGS to compile embedded Perl... " >&6; }
-perl_embed_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}'`
+perl_embed_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}'`
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $perl_embed_ccflags" >&5
 $as_echo "$perl_embed_ccflags" >&6; }
 
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index d7638b458ef954ac14dc3b2faf06a0aa75ce4b23..27329f9e361808f44daa4be5b5c3629323a65e0c 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -63,21 +63,16 @@ EOF
   </PropertyGroup>
 EOF
 
-	# We have to use this flag on 32 bit targets because the 32bit perls
-	# are built with it and sometimes crash if we don't.
-	my $use_32bit_time_t =
-	  $self->{platform} eq 'Win32' ? '_USE_32BIT_TIME_T;' : '';
-
 	$self->WriteItemDefinitionGroup(
 		$f, 'Debug',
-		{   defs    => "_DEBUG;DEBUG=1;$use_32bit_time_t",
+		{   defs    => "_DEBUG;DEBUG=1",
 			opt     => 'Disabled',
 			strpool => 'false',
 			runtime => 'MultiThreadedDebugDLL' });
 	$self->WriteItemDefinitionGroup(
 		$f,
 		'Release',
-		{   defs    => "$use_32bit_time_t",
+		{   defs    => "",
 			opt     => 'Full',
 			strpool => 'true',
 			runtime => 'MultiThreadedDLL' });
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index a7e3a014d7a7a6b08e65f42215f3ec8cb32a4c69..c2e7f250973cb74da1c76d596f13b83835b4d81f 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -522,14 +522,15 @@ sub mkvcbuild
 		my @perl_embed_ccflags;
 		foreach my $f (split(" ",$Config{ccflags}))
 		{
-			if ($f =~ /^-D[^_]/)
+			if ($f =~ /^-D[^_]/ ||
+			    $f =~ /^-D_USE_32BIT_TIME_T/)
 			{
 				$f =~ s/\-D//;
 				push(@perl_embed_ccflags, $f);
 			}
 		}
 
-		# XXX this probably is redundant now?
+		# Also, a hack to prevent duplicate definitions of uid_t/gid_t
 		push(@perl_embed_ccflags, 'PLPERL_HAVE_UID_GID');
 
 		foreach my $f (@perl_embed_ccflags)
diff --git a/src/tools/msvc/VCBuildProject.pm b/src/tools/msvc/VCBuildProject.pm
index a8d75d88f316d9d264d8cdcafed6bc8e90f13da4..669ba1730bcaa0c2a97339fb464736cbfddd34ed 100644
--- a/src/tools/msvc/VCBuildProject.pm
+++ b/src/tools/msvc/VCBuildProject.pm
@@ -33,15 +33,9 @@ sub WriteHeader
  <Configurations>
 EOF
 
-	# We have to use this flag on 32 bit targets because the 32bit perls
-	# are built with it and sometimes crash if we don't.
-	my $use_32bit_time_t =
-	  $self->{platform} eq 'Win32' ? '_USE_32BIT_TIME_T;' : '';
-
-
 	$self->WriteConfiguration(
 		$f, 'Debug',
-		{   defs     => "_DEBUG;DEBUG=1;$use_32bit_time_t",
+		{   defs     => "_DEBUG;DEBUG=1",
 			wholeopt => 0,
 			opt      => 0,
 			strpool  => 'false',
@@ -49,7 +43,7 @@ EOF
 	$self->WriteConfiguration(
 		$f,
 		'Release',
-		{   defs     => "$use_32bit_time_t",
+		{   defs     => "",
 			wholeopt => 0,
 			opt      => 3,
 			strpool  => 'true',