PATCH: Add libgcj_convenience.list

H . J . Lu hjl@lucon.org
Thu Jun 6 11:52:00 GMT 2002


This patch creats a set of convenience archives for libgcj. It helps
the build on my Linux/mipsel box with only 128MB RAM. Tested on
Linux/x86:

http://gcc.gnu.org/ml/gcc-testresults/2002-06/msg00174.html
http://gcc.gnu.org/ml/gcc-testresults/2002-06/msg00175.html

There are many more libjava failures when --disable-shared is used. But
I don't believe my patch is the real cause.


H.J.
----
2002-06-06  H.J. Lu  (hjl@gnu.org)

	* Makefile.am (CONVLIBLINK): New.
	(libgcj_convenience.list): New target.
	(libgcj.la): Depend on libgcj_convenience.list.
	* Makefile.in: Regenerated.

--- libjava/Makefile.am.link	Tue Jun  4 16:32:44 2002
+++ libjava/Makefile.am	Thu Jun  6 09:22:27 2002
@@ -74,6 +74,7 @@ GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
 GCJCOMPILE = $(LIBTOOL) --tag=GCJ --mode=compile $(GCJ_WITH_FLAGS) -fclasspath= -fbootclasspath=$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
 GCJLINK = $(LIBTOOL) --tag=GCJ --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
 LIBLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXX) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
+CONVLIBLINK = $(LIBTOOL) --mode=link $(CC)
 
 ## We define this because otherwise libtool can be run with different
 ## values of `CXX' and will then get confused and fail to work.  So,
@@ -220,10 +221,46 @@ $(javao_files) $(x_javao_files): %.lo: %
 	$(GCJCOMPILE) -o $@ $<
 
 ## Pass the list of object files to libtool in a temporary file to 
-## avoid tripping platform command line length limits.
-libgcj.la: $(libgcj_la_OBJECTS) $(libgcj_la_DEPENDENCIES)
+## avoid tripping platform command line length limits. We also use
+## libgcj_convenience.list to avoid creating a long linker command line
+## which causes problems on some OSes and makes it almost impossible to
+## debug the linker under a debugger. We can't use a single convenience
+## archive since there are files with the same basename.
+libgcj_convenience.list: $(libgcj_la_OBJECTS) $(libgcj_la_DEPENDENCIES)
 	@: $(shell echo Creating list of files to link...) $(shell rm -f libgcj.objectlist || :) $(shell touch libgcj.objectlist) $(foreach object,$(libgcj_la_OBJECTS) $(libgcj_la_LIBADD),$(shell echo $(object) >> libgcj.objectlist))
-	$(libgcj_la_LINK) -objectlist libgcj.objectlist \
+	@for f in `cat libgcj.objectlist`; do \
+	  echo $$f | sed -e "s,\(.*\)/.*,\1,"; \
+	done | sort | uniq > libgcj.objectlist.dir
+	@for d in `cat libgcj.objectlist.dir`; do \
+	  case $$d in \
+	  *.lo) rm -f gcj.list; touch gcj.list;; \
+	  *) rm -f $$d/gcj.list; touch $$d/gcj.list;; \
+	  esac; \
+	done
+	@for f in `cat libgcj.objectlist`; do \
+	  echo $$f | sed -e "s,\(.*\)/\(.*\),\2 \1,"; \
+	done | while read base dir; do \
+	  if test -n "$$dir"; then \
+	    echo $$dir/$$base >> $$dir/gcj.list; \
+	  else \
+	    echo $$base >> gcj.list; \
+	  fi; \
+	done
+	rm -f libgcj_convenience.list
+	echo libgcj_convenience.la > libgcj_convenience.list
+	$(CONVLIBLINK) -o libgcj_convenience.la -objectlist gcj.list
+	@for d in `cat libgcj.objectlist.dir`; do \
+	  case $$d in \
+	  *.lo);; \
+	  *) \
+	    c=`echo $$d | sed -e "s,/,_,g"`; \
+	    echo lib$${c}_convenience.la >> libgcj_convenience.list; \
+	    $(CONVLIBLINK) -o lib$${c}_convenience.la -objectlist $$d/gcj.list;; \
+	  esac; \
+	done
+
+libgcj.la: libgcj_convenience.list
+	$(libgcj_la_LINK) `cat libgcj_convenience.list` \
 	@GCLIBS@ @LIBFFI@ @ZLIBS@ \
 	-rpath $(toolexeclibdir) $(libgcj_la_LDFLAGS) $(LIBS)
 



More information about the Gcc-patches mailing list