[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Piecewise linking with GNU ld scripts
From: |
Paolo Bonzini |
Subject: |
[PATCH] Piecewise linking with GNU ld scripts |
Date: |
Mon, 23 Aug 2004 16:52:28 +0200 |
User-agent: |
Mozilla Thunderbird 0.5 (Windows/20040207) |
I ported this over from GCC's custom libtool (which I hope to get rid of
some time, since GCC has entirely switched to Autoconf 2.5x now), is it
ok for HEAD?
I attach a 'diff -u' and a 'diff -ub' patch for ease of review.
How am I supposed to test it, apart from 'make check' which does not
test this path?
Paolo
2004-08-23 Paolo Bonzini <address@hidden>
* config/ltmain.in (piecewise linking): Use a GNU ld script if
possible.
* m4/libtool.m4 (_LT_LINKER_SHLIBS): Add per-tag variable
with_gnu_ld.
(_LT_LANG_CXX_CONFIG): Don't set unused variable with_gnu_ldcxx.
? build
? config-h.in
? config/compile
? config/config.guess
? config/config.sub
? config/depcomp
? libltdl/loaders/Makefile.in
? m4/ltversion.m4
Index: config/ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.in,v
retrieving revision 1.2
diff -u -b -r1.2 ltmain.in
--- config/ltmain.in 3 Aug 2004 14:54:34 -0000 1.2
+++ config/ltmain.in 23 Aug 2004 13:21:56 -0000
@@ -4222,8 +4222,8 @@
test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
:
else
- # The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker script
# Save the value of $output and $libobjs because we want to
# use them later. If we have whole_archive_flag_spec, we
@@ -4247,6 +4247,18 @@
delfiles=
last_robj=
k=1
+
+ if test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnk
+ $echo "creating GNU ld script: $output"
+ $echo 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ $echo \""$obj"\" >> $output
+ done
+ $echo ')' >> $output
+ else
+ $echo "creating reloadable object files..."
output=$output_objdir/$output_la-${k}.$objext
# Loop over the list of objects to be linked.
for obj in $save_libobjs
@@ -4289,7 +4301,7 @@
eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
fi
- # Set up a command to remove the reloadale object files
+ # Set up a command to remove the reloadable object files
# after they are used.
i=0
while test "$i" -lt "$k"
@@ -4317,6 +4329,7 @@
}
done
IFS="$save_ifs"
+ fi
libobjs=$output
# Restore the value of output.
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.91
diff -u -b -r1.91 libtool.m4
--- m4/libtool.m4 22 Aug 2004 22:02:07 -0000 1.91
+++ m4/libtool.m4 23 Aug 2004 13:21:56 -0000
@@ -4218,6 +4218,8 @@
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
_LT_DECL([], [extract_expsyms_cmds], [2],
@@ -4302,6 +4304,8 @@
[Commands used to build a loadable module if different from building
a shared archive.])
_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([with_gnu_ld], [with_gnu_ld], [1],
+ [Whether we are using GNU ld or not])
_LT_TAGDECL([], [allow_undefined_flag], [1],
[Flag that allows shared libraries with undefined symbols to be built])
_LT_TAGDECL([], [no_undefined_flag], [1],
@@ -5377,7 +5381,6 @@
LDCXX=$LD
LD=$lt_save_LD
GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
with_gnu_ld=$lt_save_with_gnu_ld
lt_cv_path_LDCXX=$lt_cv_path_LD
lt_cv_path_LD=$lt_save_path_LD
Index: config/ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.in,v
retrieving revision 1.2
diff -u -r1.2 ltmain.in
--- config/ltmain.in 3 Aug 2004 14:54:34 -0000 1.2
+++ config/ltmain.in 23 Aug 2004 11:35:33 -0000
@@ -4222,8 +4222,8 @@
test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
:
else
- # The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker script
# Save the value of $output and $libobjs because we want to
# use them later. If we have whole_archive_flag_spec, we
@@ -4247,76 +4247,89 @@
delfiles=
last_robj=
k=1
- output=$output_objdir/$output_la-${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\"
+
+ if test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnk
+ $echo "creating GNU ld script: $output"
+ $echo 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ $echo \""$obj"\" >> $output
+ done
+ $echo ')' >> $output
+ else
+ $echo "creating reloadable object files..."
+ output=$output_objdir/$output_la-${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
- # All subsequent reloadable object files will link in
- # the last one created.
- eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist
$last_robj\"
+ # 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/$output_la-${k}.$objext
+ k=`expr $k + 1`
+ output=$output_objdir/$output_la-${k}.$objext
+ objlist=$obj
+ len=1
fi
- last_robj=$output_objdir/$output_la-${k}.$objext
- k=`expr $k + 1`
- output=$output_objdir/$output_la-${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\"
-
- if ${skipped_export-false}; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
- fi
-
- # 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/$output_la-${i}.$objext"
- done
-
- $echo "creating a temporary reloadable object file: $output"
+ 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\"
+
+ if ${skipped_export-false}; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $run $rm $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+ fi
+
+ # Set up a command to remove the reloadable object files
+ # after they are used.
+ i=0
+ while test "$i" -lt "$k"
+ do
+ i=`expr $i + 1`
+ delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
+ done
- # Loop through the commands generated above and execute them.
- save_ifs="$IFS"; IFS='~'
- for cmd in $concat_cmds; do
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || {
- lt_exit=$?
+ $echo "creating a temporary reloadable object file: $output"
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv
${realname}U $realname)'
- fi
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ $run eval '(cd $output_objdir && $rm ${realname}T && $mv
${realname}U $realname)'
+ fi
- exit $lt_exit
- }
- done
- IFS="$save_ifs"
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+ fi
libobjs=$output
# Restore the value of output.
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.91
diff -u -r1.91 libtool.m4
--- m4/libtool.m4 22 Aug 2004 22:02:07 -0000 1.91
+++ m4/libtool.m4 23 Aug 2004 11:35:34 -0000
@@ -4218,6 +4218,8 @@
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
_LT_DECL([], [extract_expsyms_cmds], [2],
@@ -4302,6 +4304,8 @@
[Commands used to build a loadable module if different from building
a shared archive.])
_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([with_gnu_ld], [with_gnu_ld], [1],
+ [Whether we are using GNU ld or not])
_LT_TAGDECL([], [allow_undefined_flag], [1],
[Flag that allows shared libraries with undefined symbols to be built])
_LT_TAGDECL([], [no_undefined_flag], [1],
@@ -5377,7 +5381,6 @@
LDCXX=$LD
LD=$lt_save_LD
GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
with_gnu_ld=$lt_save_with_gnu_ld
lt_cv_path_LDCXX=$lt_cv_path_LD
lt_cv_path_LD=$lt_save_path_LD
- [PATCH] Piecewise linking with GNU ld scripts,
Paolo Bonzini <=