[PATCH] ccwrap: fix build with non-english locale set

mail@patrick-bendorf.de mail@patrick-bendorf.de
Mon Feb 29 12:21:00 GMT 2016


Hi Corinna,

Am 2016-02-29 11:33, schrieb Corinna Vinschen:
> Hi Patrick,
> 
> On Feb 29 08:12, Patrick Bendorf wrote:
>> /winsup/
>> * ccwrap: fix build with non-english locale set
> 
> First of all, why fix it?  Without at least a short explanation what 
> you
> observe without this patch, this change seems arbitrary.
> 
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.

consider the following two pastebins from a system with an english 
locale and mine. a whole bunch of "-isystem" can not be found on my 
system using german locale.
http://pastebin.com/ip5L7dZY
http://pastebin.com/wZBc2cqr

ccwrap scans the output of the first compiler invocation (line 21) for 
some specific english output on and around line 43.
output of first invocation on german locale system:
http://pastebin.com/ZZzVGReh

>> ---
>>  winsup/ccwrap | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/winsup/ccwrap b/winsup/ccwrap
>> index 7580e7a..ef83085 100755
>> --- a/winsup/ccwrap
>> +++ b/winsup/ccwrap
>> @@ -12,6 +12,7 @@ if ($ARGV[0] ne '++') {
>>      $cxx = 1;
>>  }
>>  die "$0: $ccorcxx environment variable does not exist\n" unless 
>> exists
>> $ENV{$ccorcxx};
>> +$ENV{'LANG'} = 'C.UTF-8';
>>  my @compiler = split ' ', $ENV{$ccorcxx};
>>  if ("@ARGV" !~ / -nostdinc/o) {
>>      my $fd;
>> --
>> 2.7.0
> 
> That won't work nicely for non-Cygwin build systems.  When cross
> building Cygwin on, e.g., Linux, "C.UTF-8" is an unrecognized locale.
> Ideally the above would test for the current build system being Cygwin
> and use "C.UTF-8" on Cygwin, "C" otherwise.
> 
thanks for pointing that out.
i changed the patch to check uname -o for cygwin string and set the 
locale to either C or C.UTF-8

---
  winsup/ccwrap | 1 +
  1 file changed, 1 insertion(+)

diff --git a/winsup/ccwrap b/winsup/ccwrap
index 7580e7a..ef83085 100755
--- a/winsup/ccwrap
+++ b/winsup/ccwrap
@@ -12,6 +12,11 @@ if ($ARGV[0] ne '++') {
      $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;
--
2.7.0

> 
> Thanks,
> Corinna



More information about the Cygwin-patches mailing list