* config/ltmain.m4sh (func_mode_link): Rewrite duplicate object name renaming to avoid quadratic scaling by use of temp files, paste, join, OUTPUT_LONG_LIST. Breaks if file names contain newlines (and, if `read' does not support `-r', also backslashes). Hide `expr: argument list too long' error. 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 @@ -6298,47 +6351,45 @@ # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + objs_bnames=$always_gentop/objs_basenames + objs_nonuniq=$always_gentop/objs_nonuniq + replace_script=$always_gentop/replace_script + objs_file=$always_gentop/objs + OUTPUT_LONG_LIST([$oldobjs], ["$always_gentop/scratch6"], ["$basename"]) >"$objs_bnames" + sort "$objs_bnames" | uniq -d > "$objs_nonuniq" + if test -s "$objs_nonuniq" + then - $ECHO "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs + func_echo "copying selected object files to avoid basename conflicts..." + : >"$replace_script" + # Make sure we use unique names: find highest number currently in use. + counter=`$SED -n ['/^lt-[0-9][0-9]*/ { s/^lt-//; s/[^0-9].*//; p; }'] "$objs_bnames" \ + | sort -n | $SED -n '$p'` + OUTPUT_LONG_LIST([$oldobjs], ["$always_gentop/scratch7"]) >"$objs_file" + # Create a list with: line number, object basename, object name. + # Sort it by basename, then pick out all lines corresponding to conflicts. + # The last sort merely cosmetic. + sed = "$objs_bnames" | + sed 'N;s/\n/ /' | + paste - "$objs_file" | + if $posix_sort; then sort -k2; else sort +1; fi | + join -1 2 - "$objs_nonuniq" | + if $posix_sort; then sort -k2n; else sort -n +1; fi | + while $read_r objbase line obj do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[[\ /]]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - counter=`expr $counter + 1` - case " $oldobjs " in - *[[\ /]]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - oldobjs="$oldobjs $gentop/$newobj" - ;; - *) oldobjs="$oldobjs $obj" ;; - esac + counter=`expr $counter + 1` + newobj=lt$counter-$objbase + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $ECHO "$line c\\ +$gentop/$newobj" >>"$replace_script" done + oldobjs=' '`$SED -f "$replace_script" "$objs_file" | $NL2SP` fi eval cmds=\"$old_archive_cmds\" - if len=`expr "X$cmds" : ".*"` && + if len=`expr "X$cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else