[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MLB] Fix for arg list too long (Finally a patch!)
From: |
Robert Boehne |
Subject: |
[MLB] Fix for arg list too long (Finally a patch!) |
Date: |
Tue, 13 Feb 2001 15:33:00 -0600 |
Libtoolers:
Here is my latest incarnation of that elusive animal,
the incrementally linking Libtool. (libtoolus-handlesalottafilesforus)
ChangeLog entry:
2001-02-13 Robert Boehne <address@hidden>
* ltconfig.in: Added the variable max_cmd_len to define
the limit in characters for command line arguments.
Added a test to find the approximate value of the
command line limit.
* ltmain.in: Added support for incremental linking of
static and shared objects using $max_cmd_len determined
by ltconfig.
--
Robert Boehne Software Engineer
Ricardo Software Chicago Technical Center
TEL: (630)789-0003 x. 238
FAX: (630)789-0127
email: address@hidden
ChangeLog entry:
2001-02-13 Robert Boehne <address@hidden>
* ltconfig.in: Added the variable max_cmd_len to define
the limit in characters for command line arguments.
Added a test to find the approximate value of the
command line limit.
* ltmain.in: Added support for incremental linking of
static and shared objects using $max_cmd_len determined
by ltconfig.
Index: ltconfig.in
===================================================================
RCS file: /cvsroot/libtool/libtool/Attic/ltconfig.in,v
retrieving revision 1.246.2.43
diff -u -r1.246.2.43 ltconfig.in
--- ltconfig.in 2001/02/12 18:08:11 1.246.2.43
+++ ltconfig.in 2001/02/13 21:26:17
@@ -216,6 +216,7 @@
ac_ext=c
libext=a
cache_file=
+max_cmd_len=
## Dependencies to place before and after the object being linked:
predep_objects=
@@ -774,6 +775,21 @@
no_builtin_flag="$ac_cv_prog_cc_no_builtin"
can_build_shared="$ac_cv_prog_cc_can_build_shared"
+# find the maximum length of command line arguments
+echo $ac_n "finding the maximum length of command line arguments... $ac_c" 1>&6
+echo "$progname:@LINENO@:finding the maximum length of command line arguments"
1>&5
+i=0
+testring="ABCDEF"
+while test `$0 --fallback-echo "X$testring" >/dev/null 2>&1` == `echo
"X$testring" >/dev/null 2>&1` &&
+ new_result=`expr "X$testring" : ".*" 2>&1` &&
+ max_cmd_len=$new_result &&
+ test $i != 32 # 1 MB should be enough
+do
+ i=`expr $i + 1`
+ testring=$testring$testring
+done
+echo "$ac_t""$max_cmd_len" 1>&6
+
# Check to see if options -o and -c are simultaneously supported by compiler
echo $ac_n "checking if $compiler supports -c -o file.$objext... $ac_c" 1>&6
$rm -r conftest 2>/dev/null
@@ -2215,6 +2237,9 @@
# Additional compiler flags for building library objects.
pic_flag=$pic_flag
pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
# Does compiler simultaneously support -c and -o options?
compiler_c_o=$compiler_c_o
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.200.2.44
diff -u -r1.200.2.44 ltmain.in
--- ltmain.in 2001/01/24 20:08:34 1.200.2.44
+++ ltmain.in 2001/02/13 21:26:17
@@ -3007,6 +3007,77 @@
else
eval cmds=\"$archive_cmds\"
fi
+ if test `expr "X$cmds" : ".*"` -gt $max_cmd_len ; then
+ # the command line is too long to link in one step, link
incrementally
+ $echo "using incremental linking..."
+ # save the value of $output and $libobjs because we want to use them
later
+ save_libobjs=$libobjs
+ save_output=$output
+ # clear the reloadable object creation command queue and initialize
k to one.
+ concat_cmds=
+ objlist=
+ k=0
+ # loop over the list of objects to be linked
+ for obj in $save_libobjs
+ do
+ if test `expr "X$test_cmds" : ".*"` -gt $max_cmd_len ; then
+ # the above command is almost too long
+ # increment k, the reloadable object file counter
+ k=`expr $k + 1`
+ # set the value of $output to the Kth object file
+ output=$output_objdir/all_objs${k}.$objext
+ if test $k -eq 1 ; then
+ # the first file doesn't need to have the previous one linked
in.
+ eval concat_cmds=\"$reload_cmds $objlist\"
+ else
+ # all subsequent reloadable object files will link in the last
one created
+ eval concat_cmds=\"$concat_cmds~$reload_cmds $objlist
$output_objdir/all_objs`expr $k - 1`.$objext\"
+ fi
+ test_cmds=X
+ objlist=$obj
+ else
+ objlist="$objlist"
+ if test $k -eq 0 ; then
+ # the first file doesn't need to have the previous one linked
in.
+ eval test_cmds=\"$reload_cmds $objlist\"
+ else
+ # all subsequent reloadable object files will link in the last
one created
+ eval test_cmds=\"$reload_cmds $objlist
$output_objdir/all_objs`expr $k - 1`.$objext\"
+ fi
+ fi
+ done
+ # handle the remaining objects by creating one last reloadable
object file
+ k=`expr $k + 1`
+ output=$output_objdir/all_objs${k}.$objext
+ if test $k != 1 ; then
+ # all subsequent reloadable object files will link in the last one
created
+ eval concat_cmds=\"$concat_cmds~$reload_cmds $objlist
$output_objdir/all_objs`expr $k - 1`.$objext\"
+ else
+ eval concat_cmds=\"$reload_cmds $save_libobjs\"
+ fi
+ $echo "creating a temporary reloadable object file: $output"
+
+ # loop through the commands generated above and execute them
+ IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ libobjs=$output
+ # restore the value of output
+ output=$save_output
+
+ # expand the library linking commands again to reset the value of
$libobjs for incremental linking
+ # Do each of the archive commands.
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+ fi
IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
IFS="$save_ifs"
@@ -3914,6 +3985,28 @@
# done
eval cmds=\"$old_archive_cmds\"
+ if test `expr "X$cmds" : ".*"` -gt $max_cmd_len ; then
+ # the command line is too long to link in one step, link
incrementally
+ $echo "using incremental archive linking..."
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ for obj in $save_oldobjs
+ do
+ oldobjs="$objlist $obj"
+ objlist="$objlist $obj"
+ eval test_cmds=\"$old_archive_cmds\"
+ if test `expr "X$test_cmds" : ".*"` -gt $max_cmd_len ; then
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ eval concat_cmds=\"$old_archive_cmds~$concat_cmds\"
+ objlist=
+ fi
+ done
+ oldobjs=$objlist
+ eval concat_cmds=\"$old_archive_cmds~$concat_cmds\"
+ eval cmds=\"$concat_cmds\"
+ fi
fi
IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
for cmd in $cmds; do
- [MLB] Fix for arg list too long (Finally a patch!),
Robert Boehne <=
- Re: [MLB] Fix for arg list too long (Finally a patch!), Alexandre Oliva, 2001/02/14
- Re: [MLB] Fix for arg list too long (Finally a patch!), Robert Boehne, 2001/02/15
- Re: [MLB] Fix for arg list too long (Finally a patch!), Alexandre Oliva, 2001/02/15
- Re: [MLB] Fix for arg list too long (another attempt), Robert Boehne, 2001/02/19
- Re: [MLB] Fix for arg list too long (another attempt), Alexandre Oliva, 2001/02/20
- Re: [MLB] Fix for arg list too long (another [final?] attempt), Robert Boehne, 2001/02/20
- Re: [MLB] Fix for arg list too long (another [final?] attempt), Alexandre Oliva, 2001/02/22
- Re: [MLB] Fix for arg list too long (another final! attempt), Robert Boehne, 2001/02/22
- Re: [MLB] Fix for arg list too long (another final! attempt), Alexandre Oliva, 2001/02/23