Re: pr-msvc-support: building .DLLs with symbols

2009-09-10 Thread Peter Rosin

Hi David,

(moving to libtool-patc...@...)

Den 2009-09-03 20:24 skrev David Byron:

You want to send -DEBUG to link.exe, not to cl.exe. I'm
sure you know this, but simply adding -DEBUG to LDFLAGS is
not the way you do this. The correct way would be to use
-Wl,-DEBUG. If the msvc stuff were complete, libtool would
then feed -DEBUG to the linker.  But this does not
currently work, and the main reason is that the -link
option to cl.exe is different. It feeds all options
(instead of just one) after the -link option on the
command line to the linker, so it would be very bad to
just transform -Wl,foo into -link foo.


Makes sense.


Can someone show me how to do this without hacking the
libtool file?

You can work around the above -Wl,foo limitation in two
ways.

2) Use a response file, like this:

$ cat linkdebug
-link -DEBUG
$ /bin/sh ./libtool --tag=CC   --mode=link cl @linkdebug -MD -Zi \
-no-undefined -export-symbols symfile  -o libfoo.la \
-rpath /usr/local/lib libfoo_la-public.lo libfoo_la-private.lo


This works well, though way I integrated it with autoconf and automake is a
bit cumbersome.  Trouble is, it works so it's harder to motivate to dive in
and fix libtool to do the right thing with -Wl,-DEBUG.


Here's a couple of patches that implements support for -Wl, and
-Xlinker for MSVC. The first one (rename-dashL_envvar-tolinker_envvar.patch)
is just a rename, to reduce confusion, and the second patch
(-Xlinker-msvc.patch) contains the new code...

Ok for the pr-msvc-support branch?

Cheers,
Peter

2009-09-09  Peter Rosin  p...@lysator.liu.se

Make -Wl,FLAG and -Xlinker FLAG work on MSVC.
* libltdl/m4/libtool.m4 (_LT_COMPILER_PIC) [MSVC]: Set
lt_prog_compiler_wl to @lt_envvar@ to signal that linker options
should be passed via the $linker_envvar variable.
* libltdl/config/ltmain.m4sh (func_to_linker_envvar): Also move
@lt_output@ options to the $linker_envvar variable.
(func_mode_link) [linkmode=lib]: Look for options to move to the
$linker_envvar in $compiler_flags as well. Echo the final
content of the linker_envvar.
(func_mode_link) [linkmode=prog]: Look for options to move to the
$linker_envvar in $compile_command and $finalize_command as well.
* tests/flags.at: Don't expect to find @lt_envvar@ in the output
if $wl is set to that.
* doc/libtool.texi (linker_envvar): Document the @lt_envvar@ hook.

2009-09-09  Peter Rosin  p...@lysator.liu.se

Rename dashL_envvar into linker_envvar.
* libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG):
Rename dashL_envvar into linker_envvar. The new name makes it
less confusing to pass other linker options via the variable.
* libltdl/config/ltmain.m4sh (func_dashL_to_envvar): Rename...
(func_to_linker_envvar): ...to this, and operate on linker_envvar
instead of dashL_envvar.
(func_mode_link): Adjust to above renames.
* doc/libtool.texi: Document changes.

diff --git a/doc/libtool.texi b/doc/libtool.texi
index 610117e..9aa3d4b 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -5876,13 +5876,6 @@ convenience archives or a set of object file names can 
be passed via
 linker-specific options or linker scripts.
 @end defvar
 
-...@defvar dashL_envvar
-When linking, move all paths specified with @option{-L} options to
-this variable, for toolchains where it makes sense to pass the library
-search paths in an environment variable. Normally disabled (i.e.
-...@var{dashl_envvar} empty).
-...@end defvar
-
 @defvar dashL_envvar_spec
 When moving library search paths with @var{dashL_envvar}, prepend this
 to each @option{-L} path that is added to @var{dashL_envvar}. Unused
@@ -6107,6 +6100,13 @@ Linker flag (passed through the C compiler) used to 
prevent dynamic
 linking.
 @end defvar
 
+...@defvar linker_envvar
+When linking, move all paths specified with @option{-L} options to
+this variable, for toolchains where it makes sense to pass the library
+search paths in an environment variable. Normally disabled (i.e.
+...@var{linker_envvar} empty).
+...@end defvar
+
 @defvar macro_version
 @defvarx macro_revision
 The release and revision from which the libtool.m4 macros were
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 40ff9d3..5fc8d0b 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -634,8 +634,8 @@ func_infer_tag ()
 }
 
 
-# func_dashL_to_envvar deplibs_variable deplibs...
-func_dashL_to_envvar ()
+# func_to_linker_envvar deplibs_variable deplibs...
+func_to_linker_envvar ()
 {
   deplibs_variable=$1
   shift
@@ -653,7 +653,7 @@ func_dashL_to_envvar ()
env_path=`cygpath -w $env_path`
;;
   esac
-  eval $dashL_envvar=\\$$dashL_envvar $dashL_envvar_spec$env_path\
+  eval $linker_envvar=\\$$linker_envvar $dashL_envvar_spec$env_path\
   ;;
 *)
   tmp_libs=$tmp_libs $deplib
@@ 

func_win32_libid doesn't work with MS dumpbin

2009-09-10 Thread Peter Rosin

Hi!

I recently upgraded to MSYS 1.0.11 and it provides file(1). Since
then the library dependecy check fails if $NM isn't the good old
binutils nm. So, I propose this patch (for master).

Ok to push?

Cheers,
Peter

2009-09-10  Peter Rosin  p...@lysator.liu.se

func_win32_libid doesn't work with MS dumpbin
* libltdl/m4/libtool.m4 (_LT_CHECK_MAGIC_METHOD): The $NM
interface is assumed to be BSD nm in func_win32_libid, so
check for that before using it.
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 662a88b..bebce6b 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2989,7 +2989,8 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  if ( file / ) /dev/null 21; then
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test $lt_cv_nm_interface = BSD nm  file / ) /dev/null 21; then
 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
 lt_cv_file_magic_cmd='func_win32_libid'
   else


Re: [SCM] GNU Libtool branch, pr-msvc-support, updated. v2.2.6-182-gdd42e63

2009-09-10 Thread Ralf Wildenhues
Hi Peter,

* Peter Rosin wrote on Thu, Sep 10, 2009 at 10:06:32AM CEST:
 The branch, pr-msvc-support has been updated
via  dd42e63ce688302500f349606c55bf173feda3a4 (commit)
[...]
 commit dd42e63ce688302500f349606c55bf173feda3a4
 Merge: a128e6d5f8a57c0f3cfb85a28d8d843f504a3cdf 
 b03736353b6d478a68bfc19c017605eb21a3edce
 Author: Peter Rosin p...@lysator.liu.se
 Date:   Wed Sep 9 12:36:23 2009 +0200
 
 Merge branch 'master' into pr-msvc-support

Thank you!
Ralf