* config/ltmain.m4sh (func_mode_link): Eliminate quadratic argument parsing with temp files, keep file descriptors (FD_LIBTOOL_ARGS, FD_COMPILE_COMMAND, FD_FINALIZE_COMMAND, FD_LIBOBJS, FD_NONPIC_OBJS): New. Use to avoid repeated reopening. Slurp in lists after parsing loop, make sure empty lists stay that way. (always_gentop): New variable to hold temp dir for scratch. Will be generated for every --mode=link invocation, also in dry run, and deleted upon exit. diff -ru config/ltmain.m4sh config/ltmain.m4sh --- config/ltmain.m4sh 27 Apr 2005 20:30:38 -0000 1.66 +++ config/ltmain.m4sh 19 May 2005 20:18:50 -0000 @@ -2166,10 +2186,32 @@ allow_undefined=yes ;; esac - libtool_args="$nonopt" + # Use files for long option lists, it avoids quadratic string handling. + # We need temp files, though, even in dry run + always_gentop=`opt_dry_run=false func_mktempdir` + trap "${RM}r \"$always_gentop\"" 0 +m4_define([FD_LIBTOOL_ARGS], [5])dnl +m4_define([FD_COMPILE_COMMAND], [6])dnl +m4_define([FD_FINALIZE_COMMAND], [7])dnl +m4_define([FD_LIBOBJS], [8])dnl +m4_define([FD_NONPIC_OBJS], [9])dnl + libtool_args_file=$always_gentop/libtool_args + compile_command_file=$always_gentop/compile_command + finalize_command_file=$always_gentop/finalize_command + libobjs_file=$always_gentop/libobjs + non_pic_objs_file=$always_gentop/non_pic_objs + exec FD_LIBTOOL_ARGS>"$libtool_args_file" \ + FD_COMPILE_COMMAND>"$compile_command_file" \ + FD_FINALIZE_COMMAND>"$finalize_command_file" \ + FD_LIBOBJS>"$libobjs_file" \ + FD_NONPIC_OBJS>"$non_pic_objs_file" + + $ECHO " " >&FD_LIBOBJS + $ECHO " " >&FD_NONPIC_OBJS + $ECHO " $nonopt" >&FD_LIBTOOL_ARGS + $ECHO " $nonopt" >&FD_COMPILE_COMMAND + $ECHO " $nonopt" >&FD_FINALIZE_COMMAND base_compile="$nonopt $@" - compile_command="$nonopt" - finalize_command="$nonopt" compile_rpath= finalize_rpath= @@ -2194,12 +2236,10 @@ export_symbols= export_symbols_regex= generated= - libobjs= ltlibs= module=no no_install=no objs= - non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no @@ -2235,8 +2275,8 @@ if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static # See comment for -static flag below, for more details. - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" + $ECHO " $link_static_flag" >&FD_COMPILE_COMMAND + $ECHO " $link_static_flag" >&FD_FINALIZE_COMMAND fi else if test -z "$pic_flag" && test -n "$link_static_flag"; then @@ -2260,14 +2300,14 @@ shift func_quote_for_eval "$arg" qarg="$func_quote_for_eval_unquoted_result" - libtool_args="$libtool_args $func_quote_for_eval_result" + $ECHO " $func_quote_for_eval_result" >&FD_LIBTOOL_ARGS # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" + $ECHO " @OUTPUT@" >&FD_COMPILE_COMMAND + $ECHO " @OUTPUT@" >&FD_FINALIZE_COMMAND ;; esac @@ -2275,8 +2315,8 @@ dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" + $ECHO " @SYMFILE@" >&FD_COMPILE_COMMAND + $ECHO " @SYMFILE@" >&FD_FINALIZE_COMMAND preload=yes fi case $arg in @@ -2398,7 +2438,7 @@ fi # A PIC object. - libobjs="$libobjs $pic_object" + $ECHO " $pic_object" >&FD_LIBOBJS arg="$pic_object" fi @@ -2408,7 +2448,7 @@ non_pic_object="$xdir$non_pic_object" # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi @@ -2416,7 +2456,7 @@ # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS fi else # Only an error if not doing a dry-run. @@ -2427,8 +2467,8 @@ pic_object=`$ECHO "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$ECHO "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $pic_object" >&FD_LIBOBJS + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS else func_fatal_error "\`$arg' is not a valid libtool object" fi @@ -2487,23 +2527,23 @@ linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" + $ECHO " $qarg" >&FD_COMPILE_COMMAND + $ECHO " $qarg" >&FD_FINALIZE_COMMAND continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" + $ECHO " $qarg" >&FD_COMPILE_COMMAND + $ECHO " $qarg" >&FD_FINALIZE_COMMAND continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" + $ECHO " $wl$qarg" >&FD_COMPILE_COMMAND + $ECHO " $wl$qarg" >&FD_FINALIZE_COMMAND continue ;; *) @@ -2574,8 +2614,8 @@ -L[[A-Z]][[A-Z]]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" + $ECHO " $arg" >&FD_COMPILE_COMMAND + $ECHO " $arg" >&FD_FINALIZE_COMMAND ;; esac continue @@ -2657,17 +2697,17 @@ # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. -model) - compile_command="$compile_command $arg" compiler_flags="$compiler_flags $arg" - finalize_command="$finalize_command $arg" + $ECHO " $arg" >&FD_COMPILE_COMMAND + $ECHO " $arg" >&FD_FINALIZE_COMMAND prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) compiler_flags="$compiler_flags $arg" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" + $ECHO " $arg" >&FD_COMPILE_COMMAND + $ECHO " $arg" >&FD_FINALIZE_COMMAND case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; @@ -2840,8 +2880,8 @@ -64|-mips[[0-9]]|-r[[0-9]][[0-9]]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" + $ECHO " $arg" >&FD_COMPILE_COMMAND + $ECHO " $arg" >&FD_FINALIZE_COMMAND compiler_flags="$compiler_flags $arg" continue ;; @@ -2906,7 +2946,7 @@ fi # A PIC object. - libobjs="$libobjs $pic_object" + $ECHO " $pic_object" >&FD_LIBOBJS arg="$pic_object" fi @@ -2916,7 +2956,7 @@ non_pic_object="$xdir$non_pic_object" # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi @@ -2924,7 +2964,7 @@ # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS fi else # Only an error if not doing a dry-run. @@ -2935,8 +2975,8 @@ pic_object=`$ECHO "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$ECHO "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" + $ECHO " $pic_object" >&FD_LIBOBJS + $ECHO " $non_pic_object" >&FD_NONPIC_OBJS else func_fatal_error "\`$arg' is not a valid libtool object" fi @@ -2978,11 +3018,25 @@ # Now actually substitute the argument into the commands. if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" + $ECHO " $arg" >&FD_COMPILE_COMMAND + $ECHO " $arg" >&FD_FINALIZE_COMMAND fi done # argument parsing loop + exec FD_LIBTOOL_ARGS>&- \ + FD_COMPILE_COMMAND>&- \ + FD_FINALIZE_COMMAND>&- \ + FD_LIBOBJS>&- \ + FD_NONPIC_OBJS>&- + libtool_args=`$SED 's/^ //' <"$libtool_args_file" | $NL2SP` + compile_command=`$SED 's/^ //' <"$compile_command_file" | $NL2SP` + finalize_command=`$SED 's/^ //' <"$finalize_command_file" | $NL2SP` + libobjs=`$SED 's/^ //' <"$libobjs_file" | $NL2SP` + non_pic_objects=`$SED 's/^ //' <"$non_pic_objs_file" | $NL2SP` + # Do not let `test -z' fail: + case $libobjs in ' ') libobjs=;; esac + case $non_pic_objects in ' ') non_pic_objects=;; esac + test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument"