[PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Peter Rosin
Hi!

I know it's late for the release, but I'd like to squeeze this one in
too, if at all possible. After all, it doesn't affect anything but MSVC.

With the patch, I get

sys_lib_search_path_spec=/c/PROGRA~1/MID05A~1/VC/ATLMFC/LIB 
/c/PROGRA~1/MID05A~1/VC/LIB /c/PROGRA~1/MID05A~1/VC/PLATFO~1/lib 
/c/PROGRA~1/MID05A~1/SDK/v2.0/lib

on MSYS/MSVC, and

sys_lib_search_path_spec=/cygdrive/c/PROGRA~1/MID05A~1/VC/ATLMFC/LIB 
/cygdrive/c/PROGRA~1/MID05A~1/VC/LIB 
/cygdrive/c/PROGRA~1/MID05A~1/VC/PLATFO~1/lib 
/cygdrive/c/PROGRA~1/MID05A~1/SDK/v2.0/lib

on Cygwin/MSVC, which is a whole lot better than what was there before,
namely this for both

sys_lib_search_path_spec=C:\Program Files\Microsoft Visual Studio 
8\VC\ATLMFC\LIB C:\Program Files\Microsoft Visual Studio 8\VC\LIB C:\Program 
Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib C:\Program Files\Microsoft 
Visual Studio 8\SDK\v2.0\lib

which simply isn't any good at all.

If this patch is included it means that I can remove tiresome workarounds
when linking with system libraries.

This needs testsuite exposure, and search-path.at seems to come close,
but is not up to the task. Not even if I extend it to try some other
system library such as -luser32 if -lz isn't found.

So, ok to push even if it's late and without testsuite coverage?

Cheers,
Peter

From 6292de4810a69f5debc89d714df0db580e684eef Mon Sep 17 00:00:00 2001
From: Peter Rosin p...@lysator.liu.se
Date: Tue, 21 Sep 2010 09:30:07 +0200
Subject: [PATCH] msvc: eliminate spaces in the library search path.

* libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
cl*, sys_lib_search_path_spec: The LIB path variable telling
where MSVC looks for libraries is with high probably containing
directory names with spaces.  Convert those directory names to
the short 8.3 dos form (i.e. without spaces) when storing them
in sys_lib_search_path_spec, as that is a space separated
variable.

Signed-off-by: Peter Rosin p...@lysator.liu.se
---
 ChangeLog |   11 +++
 libltdl/m4/libtool.m4 |   49 -
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ceb193c..f32a59a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-21  Peter Rosin  p...@lysator.liu.se
+
+   msvc: eliminate spaces in the library search path.
+   * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
+   cl*, sys_lib_search_path_spec: The LIB path variable telling
+   where MSVC looks for libraries is with high probably containing
+   directory names with spaces.  Convert those directory names to
+   the short 8.3 dos form (i.e. without spaces) when storing them
+   in sys_lib_search_path_spec, as that is a space separated
+   variable.
+
 2010-09-20  Eric Blake  ebl...@redhat.com
 
maint: drop autobuild requirement
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index a8b07bf..534e912 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2313,15 +2313,46 @@ m4_if([$1], [],[
 libname_spec='$name'
 soname_spec='${libname}`echo ${release} | $SED -e 
's/[[.]]/-/g'`${versuffix}${shared_ext}'
 library_names_spec='${libname}.dll.lib'
-sys_lib_search_path_spec=$LIB
-if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' /dev/null]; 
then
-  # It is most probably a Windows format PATH.
-  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
's/;/ /g'`
-else
-  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
s/$PATH_SEPARATOR/ /g`
-fi
-# FIXME: find the short name or the path components, as spaces are
-# common. (e.g. Program Files - PROGRA~1)
+
+case $build_os in
+mingw*)
+  sys_lib_search_path_spec=
+  lt_save_ifs=$IFS
+  # Doesn't work to have IFS=; so select some other char that is
+  # invalid in w32 file names.
+  IFS=?
+  for lt_path in `echo $LIB | tr ';' '?'`
+  do
+IFS=$lt_save_ifs
+# Let DOS variable expansion print the short 8.3 style file name.
+lt_path=`cd $lt_path  cmd //C for %i in (.) do @echo %~si`
+sys_lib_search_path_spec=$sys_lib_search_path_spec $lt_path
+  done
+  IFS=$lt_save_ifs
+  # Convert to MSYS style.
+  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | sed -e 
's||/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+  ;;
+cygwin*)
+  # Convert to unix form, then to dos form, then back to unix form
+  # but this time dos style (no spaces!) so that the unix form looks
+  # like /cygdrive/c/PROGRA~1:/cygdr...
+  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
+  sys_lib_search_path_spec=`cygpath --path --dos 
$sys_lib_search_path_spec`
+  sys_lib_search_path_spec=`cygpath --path --unix 
$sys_lib_search_path_spec | $SED -e s/$PATH_SEPARATOR/ /g`
+  ;;
+*)
+  sys_lib_search_path_spec=$LIB
+  if $ECHO

Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Peter Rosin
Den 2010-09-21 09:37 skrev Peter Rosin:
 I know it's late for the release, but I'd like to squeeze this one in
 too, if at all possible. After all, it doesn't affect anything but MSVC.
 
 With the patch, I get
 
 sys_lib_search_path_spec=/c/PROGRA~1/MID05A~1/VC/ATLMFC/LIB 
 /c/PROGRA~1/MID05A~1/VC/LIB /c/PROGRA~1/MID05A~1/VC/PLATFO~1/lib 
 /c/PROGRA~1/MID05A~1/SDK/v2.0/lib
 
 on MSYS/MSVC, and
 
 sys_lib_search_path_spec=/cygdrive/c/PROGRA~1/MID05A~1/VC/ATLMFC/LIB 
 /cygdrive/c/PROGRA~1/MID05A~1/VC/LIB 
 /cygdrive/c/PROGRA~1/MID05A~1/VC/PLATFO~1/lib 
 /cygdrive/c/PROGRA~1/MID05A~1/SDK/v2.0/lib
 
 on Cygwin/MSVC, which is a whole lot better than what was there before,
 namely this for both
 
 sys_lib_search_path_spec=C:\Program Files\Microsoft Visual Studio 
 8\VC\ATLMFC\LIB C:\Program Files\Microsoft Visual Studio 8\VC\LIB C:\Program 
 Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib C:\Program Files\Microsoft 
 Visual Studio 8\SDK\v2.0\lib
 
 which simply isn't any good at all.

FYI, I just guessed what the prior content was (I was in a bit of a rush
for some reason). Now I have checked what it really was, which is a wee bit
worse than I thought:

sys_lib_search_path_spec=C Program FilesMicrosoft Visual Studio 
8VCATLMFCLIB;C Program FilesMicrosoft Visual Studio 
8VCLIB;C Program FilesMicrosoft Visual Studio 
8VCPlatformSDKlib;C Program FilesMicrosoft Visual Studio 
8SDKv2.0lib

I copy-pasted the content for the cases with the patch applied so those
were correct from the start.

Cheers,
Peter



Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Ralf Wildenhues
Hi Peter,

* Peter Rosin wrote on Tue, Sep 21, 2010 at 09:37:16AM CEST:
 I know it's late for the release, but I'd like to squeeze this one in
 too, if at all possible. After all, it doesn't affect anything but MSVC.

I have questions:

What does Charles have to say to this?

What is $LIB?  Is this an API you just made up?  If not, where is it
documented?  Hmm, we used it before, so I guess that's not new.

 Subject: [PATCH] msvc: eliminate spaces in the library search path.
 
 * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
 cl*, sys_lib_search_path_spec: The LIB path variable telling
 where MSVC looks for libraries is with high probably containing

s/probably/probability/  ?  If yes, I'd rather write is likely to
contain ...

 directory names with spaces.  Convert those directory names to
 the short 8.3 dos form (i.e. without spaces) when storing them

DOS

 in sys_lib_search_path_spec, as that is a space separated
 variable.

 --- a/libltdl/m4/libtool.m4
 +++ b/libltdl/m4/libtool.m4
 @@ -2313,15 +2313,46 @@ m4_if([$1], [],[
  libname_spec='$name'
  soname_spec='${libname}`echo ${release} | $SED -e 
 's/[[.]]/-/g'`${versuffix}${shared_ext}'
  library_names_spec='${libname}.dll.lib'
 -sys_lib_search_path_spec=$LIB
 -if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' /dev/null]; 
 then
 -  # It is most probably a Windows format PATH.
 -  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
 's/;/ /g'`
 -else
 -  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
 s/$PATH_SEPARATOR/ /g`
 -fi
 -# FIXME: find the short name or the path components, as spaces are
 -# common. (e.g. Program Files - PROGRA~1)
 +
 +case $build_os in
 +mingw*)
 +  sys_lib_search_path_spec=
 +  lt_save_ifs=$IFS
 +  # Doesn't work to have IFS=; so select some other char that is
 +  # invalid in w32 file names.
 +  IFS=?
 +  for lt_path in `echo $LIB | tr ';' '?'`

You should use the fix that you discovered.

 +  do
 +IFS=$lt_save_ifs
 +# Let DOS variable expansion print the short 8.3 style file name.
 +lt_path=`cd $lt_path  cmd //C for %i in (.) do @echo %~si`

Can you explain what this command does?  I mean, no need to change the
patch, but I don't understand the %~si syntax and I can only infer the
%i and (...) bits, but can't tell whether they are correct, work by
accident, or something else.  I'm willing to believe you, but it would
be nice to know for sure.

Can the command fail?

 +sys_lib_search_path_spec=$sys_lib_search_path_spec $lt_path
 +  done
 +  IFS=$lt_save_ifs
 +  # Convert to MSYS style.
 +  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | sed -e 
 's||/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
 +  ;;
 +cygwin*)
 +  # Convert to unix form, then to dos form, then back to unix form
 +  # but this time dos style (no spaces!) so that the unix form looks
 +  # like /cygdrive/c/PROGRA~1:/cygdr...
 +  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
 +  sys_lib_search_path_spec=`cygpath --path --dos 
 $sys_lib_search_path_spec`
 +  sys_lib_search_path_spec=`cygpath --path --unix 
 $sys_lib_search_path_spec | $SED -e s/$PATH_SEPARATOR/ /g`

Can any of the cygpath commands fail?
What about LT_CYGPATH?

 +  ;;
 +*)
 +  sys_lib_search_path_spec=$LIB
 +  if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' 
 /dev/null]; then
 +# It is most probably a Windows format PATH.
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e 's/;/ /g'`
 +  else
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e s/$PATH_SEPARATOR/ /g`
 +  fi
 +  # FIXME: find the short name or the path components, as spaces are
 +  # common. (e.g. Program Files - PROGRA~1)

Is this comment still relevant in light of the above changes?
Assuming yes, for the (*) case.

 +  ;;
 +esac
 +
  # DLL is installed to $(libdir)/../bin by postinstall_cmds
  postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 21 -c '\''. $dir/'\''\${base_file}'\''i; echo 
 \$dlname'\''`~

Thanks,
Ralf



Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Charles Wilson
On 9/21/2010 1:33 PM, Ralf Wildenhues wrote:
 Hi Peter,
 
 * Peter Rosin wrote on Tue, Sep 21, 2010 at 09:37:16AM CEST:
 I know it's late for the release, but I'd like to squeeze this one in
 too, if at all possible. After all, it doesn't affect anything but MSVC.
 
 I have questions:
 
 What does Charles have to say to this?

Well, in principle -- so long as this code is activated only when $CC is
MSVC -- the patch as revised is fine with me.

 What is $LIB?  Is this an API you just made up?  If not, where is it
 documented?  Hmm, we used it before, so I guess that's not new.

LIB and INCLUDE are MSVC's mechanisms for setting search paths; it's not
something we libtoolers picked.

 +  do
 +IFS=$lt_save_ifs
 +# Let DOS variable expansion print the short 8.3 style file name.
 +lt_path=`cd $lt_path  cmd //C for %i in (.) do @echo %~si`
 
 Can you explain what this command does?  I mean, no need to change the
 patch, but I don't understand the %~si syntax and I can only infer the
 %i and (...) bits, but can't tell whether they are correct, work by
 accident, or something else.  I'm willing to believe you, but it would
 be nice to know for sure.

See http://thread.gmane.org/gmane.comp.gnu.mingw.user/34276

 Can the command fail?

Sure -- if lt_path doesn't exist.  I don't know if that is an issue in
this particular case.  It will also fail on Win9x (where cmd.exe doesn't
exist, and command.com is supposed to be used).  However, we already
have that problem in func_convert_core_msys_to_w32.

One workaround would be to use the %COMSPEC% variable in both cases,
but...I'd rather go with cmd in both places, and then worry about
%COMSPEC% after the release, and only if we get complaints.

 +sys_lib_search_path_spec=$sys_lib_search_path_spec $lt_path
 +  done
 +  IFS=$lt_save_ifs
 +  # Convert to MSYS style.
 +  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | sed -e 
 's||/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`

Yes, sadly msys does not provide a program analogous to cygpath.  So, we
can go msys-win32 by exploiting msys's autoconvert behavior (by running
a native win32 program cmd.exe with the args to be converted).  But
we can't go the other direction -- so, fun with sed scripts.

The downside of this is that only the standard representation of paths
will be used (e.g. C:/foo - /c/foo, etc).  If there are any special
mount points defined in MSYS's /etc/fstab -- for instance

C:\PROGRA~1\MICROS~2/vizstudio

You'll get /c/PROGRA~1/MICROS~2/whatever instead of /vizstudio/whatever.
 In practice, this should make no difference -- and there really isn't
any way around it, without improvements/additions to MSYS.

 +  ;;
 +cygwin*)
 +  # Convert to unix form, then to dos form, then back to unix form
 +  # but this time dos style (no spaces!) so that the unix form looks
 +  # like /cygdrive/c/PROGRA~1:/cygdr...
 +  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
 +  sys_lib_search_path_spec=`cygpath --path --dos 
 $sys_lib_search_path_spec`
 +  sys_lib_search_path_spec=`cygpath --path --unix 
 $sys_lib_search_path_spec | $SED -e s/$PATH_SEPARATOR/ /g`
 
 Can any of the cygpath commands fail?
 What about LT_CYGPATH?

If $build_os is cygwin, then cygpath.exe IS in the $PATH (or there is
something *extremely* broken about your cygwin installation).  So, for
$build=cygwin, we can invoke cygpath directly.  LT_CYGPATH is used when
$build != cygwin, but there is a cygwin somewhere that is accessible.

We can't use the func_conv functions here, because we're (a) going
backwards in two cases, and (b) using the --dos flag instead of
--windows or --mixed even when we're going in the right direction.

 +  ;;
 +*)
 +  sys_lib_search_path_spec=$LIB
 +  if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' 
 /dev/null]; then

What if there is only a single directory in the path spec?  Then there
won't be a ';', and we'll use the else clause -- is that the right thing
to do?

 +# It is most probably a Windows format PATH.
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e 's/;/ /g'`
 +  else
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e s/$PATH_SEPARATOR/ /g`
 +  fi


--
Chuck



Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Peter Rosin
Den 2010-09-21 19:33 skrev Ralf Wildenhues:
 Hi Peter,
 
 * Peter Rosin wrote on Tue, Sep 21, 2010 at 09:37:16AM CEST:
 I know it's late for the release, but I'd like to squeeze this one in
 too, if at all possible. After all, it doesn't affect anything but MSVC.
 
 I have questions:
 
 What does Charles have to say to this?
 
 What is $LIB?  Is this an API you just made up?  If not, where is it
 documented?  Hmm, we used it before, so I guess that's not new.

MS tools use it to find libraries when linking:
http://msdn.microsoft.com/en-us/library/6y6t9esh.aspx

 Subject: [PATCH] msvc: eliminate spaces in the library search path.

 * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
 cl*, sys_lib_search_path_spec: The LIB path variable telling
 where MSVC looks for libraries is with high probably containing
 
 s/probably/probability/  ?  If yes, I'd rather write is likely to
 contain ...

Ok, I'll fix that.

 directory names with spaces.  Convert those directory names to
 the short 8.3 dos form (i.e. without spaces) when storing them
 
 DOS

Ok.

 in sys_lib_search_path_spec, as that is a space separated
 variable.
 
 --- a/libltdl/m4/libtool.m4
 +++ b/libltdl/m4/libtool.m4
 @@ -2313,15 +2313,46 @@ m4_if([$1], [],[
  libname_spec='$name'
  soname_spec='${libname}`echo ${release} | $SED -e 
 's/[[.]]/-/g'`${versuffix}${shared_ext}'
  library_names_spec='${libname}.dll.lib'
 -sys_lib_search_path_spec=$LIB
 -if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' 
 /dev/null]; then
 -  # It is most probably a Windows format PATH.
 -  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
 's/;/ /g'`
 -else
 -  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
 s/$PATH_SEPARATOR/ /g`
 -fi
 -# FIXME: find the short name or the path components, as spaces are
 -# common. (e.g. Program Files - PROGRA~1)
 +
 +case $build_os in
 +mingw*)
 +  sys_lib_search_path_spec=
 +  lt_save_ifs=$IFS
 +  # Doesn't work to have IFS=; so select some other char that is
 +  # invalid in w32 file names.
 +  IFS=?
 +  for lt_path in `echo $LIB | tr ';' '?'`
 
 You should use the fix that you discovered.

Indeed.

 +  do
 +IFS=$lt_save_ifs
 +# Let DOS variable expansion print the short 8.3 style file name.
 +lt_path=`cd $lt_path  cmd //C for %i in (.) do @echo %~si`
 
 Can you explain what this command does?  I mean, no need to change the
 patch, but I don't understand the %~si syntax and I can only infer the
 %i and (...) bits, but can't tell whether they are correct, work by
 accident, or something else.  I'm willing to believe you, but it would
 be nice to know for sure.

Page 5 in this document may give you a hint:
http://www.kohnos.net/files/cmd-quickshots.pdf

Loop around the files in the (.) list, i.e. the current dir (not the content
of the current dir), and echo full path which short names.

 Can the command fail?

Investigation reveals that if a component of $LIB does not exist you'd get
this on stderr:
sh: cd: C:\nowhere: No such file or directory

I'll use this instead:

+lt_path=`cd $lt_path 2/dev/null  cmd //C for %i in (.) do 
@echo %~si`

 +sys_lib_search_path_spec=$sys_lib_search_path_spec $lt_path
 +  done
 +  IFS=$lt_save_ifs
 +  # Convert to MSYS style.
 +  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | sed -e 
 's||/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
 +  ;;
 +cygwin*)
 +  # Convert to unix form, then to dos form, then back to unix form
 +  # but this time dos style (no spaces!) so that the unix form looks
 +  # like /cygdrive/c/PROGRA~1:/cygdr...
 +  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
 +  sys_lib_search_path_spec=`cygpath --path --dos 
 $sys_lib_search_path_spec`
 +  sys_lib_search_path_spec=`cygpath --path --unix 
 $sys_lib_search_path_spec | $SED -e s/$PATH_SEPARATOR/ /g`
 
 Can any of the cygpath commands fail?
 What about LT_CYGPATH?

LT_CYGPATH is for cases involving Cygwin, but when $build_os is not cygwin.
Quoting the comment in func_convert_file_cygwin_to_w32:

# because $build is cygwin, we call the cygpath in $PATH; no need to use
# LT_CYGPATH in this case.

So LT_CYGPATH does not apply here.

Investigation reveals that if $LIB has an invalid component, cygpath will not
be able to find the --dos name (2nd conversion) and will output this on stderr:
cygpath: cannot create short name of C:\nowhere
In that case, sys_lib_search_path_spec will be empty even if only one of its
components is bad.  Writing a loop to save the user in this case seems
overkill, no?

I'll use this instead:

+  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
+  sys_lib_search_path_spec=`cygpath --path --dos 
$sys_lib_search_path_spec 2/dev/null`
+  sys_lib_search_path_spec=`cygpath --path --unix 
$sys_lib_search_path_spec | $SED -e s

Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Peter Rosin
Den 2010-09-21 20:08 skrev Charles Wilson:
 On 9/21/2010 1:33 PM, Ralf Wildenhues wrote:
 * Peter Rosin wrote on Tue, Sep 21, 2010 at 09:37:16AM CEST:
 +  do
 +IFS=$lt_save_ifs
 +# Let DOS variable expansion print the short 8.3 style file name.
 +lt_path=`cd $lt_path  cmd //C for %i in (.) do @echo %~si`

 Can you explain what this command does?  I mean, no need to change the
 patch, but I don't understand the %~si syntax and I can only infer the
 %i and (...) bits, but can't tell whether they are correct, work by
 accident, or something else.  I'm willing to believe you, but it would
 be nice to know for sure.
 
 See http://thread.gmane.org/gmane.comp.gnu.mingw.user/34276
 
 Can the command fail?
 
 Sure -- if lt_path doesn't exist.  I don't know if that is an issue in
 this particular case.  It will also fail on Win9x (where cmd.exe doesn't
 exist, and command.com is supposed to be used).  However, we already
 have that problem in func_convert_core_msys_to_w32.
 
 One workaround would be to use the %COMSPEC% variable in both cases,
 but...I'd rather go with cmd in both places, and then worry about
 %COMSPEC% after the release, and only if we get complaints.

cmd in my MSYS installation is a script /bin/cmd with content:

#!/bin/sh
# Copyright (C) 2002, Earnie Boyd
#   mailto:ear...@users.sf.net
# This file is part of Minimal SYStem.
#   http://www.mingw.org/msys.shtml
# File: cmd

`echo $COMSPEC | sed -e 's##/#g'` $@

So, COMSPEC is not an issue.

 +  ;;
 +*)
 +  sys_lib_search_path_spec=$LIB
 +  if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' 
 /dev/null]; then
 
 What if there is only a single directory in the path spec?  Then there
 won't be a ';', and we'll use the else clause -- is that the right thing
 to do?

If there is no path separator, the two branches are equivalent.

 +# It is most probably a Windows format PATH.
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e 's/;/ /g'`
 +  else
 +sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED 
 -e s/$PATH_SEPARATOR/ /g`
 +  fi

Cheers,
Peter



Re: [PATCH] msvc: eliminate spaces in the library search path.

2010-09-21 Thread Peter Rosin
Den 2010-09-21 20:08 skrev Charles Wilson:
 On 9/21/2010 1:33 PM, Ralf Wildenhues wrote:
 Hi Peter,

 * Peter Rosin wrote on Tue, Sep 21, 2010 at 09:37:16AM CEST:
 I know it's late for the release, but I'd like to squeeze this one in
 too, if at all possible. After all, it doesn't affect anything but MSVC.

 I have questions:

 What does Charles have to say to this?
 
 Well, in principle -- so long as this code is activated only when $CC is
 MSVC -- the patch as revised is fine with me.

Hmm, since we were given the authority to approve w32-only patches, and
this is one of those, I think I'll make use of that and just push as below
(including the nits Ralf had).

Thanks for the speedy reviews!

Gary, I'm done with that in.  Thanks for putting up with the late changes!

Cheers,
Peter


From 09142eaeda3b3055653afc302fe871740d65d5c7 Mon Sep 17 00:00:00 2001
From: Peter Rosin p...@lysator.liu.se
Date: Tue, 21 Sep 2010 20:31:37 +0200
Subject: [PATCH] msvc: eliminate spaces in the library search path.

* libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
cl*, sys_lib_search_path_spec: The LIB path variable telling
where MSVC looks for libraries is likely to contain directory
names with spaces.  Convert those directory names to the short
8.3 DOS form (i.e. without spaces) when storing them in
sys_lib_search_path_spec, as that is a space separated variable.

Signed-off-by: Peter Rosin p...@lysator.liu.se
---
 ChangeLog |   10 ++
 libltdl/m4/libtool.m4 |   47 ++-
 2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f3dee40..e011a9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-21  Peter Rosin  p...@lysator.liu.se
+
+   msvc: eliminate spaces in the library search path.
+   * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
+   cl*, sys_lib_search_path_spec: The LIB path variable telling
+   where MSVC looks for libraries is likely to contain directory
+   names with spaces.  Convert those directory names to the short
+   8.3 DOS form (i.e. without spaces) when storing them in
+   sys_lib_search_path_spec, as that is a space separated variable.
+
 2010-09-21  Ralf Wildenhues  ralf.wildenh...@gmx.de
 
Revert to per-language libpath computation on AIX.
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 2aee398..a048b1f 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2321,15 +2321,44 @@ m4_if([$1], [],[
 libname_spec='$name'
 soname_spec='${libname}`echo ${release} | $SED -e 
's/[[.]]/-/g'`${versuffix}${shared_ext}'
 library_names_spec='${libname}.dll.lib'
-sys_lib_search_path_spec=$LIB
-if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' /dev/null]; 
then
-  # It is most probably a Windows format PATH.
-  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
's/;/ /g'`
-else
-  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
s/$PATH_SEPARATOR/ /g`
-fi
-# FIXME: find the short name or the path components, as spaces are
-# common. (e.g. Program Files - PROGRA~1)
+
+case $build_os in
+mingw*)
+  sys_lib_search_path_spec=
+  lt_save_ifs=$IFS
+  IFS=';'
+  for lt_path in $LIB
+  do
+IFS=$lt_save_ifs
+# Let DOS variable expansion print the short 8.3 style file name.
+lt_path=`cd $lt_path 2/dev/null  cmd //C for %i in (.) do 
@echo %~si`
+sys_lib_search_path_spec=$sys_lib_search_path_spec $lt_path
+  done
+  IFS=$lt_save_ifs
+  # Convert to MSYS style.
+  sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | sed -e 
's||/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+  ;;
+cygwin*)
+  # Convert to unix form, then to dos form, then back to unix form
+  # but this time dos style (no spaces!) so that the unix form looks
+  # like /cygdrive/c/PROGRA~1:/cygdr...
+  sys_lib_search_path_spec=`cygpath --path --unix $LIB`
+  sys_lib_search_path_spec=`cygpath --path --dos 
$sys_lib_search_path_spec 2/dev/null`
+  sys_lib_search_path_spec=`cygpath --path --unix 
$sys_lib_search_path_spec | $SED -e s/$PATH_SEPARATOR/ /g`
+  ;;
+*)
+  sys_lib_search_path_spec=$LIB
+  if $ECHO $sys_lib_search_path_spec | [$GREP ';[c-zC-Z]:/' /dev/null]; 
then
+# It is most probably a Windows format PATH.
+sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
's/;/ /g'`
+  else
+sys_lib_search_path_spec=`$ECHO $sys_lib_search_path_spec | $SED -e 
s/$PATH_SEPARATOR/ /g`
+  fi
+  # FIXME: find the short name or the path components, as spaces are
+  # common. (e.g. Program Files - PROGRA~1)
+  ;;
+esac
+
 # DLL is installed to $(libdir)/../bin by postinstall_cmds
 postinstall_cmds='base_file=`basename \${file}`~
   dlpath=`$SHELL 21 -c '\''. $dir