This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Backport input file to GCC libtool
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 03 May 2005 21:43:19 -0400
- Subject: [PATCH] Backport input file to GCC libtool
The appended patch backports functionality from CVS libtool to
invoke the linker with a list of object files if the command line is too
long. This is necessary for libgfortran to link reliably on AIX and will
speed up linking libjava if there are too many object file to fit on the
command line.
This patch has been bootstrapped successfully on
powerpc-ibm-aix5.2.0.0 and powerpc64-linux. This also has been tested
with max_cmd_len artificially set to a small value to force the
functionality to be tested.
Okay for mainline and 4.0?
David
* ltconfig: Define file_list_spec. Pass file_list_spec and
with_gnu_ld to libtool.
* ltcf-c.sh (aix[45]): Define file_list_spec.
* ltcf-cxx.sh (aix[45]): Same.
* ltcf-gcj.sh (aix[45]): Same.
* ltmain.sh: If command exceeds max_cmd_len and file_list_spec
exists, write list of input files to temporary file.
Index: ltconfig
===================================================================
RCS file: /cvs/gcc/gcc/ltconfig,v
retrieving revision 1.32
diff -c -p -r1.32 ltconfig
*** ltconfig 2 Oct 2004 16:33:06 -0000 1.32
--- ltconfig 2 May 2005 20:53:47 -0000
*************** exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
*** 266,271 ****
--- 266,272 ----
# rely on this symbol name, it's probably fine to never include it in
# preloaded symbol tables.
extract_expsyms_cmds=
+ file_list_spec=
## Tools:
old_AR="$AR"
*************** case $ltmain in
*** 2164,2170 ****
finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
hardcode_libdir_flag_spec hardcode_libdir_separator \
sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
! compiler_c_o need_locks exclude_expsyms include_expsyms; do
case $var in
reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
--- 2165,2171 ----
finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
hardcode_libdir_flag_spec hardcode_libdir_separator \
sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
! compiler_c_o need_locks exclude_expsyms include_expsyms file_list_spec; do
case $var in
reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
*************** exclude_expsyms=$exclude_expsyms
*** 2557,2562 ****
--- 2558,2569 ----
# Symbols that must always be exported.
include_expsyms=$include_expsyms
+ # Specify filename containing input files.
+ file_list_spec=$file_list_spec
+
+ # with_gnu_ld value
+ with_gnu_ld=$with_gnu_ld
+
EOF
if test -z "$tagname"; then
Index: ltcf-c.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltcf-c.sh,v
retrieving revision 1.21
diff -c -p -r1.21 ltcf-c.sh
*** ltcf-c.sh 2 Oct 2004 16:33:06 -0000 1.21
--- ltcf-c.sh 2 May 2005 20:53:47 -0000
*************** else
*** 267,272 ****
--- 267,273 ----
hardcode_direct=yes
hardcode_libdir_separator=':'
link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
# When large executables or shared objects are built, AIX ld can
# have problems creating the table of contents. If linking a library
# or program results in "error TOC overflow" add -mminimal-toc to
Index: ltcf-cxx.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltcf-cxx.sh,v
retrieving revision 1.30
diff -c -p -r1.30 ltcf-cxx.sh
*** ltcf-cxx.sh 2 Oct 2004 16:33:06 -0000 1.30
--- ltcf-cxx.sh 2 May 2005 20:53:47 -0000
*************** case $host_os in
*** 128,133 ****
--- 128,134 ----
hardcode_direct=yes
hardcode_libdir_separator=':'
link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
# When large executables or shared objects are built, AIX ld can
# have problems creating the table of contents. If linking a library
# or program results in "error TOC overflow" add -mminimal-toc to
Index: ltcf-gcj.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltcf-gcj.sh,v
retrieving revision 1.14
diff -c -p -r1.14 ltcf-gcj.sh
*** ltcf-gcj.sh 27 Apr 2004 06:14:30 -0000 1.14
--- ltcf-gcj.sh 2 May 2005 20:53:47 -0000
*************** else
*** 266,271 ****
--- 266,272 ----
hardcode_direct=yes
hardcode_libdir_separator=':'
link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
# When large executables or shared objects are built, AIX ld can
# have problems creating the table of contents. If linking a library
# or program results in "error TOC overflow" add -mminimal-toc to
Index: ltmain.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltmain.sh,v
retrieving revision 1.25
diff -c -p -r1.25 ltmain.sh
*** ltmain.sh 1 Mar 2005 22:27:43 -0000 1.25
--- ltmain.sh 2 May 2005 20:53:47 -0000
*************** EOF
*** 3272,3278 ****
:
else
# The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
# Save the value of $output and $libobjs because we want to
# use them later. If we have whole_archive_flag_spec, we
--- 3272,3277 ----
*************** EOF
*** 3286,3291 ****
--- 3285,3291 ----
save_libobjs=$libobjs
fi
save_output=$output
+ output_la=`$echo "X$output" | $Xsed -e "s,^.*/,,"`
# Clear the reloadable object creation command queue and
# initialize k to one.
*************** EOF
*** 3295,3357 ****
delfiles=
last_robj=
k=1
- output=$output_objdir/$save_output-${k}.$objext
- # Loop over the list of objects to be linked.
- for obj in $save_libobjs
- do
- eval test_cmds=\"$reload_cmds $objlist $last_robj\"
- if test "X$objlist" = X ||
- { len=`expr "X$test_cmds" : ".*"` &&
- test $len -le $max_cmd_len; }; then
- objlist="$objlist $obj"
- else
- # The command $test_cmds is almost too long, add a
- # command to the queue.
- if test $k -eq 1 ; then
- # The first file doesn't have a previous command to add.
- eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
- else
- # All subsequent reloadable object files will link in
- # the last one created.
- eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
- fi
- last_robj=$output_objdir/$save_output-${k}.$objext
- k=`expr $k + 1`
- output=$output_objdir/$save_output-${k}.$objext
- objlist=$obj
- len=1
- fi
- done
- # Handle the remaining objects by creating one last
- # reloadable object file. All subsequent reloadable object
- # files will link in the last one created.
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
-
- # Set up a command to remove the reloadale object files
- # after they are used.
- i=0
- while test $i -lt $k
- do
- i=`expr $i + 1`
- delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
- done
! $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"
! eval cmd=\"$cmd\"
! $show "$cmd"
! $run eval "$cmd" || exit $?
! done
! IFS="$save_ifs"
! libobjs=$output
# Restore the value of output.
! output=$save_output
if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
--- 3295,3381 ----
delfiles=
last_robj=
k=1
! if test "$with_gnu_ld" = yes; then
! output=${output_objdir}/${output_la}.lnkscript
! $echo "creating GNU ld script: $output"
! $echo 'INPUT (' > $output
! for obj in $save_libobjs
! do
! $echo \""$obj"\" >> $output
! done
! $echo ')' >> $output
! delfiles="$delfiles $output"
! elif test "X$file_list_spec" != X; then
! output=${output_objdir}/${output_la}.lnk
! $echo "creating linker input file list: $output"
! : > $output
! for obj in $save_libobjs
! do
! $echo "$obj" >> $output
! done
! delfiles="$delfiles $output"
! output=\"$file_list_spec$output\"
! else
! $echo "creating reloadable object files..."
! output=$output_objdir/$save_output-${k}.$objext
! # Loop over the list of objects to be linked.
! for obj in $save_libobjs
! do
! eval test_cmds=\"$reload_cmds $objlist $last_robj\"
! if test "X$objlist" = X ||
! { len=`expr "X$test_cmds" : ".*"` &&
! test $len -le $max_cmd_len; }; then
! objlist="$objlist $obj"
! else
! # The command $test_cmds is almost too long, add a
! # command to the queue.
! if test $k -eq 1 ; then
! # The first file doesn't have a previous command to add.
! eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
! else
! # All subsequent reloadable object files will link in
! # the last one created.
! eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
! fi
! last_robj=$output_objdir/$save_output-${k}.$objext
! k=`expr $k + 1`
! output=$output_objdir/$save_output-${k}.$objext
! objlist=$obj
! len=1
! fi
! done
! # Handle the remaining objects by creating one last
! # reloadable object file. All subsequent reloadable object
! # files will link in the last one created.
! test -z "$concat_cmds" || concat_cmds=$concat_cmds~
! eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
!
! # Set up a command to remove the reloadale object files
! # after they are used.
! i=0
! while test $i -lt $k
! do
! i=`expr $i + 1`
! delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
! done
! $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"
! eval cmd=\"$cmd\"
! $show "$cmd"
! $run eval "$cmd" || exit $?
! done
! IFS="$save_ifs"
! fi
!
! libobjs=$output
# Restore the value of output.
! output=$save_output
if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
*************** EOF
*** 3364,3383 ****
cmds=$archive_expsym_cmds
else
cmds=$archive_cmds
! fi
# Append the command to remove the reloadable object files
# to the just-reset $cmds.
! eval cmds=\"\$cmds~$rm $delfiles\"
! fi
! IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
! for cmd in $cmds; do
! IFS="$save_ifs"
eval cmd=\"$cmd\"
! $show "$cmd"
! $run eval "$cmd" || exit $?
! done
! IFS="$save_ifs"
# Restore the uninstalled library and exit
if test "$mode" = relink; then
--- 3388,3407 ----
cmds=$archive_expsym_cmds
else
cmds=$archive_cmds
! fi
# Append the command to remove the reloadable object files
# to the just-reset $cmds.
! eval cmds=\"\$cmds~$rm $delfiles\"
! fi
! IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
! for cmd in $cmds; do
! IFS="$save_ifs"
eval cmd=\"$cmd\"
! $show "$cmd"
! $run eval "$cmd" || exit $?
! done
! IFS="$save_ifs"
# Restore the uninstalled library and exit
if test "$mode" = relink; then