* config/ltmain.m4sh (func_mode_link): Rewrite piecewise old archive linking to avoid quadratic loop. Makes use of fold, split, temp files, and OUTPUT_LONG_LIST. * tests/pdemo-conf.test: Adjust for the fact that we require $old_archive_cmds with empty list of objects to fit in the command line. diff -u -r1.66 ltmain.m4sh --- config/ltmain.m4sh 27 Apr 2005 20:30:38 -0000 1.66 +++ config/ltmain.m4sh 19 May 2005 20:18:50 -0000 @@ -6348,38 +6399,35 @@ RANLIB=: objlist= concat_cmds= - save_oldobjs=$oldobjs - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - for obj in $save_oldobjs + OUTPUT_LONG_LIST([$oldobjs], ["$always_gentop/scratch8"]) >"$objs_file" + oldobjs= + objs_split_base=$always_gentop/objs_split + eval test_cmds=\"$old_archive_cmds\" + len_netto=`expr "X$test_cmds" : ".*"` \ + || func_fatal_error "too many arguments in \`old_archive_cmds'" + test "$len_netto" -lt "$max_cmd_len" \ + || func_fatal_error "too many arguments in \`old_archive_cmds'" + len_allowed=`expr "$max_cmd_len" - "$len_netto"` + ${RM} "$objs_split_base"?* + # `fold' accepts long lines, `split' should too. + # We have to split, because `read' is limited to text files. + ( $NL2SP <"$objs_file"; echo ) \ + | fold -b -s -w "$len_allowed" \ + | split -l 1 - "$objs_split_base" + oldobjs= + for objfile in "$objs_split_base"?* last do - oldobjs="$objlist $obj" - objlist="$objlist $obj" - eval test_cmds=\"$old_archive_cmds\" - if len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi + case $objfile in last) RANLIB=$save_RANLIB;; esac + case $oldobjs in '') ;; + *) test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - fi + ;; + esac + case $objfile in last) ;; *) oldobjs=' '`cat "$objfile"`;; esac done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi + + eval cmds=\"\$concat_cmds\" fi fi save_ifs="$IFS"; IFS='~' Index: tests/pdemo-conf.test =================================================================== RCS file: /cvsroot/libtool/libtool/tests/pdemo-conf.test,v retrieving revision 1.12 diff -u -r1.12 pdemo-conf.test --- tests/pdemo-conf.test 22 Apr 2005 10:10:30 -0000 1.12 +++ tests/pdemo-conf.test 6 May 2005 16:59:57 -0000 @@ -30,7 +30,7 @@ func_check_static_shared "yes" "yes" if test -f ./libtool ; then - sed 's/^max_cmd_len=*/max_cmd_len=24 # /g' ./libtool > ltnew + sed 's/^max_cmd_len=*/max_cmd_len=96 # /g' ./libtool > ltnew else exit 1 fi