summaryrefslogtreecommitdiff
path: root/ext/Errno
diff options
context:
space:
mode:
authorKenneth Olwing <knth@cpan.org>2022-08-16 19:41:45 +0200
committerTony Cook <tony@develop-help.com>2022-08-25 11:37:34 +1000
commit697eaf802a042beb1c1c6f1983a08a147f12eb72 (patch)
tree2ab4ae13cf8dd9a85221b1f0ba18aabd071469af /ext/Errno
parentf58ed7c7a9dd599e7a924a2105851c697f4f9d87 (diff)
downloadperl-697eaf802a042beb1c1c6f1983a08a147f12eb72.tar.gz
Handle intrin files on win32 with gcc
This fixes #20033. When building on Windows with Strawberry 5.32.1 (gcc 8.3.0) as the toolchain, the Errno.pm is created by a script Errno_pm.pl, which takes output from the compiler to find headers. A subset of these headers requires them to only be included by some specific headers. Previously the header order was effectively random and this occasionally caused build errors (that further were never detected). The get_files() is now returning the header names in the order the compiler saw them which insures they are in the right order.
Diffstat (limited to 'ext/Errno')
-rw-r--r--ext/Errno/Errno_pm.PL43
1 files changed, 24 insertions, 19 deletions
diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index ee2f4a3a92..ae647d5f06 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
use Config;
use strict;
-our $VERSION = "1.36";
+our $VERSION = "1.37";
my %err = ();
@@ -18,18 +18,11 @@ if ($Config{gccversion} ne '' && $^O eq 'MSWin32') {
# MinGW complains "warning: #pragma system_header ignored outside include
# file" if the header files are processed individually, so include them
# all in .c file and process that instead.
- my %seen;
open INCS, '>', 'includes.c' or
die "Cannot open includes.c";
foreach $file (@files) {
next if $file eq 'errno.c';
next unless -f $file;
- if ( $file eq 'avx512vpopcntdqvlintrin.h' || $file eq 'avx512bwintrin.h' ) {
- # "Never use <avx512bwintrin.h> directly; include <immintrin.h> instead."
- # "Never use <avx512vpopcntdqvlintrin.h> directly; include <immintrin.h> instead."
- $file = 'immintrin.h';
- }
- next if ++$seen{$file} > 1;
print INCS qq[#include "$file"\n];
}
close INCS;
@@ -114,7 +107,7 @@ sub default_cpp {
}
sub get_files {
- my %file = ();
+ my @file;
# When cross-compiling we may store a path for gcc's "sysroot" option:
my $sysroot = $Config{sysroot} || '';
my $linux_errno_h;
@@ -128,19 +121,19 @@ sub get_files {
# VMS keeps its include files in system libraries
if ($^O eq 'VMS') {
- $file{'Sys$Library:DECC$RTLDEF.TLB'} = 1;
+ push(@file, 'Sys$Library:DECC$RTLDEF.TLB');
} elsif ($^O eq 'os390') {
# OS/390 C compiler doesn't generate #file or #line directives
# and it does not tag the header as 1047 (EBCDIC), so make a local
# copy and tag it
my $cp = `cp /usr/include/errno.h ./errno.h`;
my $chtag = `chtag -t -cIBM-1047 ./errno.h`;
- $file{'./errno.h'} = 1;
+ push(@file, './errno.h');
} elsif ($Config{archname} eq 'arm-riscos') {
# Watch out for cross compiling for RISC OS
my $dep = `echo "#include <errno.h>" | gcc -E -M -`;
if ($dep =~ /(\S+errno\.h)/) {
- $file{$1} = 1;
+ push(@file, $1);
}
} elsif ($^O eq 'linux' &&
$Config{gccversion} ne '' &&
@@ -148,14 +141,14 @@ sub get_files {
# might be using, say, Intel's icc
$linux_errno_h
) {
- $file{$linux_errno_h} = 1;
+ push(@file, $linux_errno_h);
} elsif ($^O eq 'haiku') {
# hidden in a special place
- $file{'/boot/system/develop/headers/posix/errno.h'} = 1;
+ push(@file, '/boot/system/develop/headers/posix/errno.h');
} elsif ($^O eq 'vos') {
# avoid problem where cpp returns non-POSIX pathnames
- $file{'/system/include_library/errno.h'} = 1;
+ push(@file, '/system/include_library/errno.h');
} else {
open(CPPI, '>', 'errno.c') or
die "Cannot open errno.c";
@@ -183,16 +176,28 @@ sub get_files {
if (/$pat/o) {
my $f = $1;
$f =~ s,\\\\,/,g;
- $file{$f} = 1;
+ push(@file, $f);
}
}
else {
- $file{$1} = 1 if /$pat/o;
+ push(@file, $1) if /$pat/o;
}
}
close(CPPO);
}
- return keys %file;
+ return uniq(@file);
+}
+
+#
+#
+sub uniq
+{
+ # At this point List::Util::uniq appears not to be usable so
+ # roll our own.
+ #
+ # Returns a list with unique values, while keeping the order
+ #
+ return do { my %seen; grep { !$seen{$_}++ } @_ };
}
sub write_errno_pm {
@@ -364,7 +369,7 @@ ESQ
if ($IsMSWin32) {
print " WINSOCK => [qw(\n";
- $k = join(" ", grep { /^WSAE/ } keys %err);
+ $k = join(" ", grep { /^WSAE/ } sort keys %err);
$k =~ s/(.{50,70})\s/$1\n\t/g;
print "\t",$k,"\n )],\n";
}