This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Avoid long commands in libtool


(This complements a post to java-patches to prevent build failures
due to long command lines and degenerate shells.)

Libtool now supports `-objectlist' to read its arguments from a file.
This didn't work for me, since it evaluates to

	for fil in `cat $save_arg`

resulting in an excessively long shell command, which is the problem that
-objectlist was supposed to prevent in the first place.

I suggest using the read builtin command to process objectlist a line at a
time, taking care that arguments may be separated by whitespace other
than newlines.

Bootstrapped on 3.0 branch with alphapca56-unknown-linux-gnu.  OK for
trunk and branch?

Jeff
Index: ltmain.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltmain.sh,v
retrieving revision 1.11.4.5
diff -u -r1.11.4.5 ltmain.sh
--- ltmain.sh	2001/05/28 20:46:49	1.11.4.5
+++ ltmain.sh	2001/07/09 05:40:03
@@ -968,100 +968,103 @@
 	  if test -f "$arg"; then
             save_arg=$arg
 	    moreargs=
-	    for fil in `cat $save_arg`
+	    cat $save_arg | while read line
 	    do
-#	      moreargs="$moreargs $fil"
-              arg=$fil
-              # A libtool-controlled object.
-
-	      # Check to see that this really is a libtool object.
-	      if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-                pic_object=
-                non_pic_object=
-
-                # Read the .lo file
-                # If there is no directory component, then add one.
-                case $arg in
-                */* | *\\*) . $arg ;;
-                *) . ./$arg ;;
-                esac
-
-                if test -z "$pic_object" || \
-                   test -z "$non_pic_object" ||
-                   test "$pic_object" = none && \
-                   test "$non_pic_object" = none; then
-                  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
-                  exit 1
-                fi
-
-	        # Extract subdirectory from the argument.
-	        xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-	        if test "X$xdir" = "X$arg"; then
-	          xdir=
-	        else
-	          xdir="$xdir/"
-	        fi
-
-                if test "$pic_object" != none; then
-                  # Prepend the subdirectory the object is found in.
-	          pic_object="$xdir$pic_object"
-
-	          if test "$prev" = dlfiles; then
-	            if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
-	              dlfiles="$dlfiles $pic_object"
-	              prev=
-	              continue
-	            else
-	              # If libtool objects are unsupported, then we need to preload.
-	              prev=dlprefiles
-	            fi
-	          fi
-
-	          # CHECK ME:  I think I busted this.  -Ossama
-                  if test "$prev" = dlprefiles; then
-	            # Preload the old-style object.
-	            dlprefiles="$dlprefiles $pic_object"
-	            prev=
-                  fi
-
-                  # A PIC object.
-	          libobjs="$libobjs $pic_object"
-	          arg="$pic_object"
-                fi
-
-                # Non-PIC object.
-                if test "$non_pic_object" != none; then
-                  # Prepend the subdirectory the object is found in.
-	          non_pic_object="$xdir$non_pic_object"
-
-                  # A standard non-PIC object
-                  non_pic_objects="$non_pic_objects $non_pic_object"
-                  if test -z "$pic_object" || test "$pic_object" = none ; then
-                    arg="$non_pic_object"
-                  fi
-                fi
-              else
-                # Only an error if not doing a dry-run.
-                if test -z "$run"; then
-                  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
-                  exit 1
-                else
-                  # Dry-run case.
-
-	          # Extract subdirectory from the argument.
-	          xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-	          if test "X$xdir" = "X$arg"; then
-	            xdir=
-	          else
-	            xdir="$xdir/"
-	          fi
-
-                  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
-                  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
-	          libobjs="$libobjs $pic_object"
-                  non_pic_objects="$non_pic_objects $non_pic_object"
-                fi
-	      fi
+	      for fil in $line
+	      do
+#		moreargs="$moreargs $fil"
+		arg=$fil
+		# A libtool-controlled object.
+
+		# Check to see that this really is a libtool object.
+		if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+		  pic_object=
+		  non_pic_object=
+
+		  # Read the .lo file
+		  # If there is no directory component, then add one.
+		  case $arg in
+		  */* | *\\*) . $arg ;;
+		  *) . ./$arg ;;
+		  esac
+
+		  if test -z "$pic_object" || \
+		    test -z "$non_pic_object" ||
+		    test "$pic_object" = none && \
+		    test "$non_pic_object" = none; then
+		    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+		    exit 1
+		  fi
+
+		  # Extract subdirectory from the argument.
+		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+		  if test "X$xdir" = "X$arg"; then
+		    xdir=
+		  else
+		    xdir="$xdir/"
+		  fi
+
+		  if test "$pic_object" != none; then
+		    # Prepend the subdirectory the object is found in.
+		    pic_object="$xdir$pic_object"
+
+		    if test "$prev" = dlfiles; then
+		      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+			dlfiles="$dlfiles $pic_object"
+			prev=
+			continue
+		      else
+			# If libtool objects are unsupported, then we need to preload.
+			prev=dlprefiles
+		      fi
+		    fi
+
+		    # CHECK ME:  I think I busted this.  -Ossama
+		    if test "$prev" = dlprefiles; then
+		      # Preload the old-style object.
+		      dlprefiles="$dlprefiles $pic_object"
+		      prev=
+		    fi
+
+		    # A PIC object.
+		    libobjs="$libobjs $pic_object"
+		    arg="$pic_object"
+		  fi
+
+		  # Non-PIC object.
+		  if test "$non_pic_object" != none; then
+		    # Prepend the subdirectory the object is found in.
+		    non_pic_object="$xdir$non_pic_object"
+
+		    # A standard non-PIC object
+		    non_pic_objects="$non_pic_objects $non_pic_object"
+		    if test -z "$pic_object" || test "$pic_object" = none ; then
+		      arg="$non_pic_object"
+		    fi
+		  fi
+		else
+		  # Only an error if not doing a dry-run.
+		  if test -z "$run"; then
+		    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+		    exit 1
+		  else
+		    # Dry-run case.
+
+		    # Extract subdirectory from the argument.
+		    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+		    if test "X$xdir" = "X$arg"; then
+		      xdir=
+		    else
+		      xdir="$xdir/"
+		    fi
+
+		    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+		    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+		    libobjs="$libobjs $pic_object"
+		    non_pic_objects="$non_pic_objects $non_pic_object"
+		  fi
+		fi
+	      done
 	    done
 	  else
 	    $echo "$modename: link input file \`$save_arg' does not exist"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]