libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

piecewise linking fix


From: Ralf Wildenhues
Subject: piecewise linking fix
Date: Wed, 2 Feb 2005 21:16:40 +0100
User-agent: Mutt/1.5.6+20040907i

I realized that piecewise linking uses relocatable objects.  Seeing that
we may need this for long input lines, I guess I will eventually look at
the other uses again as well (not soon) (there have been bugreports).

But I figured, hey, why not test whether piecewise linking works at all,
by faking a low max_cmd_len.

Below is a patch which adds a test to that extent to branch-1-5, plus a
fix for the bug it uncovered, very similarly to how that was already
done in branch-2-0.  OK to apply to 1-5?  If you disagree with the test,
I can also just check in the directory fix.

Forward-port of the test will follow.

(It may be that someone actually reported this issue, and also a patch,
but I don't remember and can't find it now.)

Regards,
Ralf

        * ltmain.in (link mode): With piecewise (partial) linking, fix
        intermediate output name for subdir-objects.  Backport from
        branch-2-0.
        * tests/Makefile.am, tests/reload.test: New test for this.

Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/Attic/ltmain.in,v
retrieving revision 1.334.2.52
diff -u -r1.334.2.52 ltmain.in
--- ltmain.in   1 Feb 2005 07:35:38 -0000       1.334.2.52
+++ ltmain.in   2 Feb 2005 20:00:41 -0000
@@ -3907,6 +3907,7 @@
            save_libobjs=$libobjs
          fi
          save_output=$output
+         output_la=`$echo "X$output" | $Xsed -e "$basename"`
 
          # Clear the reloadable object creation command queue and
          # initialize k to one.
@@ -3916,7 +3917,7 @@
          delfiles=
          last_robj=
          k=1
-         output=$output_objdir/$save_output-${k}.$objext
+         output=$output_objdir/$output_la-${k}.$objext
          # Loop over the list of objects to be linked.
          for obj in $save_libobjs
          do
@@ -3936,9 +3937,9 @@
                # the last one created.
                eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist 
$last_robj\"
              fi
-             last_robj=$output_objdir/$save_output-${k}.$objext
+             last_robj=$output_objdir/$output_la-${k}.$objext
              k=`expr $k + 1`
-             output=$output_objdir/$save_output-${k}.$objext
+             output=$output_objdir/$output_la-${k}.$objext
              objlist=$obj
              len=1
            fi
@@ -3958,13 +3959,13 @@
            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"
          do
            i=`expr $i + 1`
-           delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
+           delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
          done
 
          $echo "creating a temporary reloadable object file: $output"
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/Makefile.am,v
retrieving revision 1.32.2.3
diff -u -r1.32.2.3 Makefile.am
--- tests/Makefile.am   26 Jan 2005 17:53:51 -0000      1.32.2.3
+++ tests/Makefile.am   2 Feb 2005 20:00:41 -0000
@@ -46,7 +46,7 @@
        pdemo-make.test pdemo-exec.test pdemo-inst.test \
        mdemo-conf.test mdemo-make.test mdemo2-conf.test \
        mdemo2-make.test mdemo2-exec.test \
-       func_extract_archives.test 
+       func_extract_archives.test reload.test
 
 
 if HAVE_CXX
--- /dev/null   2005-01-02 13:09:49.000000000 +0100
+++ tests/reload.test   2005-02-02 20:00:34.000000000 +0100
@@ -0,0 +1,35 @@
+#! /bin/sh
+# reload.test - check whether putting the command line together in pieces works
+
+# Test script header.
+need_prefix=yes
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+
+set -e
+
+objdir='reload-test-dir'
+rm -rf $objdir
+mkdir $objdir
+
+# Create a new libtool script that has a low max_cmd_len
+sed 's/^max_cmd_len=.*$/max_cmd_len=10/' < $libtool > $objdir/libtool
+chmod +x $objdir/libtool
+
+libtool=$objdir/libtool
+
+for i in 1 2 3 4 5
+do
+  echo "int x$i = 42;" > $objdir/$i.c
+  $libtool --mode=compile $CC -c -o $objdir/$i.lo $objdir/$i.c
+done
+
+$libtool --mode=link $CC -o $objdir/libfoo.la $objdir/*.lo
+$libtool --mode=link $CC -o $objdir/libfoo.la $objdir/*.lo -rpath /nonexistent
+
+rm -rf $objdir
+exit 0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]