Re: [patch #6448] [MSVC 7/7] Add MSVC Support

2008-08-07 Thread Peter Rosin

Peter Rosin skrev:

Peter Rosin skrev:

Ralf Wildenhues skrev:

* Peter Rosin wrote on Tue, Aug 05, 2008 at 10:38:14AM CEST:

  29: static.at:68   static linking flags for programs
m-all-static.exe.manifest isn't installed


What does the manifest file do?


The manifest is an XML file that describes how the executable should
be run. In this case it contains a hint where the side-by-side (SxS)
assembly containing the C runtime (msvcrt80.dll) is. The manifest can
also specify if a file should be executed with elevated priviliges (or
not).

I'm no manifest guru, so the above is perhaps not 100% accurate.

Side note, the mainfest could perhaps be used to support some version
of hardcode_libdir?

The crude fix is to (un)install the mainfest file, the nice fix
is to embed it as a resource in the executable using the manifest
tool (mt.exe).


Here's a patch to fix the manifest failures. Maybe this should be
wrapped up in a postlink_cmds variable instead to match the existing
prelink_cmds?


Replying to self as usual, sorry about the mail flood...

The previous patch was not enough, program linking happened in more than
one place. Here's a new patch that fixes that and also adds the
postlink_cmds variable as mentioned above.

This patch actually fixes all mainfest problems. Tests 39 and 40 now
succeed, but 29 still fails, but 29 now stumbles later when the MSVC
toolchain can't handle static/shared linking of non-libtool libraries.
(The static library is always selected for non-libtool libs, as it gets
the preferred name, foo.lib. The import lib gets the name foo-0.lib and
is only found if there is a libfoo.la)

2008-08-07  Peter Rosin  [EMAIL PROTECTED]

* libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS) postlink_cmds:
New tag variable.
[ cygwin, mingw, cegcc ] cl*: Embed the manifest file as a
resource.
(_LT_LANG_CXX_CONFIG): Likewise.
* libltdl/config/ltmain.m4sh (func_mode_link): After linking
a program, replace @OUTPUT@ in $postlink_cmds and then execute
the commands.
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 35ae02f..b78d7ac 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -7340,6 +7340,11 @@ EOF
exit_status=0
func_show_eval $link_command 'exit_status=$?'
 
+   if test -n $postlink_cmds; then
+ postlink_cmds=`$ECHO X$postlink_cmds | $Xsed -e '[EMAIL 
PROTECTED]@%'$output'%g'`
+ func_execute_cmds $postlink_cmds 'exit $?'
+   fi
+
# Delete the generated files.
if test -f $output_objdir/${outputname}S.${objext}; then
  func_show_eval '$RM $output_objdir/${outputname}S.${objext}'
@@ -7385,6 +7390,12 @@ EOF
$opt_dry_run || $RM $output
# Link the executable and exit
func_show_eval $link_command 'exit $?'
+
+   if test -n $postlink_cmds; then
+ postlink_cmds=`$ECHO X$postlink_cmds | $Xsed -e '[EMAIL 
PROTECTED]@%'$output'%g'`
+ func_execute_cmds $postlink_cmds 'exit $?'
+   fi
+
exit $EXIT_SUCCESS
   fi
 
@@ -7418,6 +7429,11 @@ EOF
 
   func_show_eval $link_command 'exit $?'
 
+  if test -n $postlink_cmds; then
+   postlink_cmds=`$ECHO X$postlink_cmds | $Xsed -e '[EMAIL 
PROTECTED]@%'$output_objdir/$outputname'%g'`
+   func_execute_cmds $postlink_cmds 'exit $?'
+  fi
+
   # Now create the wrapper script.
   func_verbose creating $output
 
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 37c0f71..bd71b88 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -4812,6 +4812,10 @@ _LT_EOF
_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
_LT_TAGVAR(compile_tag, $1)=-TC
_LT_TAGVAR(dashl_xform, $1)='s/\(.*\)/\1.lib/'
+   _LT_TAGVAR(postlink_cmds, $1)='if test -e @[EMAIL PROTECTED]; then
+   mt -manifest @[EMAIL PROTECTED] -outputresource:@[EMAIL 
PROTECTED];
+   $RM @[EMAIL PROTECTED];
+ fi'
;;
   *)
# Assume MSVC wrapper
@@ -5356,6 +5367,8 @@ _LT_TAGDECL([], [include_expsyms], [1],
 [Symbols that must always be exported])
 _LT_TAGDECL([], [prelink_cmds], [2],
 [Commands necessary for linking programs (against libraries) with 
templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+[Commands necessary for finishing linking programs])
 _LT_TAGDECL([], [file_list_spec], [1],
 [Specify filename containing input files])
 _LT_TAGDECL([], [dashL_envvar], [1],
@@ -5803,6 +5816,10 @@ if test $_lt_caught_CXX_error != yes; then
  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
  _LT_TAGVAR(compile_tag, $1)=-TP
  _LT_TAGVAR(dashl_xform, $1)='s/\(.*\)/\1.lib/'
+ _LT_TAGVAR(postlink_cmds, $1)='if test -e @[EMAIL PROTECTED]; then
+ mt -manifest @[EMAIL PROTECTED] -outputresource:@[EMAIL 
PROTECTED];
+ $RM @[EMAIL PROTECTED];
+   fi'
  ;;
*)
  # g++


Re: [patch #6448] [MSVC 7/7] Add MSVC Support

2008-08-07 Thread Peter Rosin

Peter Rosin skrev:

Ralf Wildenhues skrev:

* Peter Rosin wrote on Mon, Aug 04, 2008 at 03:51:29PM CEST:

Ralf Wildenhues skrev:

I've reformatted tests/nocase.at a bit, and sprinkled in more AT_CHECKs
because the test fails for me on a GNU/Linux - MinGW cross compile
(using i586-mingw32msvc-gcc):

libFOO is found but -lfoo is not rewritten to -lFoo.  I don't know 
if it

should be, but either the test or the implementation needs fixing.

Test works fine on the MSYS/MSVC pair. I suspect if fails bacause the
build system FS is case sensitive? Cross compile is not my top priority.


Well, I certainly don't think we need to put much work in supporting a
cross compile setup where MSVC is the compiler.  However, that is not
what I was writing about: the above is a (quite widely used) GCC cross
that runs on GNU/Linux and produces code for w32, using MSYS stub
libraries and so on.  It's not nice to introduce a new test failure for
this setup.

That being said, I'm open to whether the code or the test should be
fixed, or the test should simply be skipped in this case.  Ideally we
should take into account that Windows shares may be mounted on unixy
systems as well, such that maybe there is some benefit to be had from
nocase support.  (OTOH, I have little experience with such setups;
maybe the testsuite test would actually succeed there?  Then a skip
on a case-sensitive system seems appropriate to me)


Ah, ok. That's bad. The misleading name i586-mingw32msvc-gcc caught
me. Again. What in the world is msvc doing in there?

Just to reiterate the underlying reason for this code, MSVC has a bunch
of system libs named e.g. DDRAW.LIB, while MinGW has the corresponding
import library as libddraw.dll.a. So, the libtool user can't use a
single canonical name (-lDDRAW and -lddraw are equally correct). At the
same time libtool has code that needs to find the exact file, this code
needs to be made case insensitive for things to work smoothly.

So, I don't think the benefit is all that great on unixy systems, since
there wouldn't be any question as to whether -lFoo or -lfoo is
correct.

To fix the test failure on the MinGW cross compile, it might be enough
to disable the nocase stuff in libtool.m4 for cross compiles (take the
default branch in the case $host_os statement, near the end of
_LT_CHECK_MAGIC_METHOD). This should cause a skip of the offending
test.


Like this patch. Can you verify if it works for i586-mingw32msvc-gcc?

Cheers,
Peter

2008-08-07  Peter Rosin  [EMAIL PROTECTED]

* libltdl/m4/libtool.m4 (_LT_CHECK_MAGIC_METHOD): Disable nocase
handling for cross compiles.

diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 37c0f71..ccd541a 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -3237,21 +3237,19 @@ tpf*)
 esac
 ])
 
-case $host_os in
-cygwin* | mingw* | pw32*)
-  if ( shopt | grep nocaseglob ) /dev/null 21; then
-file_magic_glob=
-want_nocaseglob=yes
-  else
-file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ 
| $SED -e s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g`
-want_nocaseglob=no
-  fi
-  ;;
-*)
-  file_magic_glob=
-  want_nocaseglob=no
-  ;;
-esac
+file_magic_glob=
+want_nocaseglob=no
+if test $build = $host; then
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+if ( shopt | grep nocaseglob ) /dev/null 21; then
+  want_nocaseglob=yes
+else
+  file_magic_glob=`echo 
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e 
s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g`
+fi
+;;
+  esac
+fi
 
 file_magic_cmd=$lt_cv_file_magic_cmd
 deplibs_check_method=$lt_cv_deplibs_check_method