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]
Other format: [Raw text]

libf2c: use -objectlist instead of convenience libraries


I had formerly suggested us to use libtool convenience libraries to
avoid exceeding command-line length limitations of some OSs.  Later
on, it occurred to me that there was a simpler solution, using
libtool's -objectlist.  I've finally found time to implement it.

This gives us a minor gain in build- and run-time performance.  The
former, because building convenience libraries just to often extract
them back at the time of creating the entire archive is a waste, and
because convenience libraries are PIC-only if PIC is available, so
even the static version of libg2c.a would contain PIC, which may hurt
performance on register-starved machines.

Besides, I find this mechanism of merging multiple libraries simpler.

While I was at it, I fixed some configury code such that make would
work from within <target_alias>/libf2c.  Before, we'd fail to create
libfrtbegin.a if we didn't get RANLIB from the top level.  The same
problem might occur for AR if make didn't provide a built-in
definition of it.  I've also fixed a minor portability problem in the
libfrtbegin.a build rule.

I have also removed the bogus install command I've just mentioned in a
message posted to gcc@gcc.gnu.org.

Tested on athlon-pc-linux-gnu.  Toon, ok to install?  Ok to back-port
to 3.0 branch?

Index: libf2c/ChangeLog
from   Alexandre Oliva  <aoliva@redhat.com>

	* Makefile.in (AR, RANLIB): Add, for substitutions.
	(all-unilib, $(LIBG2C)): Depend on object lists, not
	convenience libraries.
	(s-libe77): Renamed from libE77.la; build object list.
	(install): Do not move libraries to libdir.
	(mostlyclean, clean): Adjust.
	* libF77/Makefile.in (RANLIB): Add.
	(LINK): Remove.
	(../s-libf77): Renamed from ../libF77.la; build object list.
	(../libfrtbegin.a): Remove target first.  Don't use $<.
	(all, clean, distclean): Adjust.
	* libF77/configure.in: Substitute RANLIB.
	* libF77/configure: Rebuilt.
	* libI77/Makefile.in (LINK): Delete.
	(../s-libi77): Renamed from ../libI77.la; build object list.
	(all, clean, distclean): Adjust.
	* libU77/Makefile.in: Likewise.

Index: libf2c/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libf2c/Makefile.in,v
retrieving revision 1.41
diff -u -p -r1.41 Makefile.in
--- libf2c/Makefile.in 2001/11/16 21:29:29 1.41
+++ libf2c/Makefile.in 2001/12/02 19:35:17
@@ -1,5 +1,5 @@
 # Makefile for GNU F77 compiler runtime.
-#   Copyright (C) 1995-1998 Free Software Foundation, Inc.
+#   Copyright (C) 1995-1998, 2001 Free Software Foundation, Inc.
 #   Contributed by Dave Love (d.love@dl.ac.uk).
 #
 #This file is part of GNU Fortran.
@@ -61,6 +61,8 @@ INSTALL_DATA = @INSTALL_DATA@
 LIBTOOL = @LIBTOOL@
 CC = @CC@
 CFLAGS = @CFLAGS@
+AR = @AR@
+RANLIB = @RANLIB@
 
 # List of variables to pass to sub-makes.
 # Quote this way so that it can be used to set shell variables too.
@@ -118,24 +120,34 @@ all: all-unilib
 # meant to be invoked via multi-do for multilibs.
 
 # Its dependencies can be satisfied in parallel.  The [fiu]77 targets
-# always invoke sub makes to check dependencies in the subdirs, else we'd
+# update stamp files (object file lists, actually, see the subdir
+# makefiles) on which the $(LIBG2C) depends.  The stamp files
+# s-lib[fiu]77 are intentionally not targets, since we're only meant
+# to come in at the level of this target.  The [fiu]77 targets always
+# invoke sub makes to check dependencies in the subdirs, else we'd
 # have to maintain them at this level; we live with the overhead of
 # some recursive makes which may do nothing.
 
-all-unilib: i77 f77 u77 libE77.la
+all-unilib: i77 f77 u77 s-libe77
 	$(MAKE) $(FLAGS_TO_PASS) $(LIBG2C)
 
 i77 f77 u77: g2c.h
 
 # This target should normally only get invoked via `all-unilib' --
 # after all's well in the subdirs -- actually to assemble the library.
+# The stamp files contain the object lists of each component of the
+# library.  The point of breaking them up is to avoid command-line
+# length limitations.
 
-$(LIBG2C): libF77.la libI77.la libU77.la libE77.la
-	rm -f $@ ;\
-	set -e; \
+$(LIBG2C): s-libi77 s-libf77 s-libu77 s-libe77
 	$(LIBTOOL) --mode=link $(CC) -o $@ \
 	  -version-info $(VERSION_MAJOR):$(VERSION_MINOR):$(VERSION_SUB) \
-	  -rpath $(prefix)/lib libE77.la libF77.la libI77.la libU77.la -lc -lm
+	  -rpath $(prefix)/lib \
+	  -objectlist s-libe77 \
+	  -objectlist s-libf77 \
+	  -objectlist s-libi77 \
+	  -objectlist s-libu77 \
+	  -lc -lm
 
 i77:
 	cd libI77; $(MAKE) $(FLAGS_TO_PASS) all
@@ -146,18 +158,19 @@ f77:
 u77:
 	cd libU77; $(MAKE) $(FLAGS_TO_PASS) all
 
-libE77.la: f2cext.c
-	rm -f $@
+s-libe77: f2cext.c
 	if [ -d libE77 ]; then rm -f libE77/*.o libE77/*.lo; else mkdir libE77; fi
+	-rm -f $@.T $@
 	for name in $(F2CEXT); \
 	do \
 	  echo $${name}; \
 	  $(LIBTOOL) --mode=compile $(CC) -c -I. -I$(srcdir) -I../../include \
 	    $(CPPFLAGS) $(CFLAGS) -DL$${name} $(srcdir)/f2cext.c \
-	    -o libE77/L$${name}.o ; \
+	    -o libE77/L$${name}.lo ; \
 	  if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
+	  echo libE77/L$${name}.lo >> $@.T; \
 	done
-	$(LIBTOOL) --mode=link $(CC) -o libE77.la libE77/*.lo
+	mv $@.T $@
 
 f2cext.c: g2c.h
 
@@ -192,7 +205,6 @@ check:
 
 install: all
 	$(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIBG2C) $(libsubdir)/$(MULTISUBDIR)
-	(cd $(libsubdir)/$(MULTISUBDIR) ; mv -f $(LIBG2C_BASE).* $(prefix)/lib)
 	$(INSTALL_DATA) libfrtbegin.a $(libsubdir)/$(MULTISUBDIR)
 	$(RANLIB) $(libsubdir)/$(MULTISUBDIR)/libfrtbegin.a
 	$(INSTALL_DATA) g2c.h $(libsubdir)/include/g2c.h
@@ -220,7 +232,7 @@ mostlyclean:
 	rm -f $(LIBG2C) objlist
 	$(MAKE) DO=$@ DODIRS="$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do; \
 	$(MULTICLEAN) multi-clean DO=$@
-	rm -fr libE77 libE77.la
+	rm -fr libE77 s-libe77
 
 clean: mostlyclean
 	rm -f config.log
@@ -229,7 +241,7 @@ clean: mostlyclean
 	rm -rf .libs
 
 distclean: clean
-	rm -f g2c.h libE77.la
+	rm -f g2c.h s-libe77
 	$(MAKE) DO=$@ DODIRS="$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do; \
 	$(MULTICLEAN) multi-clean DO=distclean
 	rm -f config.cache config.status Makefile
Index: libf2c/libF77/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libf2c/libF77/Makefile.in,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile.in
--- libf2c/libF77/Makefile.in 2001/11/25 19:12:50 1.14
+++ libf2c/libF77/Makefile.in 2001/12/02 19:35:17
@@ -1,7 +1,7 @@
 # Makefile for GNU F77 compiler runtime.
 # Copyright 1990 - 1994 by AT&T Bell Laboratories and Bellcore (see the
 # file `Notice').
-# Portions of this file Copyright (C) 1995-1998 Free Software Foundation, Inc.
+# Portions of this file Copyright (C) 1995-1998, 2001 Free Software Foundation, Inc.
 #   Contributed by Dave Love (d.love@dl.ac.uk).
 #
 #This file is part of GNU Fortran.
@@ -38,6 +38,7 @@ CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 AR = @AR@
 ARFLAGS = rc
+RANLIB = @RANLIB@
 @SET_MAKE@
 
 SHELL = /bin/sh
@@ -52,8 +53,6 @@ ALL_CFLAGS = -I. -I$(srcdir) -I$(G2C_H_D
 .c.lo:
 	@LIBTOOL@ --mode=compile $(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $<
 
-LINK = @LIBTOOL@ --mode=link $(CC) -o $@
-
 MISC =	F77_aloc.lo VersionF.lo s_rnge.lo abort_.lo getarg_.lo iargc_.lo\
 	getenv_.lo signal_.lo s_stop.lo s_paus.lo system_.lo cabs.lo\
 	derf_.lo derfc_.lo erf_.lo erfc_.lo sig_die.lo exit_.lo setarg.lo setsig.lo
@@ -80,10 +79,13 @@ F90BIT = lbitbits.lo lbitshft.lo qbitbit
 OBJS = $(MISC) $(POW) $(CX) $(DCX) $(REAL) $(DBL) $(INT) \
 	 $(HALF) $(CMP) $(EFL) $(CHAR) $(F90BIT)
 
-all: ../libF77.la ../libfrtbegin.a
+all: ../s-libf77 ../libfrtbegin.a
 
-../libF77.la: $(OBJS)
-	$(LINK) $(OBJS)
+../s-libf77: $(OBJS)
+	-rm -f $@.T $@
+	objs='$(OBJS)'; for name in $$objs; do \
+	  echo libF77/$${name} >> $@.T; done
+	mv $@.T $@
 
 Makefile: Makefile.in config.status
 	$(SHELL) config.status
@@ -104,7 +106,8 @@ frtbegin.o : main.c
 	$(CC) -c $(ALL_CFLAGS) $(srcdir)/main.c -o $@
 
 ../libfrtbegin.a: frtbegin.o
-	$(AR) $(ARFLAGS) $@ $<
+	-rm -f $@
+	$(AR) $(ARFLAGS) $@ frtbegin.o
 	$(RANLIB) $@
 
 F77_aloc.lo: F77_aloc.c
@@ -241,10 +244,10 @@ mostlyclean:
 
 clean: mostlyclean
 	rm -f config.log
-	rm -f ../libF77.la
+	rm -f ../s-libf77
 
 distclean: clean
-	rm -f config.cache config.status Makefile ../libF77.la configure
+	rm -f config.cache config.status Makefile ../s-libf77 configure
 
 maintainer-clean:
 
Index: libf2c/libF77/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libf2c/libF77/configure.in,v
retrieving revision 1.5
diff -u -p -r1.5 configure.in
--- libf2c/libF77/configure.in 2001/09/30 22:06:22 1.5
+++ libf2c/libF77/configure.in 2001/12/02 19:35:18
@@ -1,5 +1,5 @@
 # Process this file with autoconf to produce a configure script.
-#   Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+#   Copyright (C) 1995, 1997, 1998, 2001 Free Software Foundation, Inc.
 #   Contributed by Dave Love (d.love@dl.ac.uk).
 #
 #This file is part of GNU Fortran.
@@ -37,6 +37,11 @@ AC_SUBST(LIBTOOL)
 
 test "$AR" || AR=ar
 AC_SUBST(AR)
+if test "$RANLIB"; then :
+  AC_SUBST(RANLIB)
+else
+  AC_PROG_RANLIB
+fi
 AC_PROG_MAKE_SET
 
 dnl Checks for libraries.
Index: libf2c/libI77/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libf2c/libI77/Makefile.in,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.in
--- libf2c/libI77/Makefile.in 2001/11/13 00:55:38 1.16
+++ libf2c/libI77/Makefile.in 2001/12/02 19:35:18
@@ -51,18 +51,19 @@ ALL_CFLAGS = -I. -I$(srcdir) -I$(G2C_H_D
 .c.lo:
 	@LIBTOOL@ --mode=compile $(CC) -c -DSkip_f2c_Undefs -DAllow_TYQUAD $(ALL_CFLAGS) $<
 
-LINK = @LIBTOOL@ --mode=link $(CC) -o $@
-
 OBJS =	VersionI.lo backspace.lo close.lo dfe.lo dolio.lo due.lo endfile.lo err.lo \
 	fmt.lo fmtlib.lo iio.lo ilnw.lo inquire.lo lread.lo lwrite.lo open.lo \
 	rdfmt.lo rewind.lo rsfe.lo rsli.lo rsne.lo sfe.lo sue.lo typesize.lo uio.lo \
 	util.lo wref.lo wrtfmt.lo wsfe.lo wsle.lo wsne.lo xwsne.lo \
 	ftell_.lo
 
-all: ../libI77.la
+all: ../s-libi77
 
-../libI77.la: $(OBJS)
-	$(LINK) $(OBJS)
+../s-libi77: $(OBJS)
+	-rm -f $@.T $@
+	objs='$(OBJS)'; for name in $$objs; do \
+	  echo libI77/$${name} >> $@.T; done
+	mv $@.T $@
 
 Makefile: Makefile.in config.status
 	$(SHELL) config.status
@@ -157,10 +158,10 @@ mostlyclean:
 	rm -rf .libs
 
 clean: mostlyclean
-	rm -f config.log ../libI77.la
+	rm -f config.log ../s-libi77
 
 distclean: clean
-	rm -f config.cache config.status Makefile ../libI77.la configure
+	rm -f config.cache config.status Makefile ../s-libi77 configure
 
 maintainer-clean:
 
Index: libf2c/libU77/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libf2c/libU77/Makefile.in,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile.in
--- libf2c/libU77/Makefile.in 2001/11/13 00:55:38 1.18
+++ libf2c/libU77/Makefile.in 2001/12/02 19:35:18
@@ -1,5 +1,5 @@
 # Makefile for GNU F77 compiler runtime, libc interface.
-# Copyright (C) 1995-1998 Free Software Foundation, Inc.
+# Copyright (C) 1995-1998, 2001 Free Software Foundation, Inc.
 #   Contributed by Dave Love (d.love@dl.ac.uk).
 #
 #This file is part of the GNU Fortran libU77 library.
@@ -55,8 +55,6 @@ G77DIR = ../../../gcc/
 .c.lo:
 	@LIBTOOL@ --mode=compile $(CC) -c -DSkip_f2c_Undefs $(ALL_CFLAGS) $<
 
-LINK = @LIBTOOL@ --mode=link $(CC) -o $@
-
 OBJS =  VersionU.lo gerror_.lo perror_.lo ierrno_.lo itime_.lo time_.lo \
 	unlink_.lo fnum_.lo getpid_.lo getuid_.lo getgid_.lo kill_.lo rand_.lo \
 	srand_.lo irand_.lo sleep_.lo idate_.lo ctime_.lo etime_.lo \
@@ -78,10 +76,13 @@ SRCS =  Version.c gerror_.c perror_.c ie
 	umask_.c sys_clock_.c date_.c second_.c flush1_.c mclock_.c \
 	alarm_.c datetime_.c
 
-all: ../libU77.la
+all: ../s-libu77
 
-../libU77.la: $(OBJS)
-	$(LINK) $(OBJS)
+../s-libu77: $(OBJS)
+	-rm -f $@.T $@
+	objs='$(OBJS)'; for name in $$objs; do \
+	  echo libU77/$${name} >> $@.T; done
+	mv $@.T $@
 
 Makefile: Makefile.in config.status
 	$(SHELL) config.status
@@ -178,11 +179,11 @@ mostlyclean:
 	rm -rf .libs
 
 clean: mostlyclean
-	rm -f config.log ../libU77.la
+	rm -f config.log ../s-libu77
 
 distclean: clean
 	rm -f config.cache config.status Makefile config.h stamp.h \
-	  ../libU77.la configure
+	  ../s-libu77 configure
 
 maintainer-clean:
 

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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