4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-16 11:31:00 +08:00
Patrick Bendorf 5b88b62562 ccwrap: fix build with non-english locale set
short explanation: after setting up cygwin on my systems the default
locale is set to "de_DE.UTF-8". this leads to ccwrap not picking up
certain "-isystem" arguments, which in turn leads to "stddef.h: no such
file or directory". this breaks the build process for systems having non
english locale.

ccwrap scans the output of the first compiler invocation (line 21) for
some specific english output on and around line 43.

i changed the patch to check uname -o for cygwin string and set the
locale to either C or C.UTF-8
2016-02-29 13:56:03 +01:00

61 lines
1.7 KiB
Perl
Executable File

#!/usr/bin/perl
use Cwd;
use strict;
my $cxx;
my $ccorcxx;
if ($ARGV[0] ne '++') {
$ccorcxx = 'CC';
$cxx = 0;
} else {
shift @ARGV;
$ccorcxx = 'CXX';
$cxx = 1;
}
die "$0: $ccorcxx environment variable does not exist\n" unless exists $ENV{$ccorcxx};
if (`uname -o` =~ /cygwin/i) {
$ENV{'LANG'} = 'C.UTF-8';
} else {
$ENV{'LANG'} = 'C';
}
my @compiler = split ' ', $ENV{$ccorcxx};
if ("@ARGV" !~ / -nostdinc/o) {
my $fd;
push @compiler, ($cxx ? '-xc++' : '-xc');
if (!open $fd, '-|') {
open STDERR, '>&', \*STDOUT;
exec @compiler, '/dev/null', '-v', '-E', '-o', '/dev/null' or die "*** error execing $compiler[0] - $!\n";
}
$compiler[1] =~ s/xc/nostdinc/o;
push @compiler, '-nostdinc' if $cxx;
push @compiler, '-I' . $_ for split ' ', $ENV{CCWRAP_HEADERS};
push @compiler, '-isystem', $_ for split ' ', $ENV{CCWRAP_SYSTEM_HEADERS};
my $finding_paths = 0;
my $mingw_compiler = $compiler[0] =~ /mingw/o;
my @dirafters;
for my $d (split ' ', $ENV{CCWRAP_DIRAFTER_HEADERS}) {
push @dirafters, '-isystem', $d if !$mingw_compiler || $d !~ /w32api/o;
}
while (<$fd>) {
if (/^\*\*\*/o) {
print;
} elsif ($_ eq "#include <...> search starts here:\n") {
$finding_paths = 1;
} elsif (!$finding_paths) {
next;
} elsif ($_ eq "End of search list.\n") {
last;
} elsif (!@dirafters || !m%w32api|mingw.*/include%o) {
chomp;
s/^\s+//;
push @compiler, '-isystem', Cwd::abs_path($_);
}
}
push @compiler, @dirafters;
close $fd;
}
push @compiler, @ARGV;
print join(' ', '+', @compiler), "\n" if $ENV{CCWRAP_VERBOSE};
exec @compiler or die "$0: $compiler[0] failed to execute\n";