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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH (libtool): Improper libgcj.a construction with modern GNU ar


(...as seen on systems with <~64K command line length limit.)

This is a proper patch for the issue discussed here:

- Report of issue on Darwin: http://gcc.gnu.org/ml/java/2002-01/msg00005.html
- Key message of thread: http://gcc.gnu.org/ml/java/2002-01/msg00037.html
- Rereport of issue on FreeBSD: http://gcc.gnu.org/ml/java/2002-04/msg00338.html

Rebuilt libjava on i386-unknown-freebsd4.5.  -static linking now works
(it makes no sense discussing regressions since it wasn't even usable
out of the default bootstrap tree before).  Given the construction of
this patch, the new code will only ever run when piecewise linking is
being done; AR_FLAGS will only be overridden with a warning when an
object name conflict is actually detectable.  No effort was made to
refine it to detect when conflicts only exist across the actual
piecewise ar commands.  I rejected sorting the object list on the
basename since (a) I didn't know if that was legal or good thing to
do; (b) due to exact placement, a piecewise break points could still
straddle objects with the same name without reworking the command line
break code.

(For good measure, I radically lowered max_cmd_len to 1000; and
 rebuilt libstdc++-v3.  This forced piecewise linking of libstdc++.a
 but since no object name conflicts exist here; it didn't override
 AR_FLAGS.)

Permission to apply to gcc mainline?

	* ltmain.sh: Detect and handle object name conflicts
	while piecewise linking a static library.

Index: ltmain.sh
===================================================================
RCS file: /cvs/gcc/gcc/ltmain.sh,v
retrieving revision 1.19
diff -c -r1.19 ltmain.sh
*** ltmain.sh	16 Mar 2002 14:42:17 -0000	1.19
--- ltmain.sh	3 May 2002 03:39:18 -0000
***************
*** 4247,4252 ****
--- 4247,4266 ----
            objlist=
            concat_cmds=
            save_oldobjs=$oldobjs
+ 	  # GNU ar 2.10+ was changed to match POSIX; thus no paths are
+ 	  # encoded into archives.  This makes 'ar r' malfunction in
+ 	  # this piecewise linking case whenever conflicting object
+ 	  # names appear in distinct ar calls; check, warn and compensate.
+           if (for obj in $save_oldobjs
+ 	    do
+ 	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
+ 	    done | sort | sort -uc >/dev/null 2>&1); then
+ 	    :
+ 	  else
+ 	    $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
+ 	    $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
+ 	    AR_FLAGS=cq
+ 	  fi
            for obj in $save_oldobjs
            do
              oldobjs="$objlist $obj"


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