PATCH: Use libgcj_convenience.la failure on darwin 5.5
H . J . Lu
hjl@lucon.org
Wed Jun 5 14:30:00 GMT 2002
On Wed, Jun 05, 2002 at 06:06:25PM -0300, Alexandre Oliva wrote:
> On Jun 5, 2002, "H . J . Lu" <hjl@lucon.org> wrote:
>
> > * ltmain.sh: Handle convenience archives with duplicated
> > members.
>
> Nope. The right way to fix this is to prevent duplicate names to be
> added to an archive in the first place.
>
That is life for libjava. I am testing this patch on gcc 3.1.1 under
Linux with/without --disable-shared now.
H.J.
----
2002-06-05 H.J. Lu (hjl@gnu.org)
* ltmain.sh: Fix piecewise archive linking.
2002-06-05 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.
--- gcc/libjava/Makefile.am.link Tue Jun 4 16:32:44 2002
+++ gcc/libjava/Makefile.am Wed Jun 5 14:21:49 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) --tag=CXX --mode=link $(CXX) -L$(here) $(JC1FLAGS) $(LDFLAGS)
## 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,52 @@ $(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 \
+ $(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 \
+ for d in `cat libgcj.objectlist.dir`; do \
+ if test "$$f" = "$$d"; then \
+ echo $$f >> gcj.list; \
+ break; \
+ else \
+ b=`basename $$f`; \
+ if test "$$f" = $$d/$$b; then \
+ echo $$f >> $$d/gcj.list; \
+ break; \
+ fi; \
+ fi; \
+ done; \
+ 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)
--- gcc/ltmain.sh.link Fri Apr 5 23:24:52 2002
+++ gcc/ltmain.sh Wed Jun 5 14:18:57 2002
@@ -4246,9 +4246,23 @@ fi\
RANLIB=:
objlist=
concat_cmds=
- save_oldobjs=$oldobjs
+ # We have to group files with same basename together. Sort
+ # it by basename first.
+ save_oldobjs=`for obj in $oldobjs
+ do
+ echo $obj | sed -e "s,\(.*\)/\(.*\),\2 \1,"
+ done | sort | while read base dir
+ do
+ if test -n "$dir"; then
+ echo $dir/$base
+ else
+ echo $base
+ fi
+ done`
for obj in $save_oldobjs
do
+ # FIXME: We can't break files with the same basename in
+ # the middle.
oldobjs="$objlist $obj"
objlist="$objlist $obj"
eval test_cmds=\"$old_archive_cmds\"
More information about the Gcc-patches
mailing list