(a) I found that winsup/cygwin/mkimport specified non-existent file names as 
arguments to objcopy invocations.  I am not sure why this did not cause build 
breaks earlier.

(b) It appears perl 5.6 and, possibly, perl 5.10 do not implement the "list 
form of pipe" in calls to "open()",

  open $my_fd, '-|', $cmd, $arg1, $arg2

I got around that by using regular pipes.

(c) The Windows native build of perl wrapped into a cygpath-translating script 
/usr/bin/perl will require protection of drive letters when using a regex in 
speclib.  I believe this change may still work with Cygwin builds of perl.

I am not aware of the purpose of the two scripts that I modified, but the fixes 
made my build succeed.

-- 


==================================================
$ cat /usr/bin/perl
#! /bin/bash
args=()
for f ; do
    if [ -f "${f}" ] ; then
        f=$(cygpath -w "${f}")
        f="${f#\\\\\?\\}"
    fi
    args+=("${f}")
done
set -x
exec /c/NATIVEPERL/perl.exe -Ic:/NATIVEPERL/lib "${ar...@]}"
==================================================
Index: speclib
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/speclib,v
retrieving revision 1.24
diff -d -u -r1.24 speclib
--- speclib     30 Nov 2009 15:40:23 -0000      1.24
+++ speclib     23 Feb 2010 23:18:37 -0000
@@ -13,7 +13,7 @@
 
 my ($ar, $as, $nm, $objcopy);
 GetOptions('exclude=s'=>\...@exclude, 'static!'=>\$static, 'v!'=>\$inverse,
-          'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
+           'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
 
 $_ = File::Spec->rel2abs($_) for @ARGV;
 
@@ -22,8 +22,11 @@
 (my $iname = basename $lib) =~ s/\.a$//o;
 $iname = '_' . $iname . '_dll_iname';
 
-open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', @ARGV, $libdll or
-  die "$0: execution of $nm for object files failed - $!\n";
+my $qargs = join(" ", map("\"$_\"", @ARGV));
+my $cmd_nm = "$nm -Apg --defined-only $qargs \"$libdll\"";
+print "Reading from $cmd_nm ...\n";
+open my $nm_fd, "$cmd_nm |" or
+  die "E: $0: $cmd_nm:\n$!\n";
 
 my %match_syms = ();
 my $symfiles = ();
@@ -35,44 +38,47 @@
 while (<$nm_fd>) {
     study;
     if (/ I _(.*)_dll_iname/o) {
-       $dllname = $1;
+        $dllname = $1;
     } else {
-       my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o;
-       next if !defined($symbol) || $symbol =~ $exclude_regex;
-       if ($file ne $libdll) {
-            $match_syms{$symbol} = 1;
-        } elsif ($match_syms{$symbol} ? !$inverse : $inverse) {
-            $extract{$member} = 1;
-        }
+        my ($file, $member, $symbol) = m%^(.*?(?!:\\)):([^:]*:)?[0-9a-fA-F]{8} 
T (.*)%o;
+        next if !defined($symbol) || $symbol =~ $exclude_regex;
+        if ($file ne $libdll) {
+            $match_syms{$symbol} = 1;
+        } elsif ($match_syms{$symbol} ? !$inverse : $inverse) {
+            chop($member);
+            $extract{$member} = 1;
+        }
     }
 }
 close $nm_fd;
    
-
-%extract or die "$0: couldn't find symbols for $lib\n";
+%extract or die "E: $0: couldn't find symbols for $lib\n";
 
 my $dir = tempdir(CLEANUP => 1);
 
 chdir $dir;
 # print join(' ', '+', $ar, 'x', sort keys %extract), "\n";
 my $res = system $ar, 'x', $libdll, sort keys %extract;
-die "$0: $ar extraction exited with non-zero status\n" if $res;
+die "E: $0: $ar extraction exited with non-zero status\n" if $res;
 unlink $lib;
 
 # Add a dummy .idata object for libtool so that it will think
 # this library is an import library.
 my $iname_o = 'd000000.o';
 $extract{$iname_o} = 1;
-open my $as_fd, '|-', $as, '-R', '-o', $iname_o, "-";
+my $cmd_as = "$as -R -o $iname_o -";
+print "Writing to $cmd_as ...\n";
+open my $as_fd, "| $cmd_as" or die "E: $0: $cmd_as:\n$!\n";
 print $as_fd <<EOF;
-       .section .idata\$7
+        .section .idata\$7
 .global $iname
 $iname: .asciz "$dllname.dll"
 EOF
 close $as_fd or exit 1;
-system $objcopy, '-j', '.idata$7', $iname_o;
+system $objcopy, '-j', '.idata$7', $iname_o and die "E: $0: $objcopy:\n$!\n";
 
 $res = system $ar, 'crus', $lib, sort keys %extract;
 unlink keys %extract;
-die "$0: ar creation of $lib exited with non-zero status\n" if $res;
+die "E: $0: ar creation of $lib exited with non-zero status\n" if $res;
 exit 0;
+
Index: speclib
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/speclib,v
retrieving revision 1.24
diff -d -u -w -r1.24 speclib
--- speclib     30 Nov 2009 15:40:23 -0000      1.24
+++ speclib     23 Feb 2010 23:18:32 -0000
@@ -22,8 +22,11 @@
 (my $iname = basename $lib) =~ s/\.a$//o;
 $iname = '_' . $iname . '_dll_iname';
 
-open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', @ARGV, $libdll or
-  die "$0: execution of $nm for object files failed - $!\n";
+my $qargs = join(" ", map("\"$_\"", @ARGV));
+my $cmd_nm = "$nm -Apg --defined-only $qargs \"$libdll\"";
+print "Reading from $cmd_nm ...\n";
+open my $nm_fd, "$cmd_nm |" or
+  die "E: $0: $cmd_nm:\n$!\n";
 
 my %match_syms = ();
 my $symfiles = ();
@@ -37,42 +40,45 @@
     if (/ I _(.*)_dll_iname/o) {
        $dllname = $1;
     } else {
-       my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o;
+        my ($file, $member, $symbol) = m%^(.*?(?!:\\)):([^:]*:)?[0-9a-fA-F]{8} 
T (.*)%o;
        next if !defined($symbol) || $symbol =~ $exclude_regex;
        if ($file ne $libdll) {
             $match_syms{$symbol} = 1;
         } elsif ($match_syms{$symbol} ? !$inverse : $inverse) {
+            chop($member);
             $extract{$member} = 1;
         }
     }
 }
 close $nm_fd;
    
-
-%extract or die "$0: couldn't find symbols for $lib\n";
+%extract or die "E: $0: couldn't find symbols for $lib\n";
 
 my $dir = tempdir(CLEANUP => 1);
 
 chdir $dir;
 # print join(' ', '+', $ar, 'x', sort keys %extract), "\n";
 my $res = system $ar, 'x', $libdll, sort keys %extract;
-die "$0: $ar extraction exited with non-zero status\n" if $res;
+die "E: $0: $ar extraction exited with non-zero status\n" if $res;
 unlink $lib;
 
 # Add a dummy .idata object for libtool so that it will think
 # this library is an import library.
 my $iname_o = 'd000000.o';
 $extract{$iname_o} = 1;
-open my $as_fd, '|-', $as, '-R', '-o', $iname_o, "-";
+my $cmd_as = "$as -R -o $iname_o -";
+print "Writing to $cmd_as ...\n";
+open my $as_fd, "| $cmd_as" or die "E: $0: $cmd_as:\n$!\n";
 print $as_fd <<EOF;
        .section .idata\$7
 .global $iname
 $iname: .asciz "$dllname.dll"
 EOF
 close $as_fd or exit 1;
-system $objcopy, '-j', '.idata$7', $iname_o;
+system $objcopy, '-j', '.idata$7', $iname_o and die "E: $0: $objcopy:\n$!\n";
 
 $res = system $ar, 'crus', $lib, sort keys %extract;
 unlink keys %extract;
-die "$0: ar creation of $lib exited with non-zero status\n" if $res;
+die "E: $0: ar creation of $lib exited with non-zero status\n" if $res;
 exit 0;
+
Index: mkimport
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/mkimport,v
retrieving revision 1.3
diff -d -u -r1.3 mkimport
--- mkimport    18 Apr 2009 17:23:45 -0000      1.3
+++ mkimport    23 Feb 2010 23:25:12 -0000
@@ -3,6 +3,9 @@
 use File::Temp qw'tempdir';
 use File::Spec;
 use Getopt::Long;
+
+$| = 1;
+
 my $dir = tempdir(CLEANUP => 1);
 
 my ($ar, $as, $nm, $objcopy, %replace);
@@ -18,7 +21,9 @@
 my $libdll = shift;
 my $inpdll = shift;
 
-open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
+my $cmd_nm = "$nm -Apg --defined-only \"$inpdll\"";
+print "Reading from $cmd_nm ...\n";
+open my $nm_fd, "$cmd_nm |" or die "E: $0: $cmd_nm:\n$!\n";
 my %text = ();
 my %import = ();
 my %symfile = ();
@@ -36,8 +41,8 @@
     my $fn;
     my $_sym = '_' . $sym;
     if (!defined($fn = $symfile{$_sym})) {
-       $fn = "$sym.o";
-       $text{$fn} = $_sym;
+        $fn = "$sym.o";
+        $text{$fn} = $_sym;
     }
     my $imp_sym = '__imp__' . $replace{$sym};
     $import{$fn} = $imp_sym;
@@ -47,33 +52,39 @@
     my $imp_sym = delete $import{$f};
     my $glob_sym = $text{$f};
     if (!defined $imp_sym) {
-       delete $text{$f};
+        delete $text{$f};
     } elsif ($imp_sym eq '__imp__') {
-       $text{$f} = 0;
+        $text{$f} = 0;
     } else {
-       $text{$f} = 1;
-       open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
-       print $as_fd <<EOF;
-       .text
-       .extern $imp_sym
-       .global $glob_sym
+        $text{$f} = 1;
+        my $cmd_as = "$as -o \"$dir/t-$f\" -";
+        print "Writing to $cmd_as ...\n";
+        open my $as_fd, "| $cmd_as" or die "E: $0: $cmd_as:\n$!\n";
+        print $as_fd <<EOF;
+        .text
+        .extern $imp_sym
+        .global $glob_sym
 $glob_sym:
-       jmp     *$imp_sym
+        jmp     *$imp_sym
 EOF
-       close $as_fd or exit 1;
+        close $as_fd or exit 1;
     }
 }
 
-chdir $dir or die "$0: couldn't cd to $dir - $!\n";
+print "cd $dir\n";
+chdir $dir or die "E: $0: couldn't cd to $dir - $!\n";
+print "$ar x $inpdll\n";
 system $ar, 'x', $inpdll;
 exit 1 if $?;
 
 for my $f (keys %text) {
     if (!$text{$f}) {
-       unlink $f;
+        unlink $f;
     } else {
-       system $objcopy, '-R', '.text', $f and exit 1;
-       system $objcopy, '-R', '.bss', '-R', '.data', "t-$f" and exit 1;
+        print "$objcopy -R .text t-$f\n";
+        system ( $objcopy, '-R', '.text', "t-$f" ) and die "E: $0: objcopy -R 
.text t-$f:\n$!\n";
+        print "$objcopy -R .bss -R .data t-$f\n";
+        system ( $objcopy, '-R', '.bss', '-R', '.data', "t-$f" ) and die "E: 
$0: objcopy -R .bss -R .data t-$f:\n$!\n";
     }
 }
 
@@ -81,3 +92,4 @@
 system $ar, 'crus', $libdll, glob('*.o'), @ARGV;
 unlink glob('*.o');
 exit 1 if $?;
+
Index: mkimport
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/mkimport,v
retrieving revision 1.3
diff -d -u -w -r1.3 mkimport
--- mkimport    18 Apr 2009 17:23:45 -0000      1.3
+++ mkimport    23 Feb 2010 23:25:09 -0000
@@ -3,6 +3,9 @@
 use File::Temp qw'tempdir';
 use File::Spec;
 use Getopt::Long;
+
+$| = 1;
+
 my $dir = tempdir(CLEANUP => 1);
 
 my ($ar, $as, $nm, $objcopy, %replace);
@@ -18,7 +21,9 @@
 my $libdll = shift;
 my $inpdll = shift;
 
-open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
+my $cmd_nm = "$nm -Apg --defined-only \"$inpdll\"";
+print "Reading from $cmd_nm ...\n";
+open my $nm_fd, "$cmd_nm |" or die "E: $0: $cmd_nm:\n$!\n";
 my %text = ();
 my %import = ();
 my %symfile = ();
@@ -52,7 +57,9 @@
        $text{$f} = 0;
     } else {
        $text{$f} = 1;
-       open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
+        my $cmd_as = "$as -o \"$dir/t-$f\" -";
+        print "Writing to $cmd_as ...\n";
+        open my $as_fd, "| $cmd_as" or die "E: $0: $cmd_as:\n$!\n";
        print $as_fd <<EOF;
        .text
        .extern $imp_sym
@@ -64,7 +71,9 @@
     }
 }
 
-chdir $dir or die "$0: couldn't cd to $dir - $!\n";
+print "cd $dir\n";
+chdir $dir or die "E: $0: couldn't cd to $dir - $!\n";
+print "$ar x $inpdll\n";
 system $ar, 'x', $inpdll;
 exit 1 if $?;
 
@@ -72,8 +81,10 @@
     if (!$text{$f}) {
        unlink $f;
     } else {
-       system $objcopy, '-R', '.text', $f and exit 1;
-       system $objcopy, '-R', '.bss', '-R', '.data', "t-$f" and exit 1;
+        print "$objcopy -R .text t-$f\n";
+        system ( $objcopy, '-R', '.text', "t-$f" ) and die "E: $0: objcopy -R 
.text t-$f:\n$!\n";
+        print "$objcopy -R .bss -R .data t-$f\n";
+        system ( $objcopy, '-R', '.bss', '-R', '.data', "t-$f" ) and die "E: 
$0: objcopy -R .bss -R .data t-$f:\n$!\n";
     }
 }
 
@@ -81,3 +92,4 @@
 system $ar, 'crus', $libdll, glob('*.o'), @ARGV;
 unlink glob('*.o');
 exit 1 if $?;
+
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to