Skip to content

Commit 697eaf8

Browse files
kenneth-olwingtonycoz
authored andcommitted
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.
1 parent f58ed7c commit 697eaf8

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ Keith Thompson <keith.s.thompson@gmail.com> Keith Thompson <kst@mib.org>
495495
Ken Neighbors <unknown> Ken Neighbors <perlbug@perl.org>
496496
Ken Williams <ken@mathforum.org> <kenahoo@gmail.com>
497497
Ken Williams <ken@mathforum.org> Ken Williams <ken.williams@thomsonreuters.com>
498+
Kenneth Ölwing <knth@cpan.org> Kenneth Olwing <knth@cpan.org>
498499
Kent Fredric <kentfredric@gmail.com> Kent Fredric <kentnl@cpan.org>
499500
Kevin Brintnall <kbrint@rufus.net> kevin brintnall <kbrint@rufus.net>
500501
Kevin Ryde <user42@zip.com.au> Kevin Ryde <perlbug-followup@perl.org>

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ Ken Williams <ken@mathforum.org>
783783
Kenichi Ishigaki <ishigaki@cpan.org>
784784
Kenneth Albanowski <kjahds@kjahds.com>
785785
Kenneth Duda <kjd@cisco.com>
786+
Kenneth Ölwing <knth@cpan.org>
786787
Kent Fredric <kentfredric@gmail.com>
787788
Keong Lim <Keong.Lim@sr.com.au>
788789
Kevin Brintnall <kbrint@rufus.net>

ext/Errno/Errno_pm.PL

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
22
use Config;
33
use strict;
44

5-
our $VERSION = "1.36";
5+
our $VERSION = "1.37";
66

77
my %err = ();
88

@@ -18,18 +18,11 @@ if ($Config{gccversion} ne '' && $^O eq 'MSWin32') {
1818
# MinGW complains "warning: #pragma system_header ignored outside include
1919
# file" if the header files are processed individually, so include them
2020
# all in .c file and process that instead.
21-
my %seen;
2221
open INCS, '>', 'includes.c' or
2322
die "Cannot open includes.c";
2423
foreach $file (@files) {
2524
next if $file eq 'errno.c';
2625
next unless -f $file;
27-
if ( $file eq 'avx512vpopcntdqvlintrin.h' || $file eq 'avx512bwintrin.h' ) {
28-
# "Never use <avx512bwintrin.h> directly; include <immintrin.h> instead."
29-
# "Never use <avx512vpopcntdqvlintrin.h> directly; include <immintrin.h> instead."
30-
$file = 'immintrin.h';
31-
}
32-
next if ++$seen{$file} > 1;
3326
print INCS qq[#include "$file"\n];
3427
}
3528
close INCS;
@@ -114,7 +107,7 @@ sub default_cpp {
114107
}
115108

116109
sub get_files {
117-
my %file = ();
110+
my @file;
118111
# When cross-compiling we may store a path for gcc's "sysroot" option:
119112
my $sysroot = $Config{sysroot} || '';
120113
my $linux_errno_h;
@@ -128,34 +121,34 @@ sub get_files {
128121

129122
# VMS keeps its include files in system libraries
130123
if ($^O eq 'VMS') {
131-
$file{'Sys$Library:DECC$RTLDEF.TLB'} = 1;
124+
push(@file, 'Sys$Library:DECC$RTLDEF.TLB');
132125
} elsif ($^O eq 'os390') {
133126
# OS/390 C compiler doesn't generate #file or #line directives
134127
# and it does not tag the header as 1047 (EBCDIC), so make a local
135128
# copy and tag it
136129
my $cp = `cp /usr/include/errno.h ./errno.h`;
137130
my $chtag = `chtag -t -cIBM-1047 ./errno.h`;
138-
$file{'./errno.h'} = 1;
131+
push(@file, './errno.h');
139132
} elsif ($Config{archname} eq 'arm-riscos') {
140133
# Watch out for cross compiling for RISC OS
141134
my $dep = `echo "#include <errno.h>" | gcc -E -M -`;
142135
if ($dep =~ /(\S+errno\.h)/) {
143-
$file{$1} = 1;
136+
push(@file, $1);
144137
}
145138
} elsif ($^O eq 'linux' &&
146139
$Config{gccversion} ne '' &&
147140
$Config{gccversion} !~ /intel/i &&
148141
# might be using, say, Intel's icc
149142
$linux_errno_h
150143
) {
151-
$file{$linux_errno_h} = 1;
144+
push(@file, $linux_errno_h);
152145
} elsif ($^O eq 'haiku') {
153146
# hidden in a special place
154-
$file{'/boot/system/develop/headers/posix/errno.h'} = 1;
147+
push(@file, '/boot/system/develop/headers/posix/errno.h');
155148

156149
} elsif ($^O eq 'vos') {
157150
# avoid problem where cpp returns non-POSIX pathnames
158-
$file{'/system/include_library/errno.h'} = 1;
151+
push(@file, '/system/include_library/errno.h');
159152
} else {
160153
open(CPPI, '>', 'errno.c') or
161154
die "Cannot open errno.c";
@@ -183,16 +176,28 @@ sub get_files {
183176
if (/$pat/o) {
184177
my $f = $1;
185178
$f =~ s,\\\\,/,g;
186-
$file{$f} = 1;
179+
push(@file, $f);
187180
}
188181
}
189182
else {
190-
$file{$1} = 1 if /$pat/o;
183+
push(@file, $1) if /$pat/o;
191184
}
192185
}
193186
close(CPPO);
194187
}
195-
return keys %file;
188+
return uniq(@file);
189+
}
190+
191+
#
192+
#
193+
sub uniq
194+
{
195+
# At this point List::Util::uniq appears not to be usable so
196+
# roll our own.
197+
#
198+
# Returns a list with unique values, while keeping the order
199+
#
200+
return do { my %seen; grep { !$seen{$_}++ } @_ };
196201
}
197202

198203
sub write_errno_pm {
@@ -364,7 +369,7 @@ ESQ
364369

365370
if ($IsMSWin32) {
366371
print " WINSOCK => [qw(\n";
367-
$k = join(" ", grep { /^WSAE/ } keys %err);
372+
$k = join(" ", grep { /^WSAE/ } sort keys %err);
368373
$k =~ s/(.{50,70})\s/$1\n\t/g;
369374
print "\t",$k,"\n )],\n";
370375
}

0 commit comments

Comments
 (0)