[This time with a patch too]

Hi!

Since I swapped to ar-lib and consequently updated it to allow
augmenting an existing archive, I've noticed stuff like this in
the testsuite logs:

libtool: link: /c/cygwin/home/peda/automake/lib/ar-lib lib cru .libs/a1.lib  
a1.obj
a1.obj : warning LNK4006: _f1 already defined in a1.lib(a1.dll); second 
definition ignored

The reason turns out to be a bit nasty...

At one point I selected this naming:

static lib:  foo.lib
shared lib:  foo-2.dll  (for major version 2)
import lib:  foo-2.lib

However, for unversioned libraries this collapses to:

static lib:  foo.lib
shared lib:  foo.dll
import lib:  foo.lib

Oops.

The symptom is seen above. When creating the static lib, an attempt to
augment the already created import lib is made, but it fails...

So, I'm now proposing this naming scheme instead:

static lib:  foo.lib
shared lib:  foo-2.dll
import lib:  foo.dll.lib

which is a lot more consistent with the MinGW naming, i.e.:

static lib:  libfoo.a
shared lib:  libfoo-2.dll
import lib:  libfoo.dll.a

An additional benefit is that with the new naming it is possible to
guess the name of the import lib when only seeing -lfoo (w/o version)
so it will be possible to look for that during library search.

On the negative side we have:

* Inconsistent naming of import libs when comparing with other MSVC
libraries. They are typically named as the static lib, but so are
static libs, when that's what's shipped. Pick your poison.

* Interface change. But libtool could not work with shared libraries
without .la files before and if it has .la files from someone who
has use a patched libtool with "old style" MSVC libraries, they
should still work. Besides, it's better to do this now, before the
first release of libtool with MSVC support, than after.

So, I'm proposing this patch.

The testsuite is running. Ok to push if results look sane?

Cheers,
Peter

>From 36e3b1db468fca816f9ce36e7393436d6bbcccb7 Mon Sep 17 00:00:00 2001
From: Peter Rosin <p...@lysator.liu.se>
Date: Fri, 3 Sep 2010 13:51:43 +0200
Subject: [PATCH] Adjust naming of MSVC import libraries.

* libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
[pw32, cegcc] <cl>: Adjust naming of the import library from
foo-<major-version>.lib to foo.dll.lib, to avoid clashes with
the static library for unversioned libraries.
(_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG) [mingw, cygwin, pw32]
[cegcc] <cl>: Explicitely name the import library to match the
above.

Signed-off-by: Peter Rosin <p...@lysator.liu.se>
---
 ChangeLog             |   11 +++++++++++
 libltdl/m4/libtool.m4 |   10 +++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c6caad..ccedcec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-03  Peter Rosin  <p...@lysator.liu.se>
+
+       Adjust naming of MSVC import libraries.
+       * libltdl/m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [mingw, cygwin]
+       [pw32, cegcc] <cl>: Adjust naming of the import library from
+       foo-<major-version>.lib to foo.dll.lib, to avoid clashes with
+       the static library for unversioned libraries.
+       (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG) [mingw, cygwin, pw32]
+       [cegcc] <cl>: Explicitely name the import library to match the
+       above.
+
 2010-09-01  Peter Rosin  <p...@lysator.liu.se>
 
        Prefer $NM @file over calculating the cmd line length.
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 81b87d4..ac26e60 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -2312,7 +2312,7 @@ m4_if([$1], [],[
     # Native MSVC
     libname_spec='$name'
     soname_spec='${libname}`echo ${release} | $SED -e 
's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}`echo ${release} | $SED -e 
's/[[.]]/-/g'`${versuffix}.lib'
+    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.
@@ -5004,8 +5004,8 @@ _LT_EOF
          else
            sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < 
$export_symbols > $output_objdir/$soname.exp;
          fi~
-         func_to_tool_file "$output_objdir/$soname.exp"~
-         $CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs 
"@$func_to_tool_file_result" -Wl,-DLL~
+         func_to_tool_file "$output_objdir/"~
+         $CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs 
"@$func_to_tool_file_result$soname.exp" 
-Wl,-DLL,-IMPLIB:"$func_to_tool_file_result$libname.dll.lib"~
          linknames='
        # The linker will not automatically build a static lib if we build a 
DLL.
        # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
@@ -6001,8 +6001,8 @@ if test "$_lt_caught_CXX_error" != yes; then
            else
              $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < 
$export_symbols > $output_objdir/$soname.exp;
            fi~
-           func_to_tool_file "$output_objdir/$soname.exp"~
-           $CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs 
"@$func_to_tool_file_result" -Wl,-DLL~
+           func_to_tool_file "$output_objdir/"~
+           $CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs 
"@$func_to_tool_file_result$soname.exp" 
-Wl,-DLL,-IMPLIB:"$func_to_tool_file_result$libname.dll.lib"~
            linknames='
          # The linker will not automatically build a static lib if we build a 
DLL.
          # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
-- 
1.7.1

Reply via email to