Hi! This is a patch that makes use of @FILE support in the archiver, if the archiver supports it. That makes linking succeed for long command lines when using MSVC, as MSVC can't do piecewise linking (-r -o) which is the current fallback. Absolute paths still needs work, but that will have to wait for Chucks work in that area.
This is similar to commit f987bddc70eb8968923964bd0b98f530b3781add Indicate if the archiver supports a listing file. but generalized so that it tests for the feature instead of only using @ when Microsoft lib is the archiver. As usual I have squashed in the relevant part of the msvc-doc commit 06cfce005204bb8ca212aadab38b38c0202ea04e Discussion that led up to the above mentioned commit on the pr-msvc-support branch: http://lists.gnu.org/archive/html/libtool-patches/2006-02/msg00081.html First post of the changeset on the pr-msvc-support branch: http://lists.gnu.org/archive/html/libtool-patches/2007-07/msg00064.html Cheers, Peter
>From 98e8919a73a40aae15ba519263c87fdcf55eb2f8 Mon Sep 17 00:00:00 2001 From: Peter Rosin <p...@lysator.liu.se> Date: Wed, 11 Aug 2010 18:17:08 +0200 Subject: [PATCH] Allow the use of a listing file if the archiver supports it. * libltdl/m4/libtool.m4 (_LT_CMD_OLD_ARCHIVE): Move detection of a suitable archiver... (_LT_PROG_AR): ...to here. New macro, also detect if the archiver supports a listing file with the new variable archiver_list_spec. * libltdl/config/ltmain.m4sh: If the archiver supports a listing file, use it when max_cmd_len is exceeded. This is needed for tool chains such as MSVC which do not support piece by piece linking (-r -o). * doc/libtool.texi (libtool script contents): Update with archiver_list_spec description. Signed-off-by: Peter Rosin <p...@lysator.liu.se> --- ChangeLog | 15 +++++++++++++++ doc/libtool.texi | 4 ++++ libltdl/config/ltmain.m4sh | 10 ++++++++++ libltdl/m4/libtool.m4 | 38 +++++++++++++++++++++++++++++++++----- 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce4c9db..5951c72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-08-11 Peter Rosin <p...@lysator.liu.se> + + Allow the use of a listing file if the archiver supports it. + * libltdl/m4/libtool.m4 (_LT_CMD_OLD_ARCHIVE): Move detection + of a suitable archiver... + (_LT_PROG_AR): ...to here. New macro, also detect if the + archiver supports a listing file with the new variable + archiver_list_spec. + * libltdl/config/ltmain.m4sh: If the archiver supports a listing + file, use it when max_cmd_len is exceeded. This is needed for + tool chains such as MSVC which do not support piece by piece + linking (-r -o). + * doc/libtool.texi (libtool script contents): Update with + archiver_list_spec description. + 2010-08-10 Gary V. Vaughan <g...@gnu.org> (tiny change) Make testsuite compatible with Autoconf 2.62 again. diff --git a/doc/libtool.texi b/doc/libtool.texi index 914bd1d..255e412 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -5875,6 +5875,10 @@ Commands used to create shared libraries, shared libraries with @option{-export-symbols} and static libraries, respectively. @end defvar +...@defvar archiver_list_spec +How to feed a file listing to the archiver. +...@end defvar + @defvar old_archive_from_new_cmds If the shared library depends on a static library, @samp{old_archive_from_new_cmds} contains the commands used to create that diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index d677529..ec6ae3c 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -7900,6 +7900,16 @@ EOF len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds + elif test -n "$archiver_list_spec"; then + func_verbose "using command file archive linking..." + for obj in $oldobjs + do + $ECHO \""$obj"\" + done > $output_objdir/$libname.libcmd + save_oldobjs="$oldobjs" + oldobjs=" $archiver_list_spec$output_objdir/$libname.libcmd" + eval cmds=\"\$old_archive_cmds\" + oldobjs="$save_oldobjs" else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index c36a6b4..9cf6ebf 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -1312,14 +1312,42 @@ need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([[int some_variable = 0;]], + [echo conftest.$ac_objext > conftest.lst + am_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst' + AC_TRY_EVAL([am_ar_try]) + if test "$ac_status" -eq 0; then + lt_cv_ar_at_file=@ + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) +[_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: -- 1.6.4.2