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] Re: Bootstrap make -- tries to compile c++ too soon


On Thu, May 25, 2000 at 11:04:04PM -0700, Donn Terry wrote:
> The change by HJL on 5/20 to cp/Make-lang.in causes c++ to be made
> too soon (even with LANGUAGES=c  (only)).  In my case, the compiler
> options used for C++ are incompatible with the bootstrap compiler, and
> this change introduces a dependency on the C++ compiler actually
> having been built.  The rule body clearly is testing for whether LANGUAGES
> intends to include C++, but the dependency is too strong.

The change on 5/20 is papering over the real problem, which is that
we're lying to Make about the dependencies of libgcc.a.  I'll describe
the situation as it was before HJ's patch.  Keep your eye on the pea...

libgcc.a depends on libgcc.mk, libgcc2.ready, and some other stuff.
libgcc.mk depends on xgcc, $(LIB2ADD), and some other stuff.
libgcc2.ready depends on $(GCC_PASSES) and the fixed headers. 

LIB2ADD contains $(LANG_LIB2FUNCS), which in a normal all-languages
configuration is set by configure to include cplib2.txt.  GCC_PASSES
lists cc1, cpp, xgcc, etc. but not cc1plus or any other non-C front
end.  When libgcc.mk is created, it is told that it must compile all
the sources named by cplib2.txt into libgcc.a.

Over in cp/Make-lang.in, cplib2.txt depends on $(CXX_LIB2SRCS),
$(CXX_EXTRA_HEADERS), and cplib2.ready.  cplib2.ready depends on a
bunch of random junk, not including cc1plus.  The rule for cplib2.txt
creates an empty file if $(LANGUAGES) doesn't contain "c++" and a list
of source files if it does.  Some of those source files are in C++.

Therefore, if and only if LANGUAGES contains "c++", libgcc.a can't be
built without cc1plus.  But cc1plus is nowhere in the dependencies of
libgcc.a.  Given a sufficiently parallel build, in stage2 we could
try to compile (e.g.) tinfo.cc before cc1plus had been created.

HJ's patch added cc1plus to a convenient position of the dependency
tree - cplib2.ready - which fixed the problem in stage2.  But cc1plus
is then depended on irrespective of the value of LANGUAGES, so we try
to build it in stage1.

The _proper_ fix, IMHO, is to make libgcc.a, or actually libgcc2.ready, 
depend directly on $(LANGUAGES) as well as $(GCC_PASSES).  That is
slightly stronger than necessary but should be safe.  Also, cplib2.ready
is unnecessary as far as I can tell, it serves only to confuse the
issue.

The appended patch works for me insofar as it prevents cc1plus being
built during stage1.  I haven't bootstrapped it yet.  Also, testing
make -j on an SMP box would be a good idea.

zw

	* Makefile.in (libgcc2.ready): Rename to libgcc.ready.
	Depend on $(LANGUAGES) as well as $(GCC_PATCHES) and fixed
	headers.
	(libgcc.mk): Don't depend on xgcc.
	(clean): No need to delete libgcc1.a, libgcc1-asm.a,
	libgcc2.a, or libgcc1.null.

cp:
	* Make-lang.in (cplib2.ready): Eradicate.

===================================================================
Index: Makefile.in
--- Makefile.in	2000/05/25 15:21:49	1.452
+++ Makefile.in	2000/05/27 00:13:17
@@ -159,7 +159,7 @@ USER_H = $(srcdir)/ginclude/stdarg.h $(s
 # want to set this empty.
 INSTALL_ASSERT_H = install-assert-h
 
-# The GCC to use for compiling libgcc2.a, enquire, and libgcc1-test.
+# The GCC to use for compiling libgcc.a, enquire, and libgcc1-test.
 # Usually the one we just built.
 # Don't use this as a dependency--use $(GCC_PASSES) or $(GCC_PARTS).
 GCC_FOR_TARGET = ./xgcc -B$(build_tooldir)/bin/ -B./ -isystem $(build_tooldir)/include
@@ -947,16 +947,16 @@ xlimits.h: glimits.h limitx.h limity.h
 # Compiling libgcc2.a requires making sure that cc1, etc. have been compiled.
 # But recompiling cc1 should not force recompilation of libgcc2.a.
 # If you want to force recompilation, delete libgcc2.a.
-libgcc2.ready: $(GCC_PASSES) stmp-int-hdrs $(STMP_FIXPROTO)
-	-if [ -f libgcc2.ready ] ; then \
+libgcc.ready: $(GCC_PASSES) $(LANGUAGES) stmp-int-hdrs $(STMP_FIXPROTO)
+	-if [ -f libgcc.ready ] ; then \
 		true; \
 	else \
-		touch libgcc2.ready; \
+		touch libgcc.ready; \
 	fi
 
 LIB2ADD = $(LIB2ADDEH) $(LIB2FUNCS_EXTRA) $(LANG_LIB2FUNCS)
 
-libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) xgcc$(exeext)
+libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD)
 	objext='$(objext)' \
 	OLDCC='$(OLDCC)' \
 	LIBGCC1='$(LIBGCC1)' \
@@ -975,7 +975,7 @@ libgcc.mk: config.status Makefile mklibg
 	  $(SHELL) mklibgcc > tmp-libgcc.mk
 	$(SHELL) $(srcdir)/move-if-change tmp-libgcc.mk libgcc.mk
 
-libgcc.a: libgcc2.ready libgcc.mk $(FPBIT) $(DPBIT)
+libgcc.a: libgcc.ready libgcc.mk $(FPBIT) $(DPBIT)
 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
 	  HOST_PREFIX="$(HOST_PREFIX)" HOST_PREFIX_1="$(HOST_PREFIX_1)" \
 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
@@ -1006,7 +1006,7 @@ s-mlib: $(srcdir)/genmultilib Makefile
 	touch s-mlib
 
 # Build multiple copies of libgcc.a, one for each target switch.
-stmp-multilib: libgcc2.ready libgcc.mk $(FPBIT) $(DPBIT)
+stmp-multilib: libgcc.ready libgcc.mk $(FPBIT) $(DPBIT)
 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
 	  HOST_PREFIX="$(HOST_PREFIX)" HOST_PREFIX_1="$(HOST_PREFIX_1)" \
 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
@@ -2139,8 +2139,7 @@ mostlyclean: $(INTL_MOSTLYCLEAN) lang.mo
 # that don't exist in the distribution.
 INTL_CLEAN = intl.clean
 clean: mostlyclean $(INTL_CLEAN) lang.clean
-	-rm -f libgcc.a libgcc1.a libgcc1-asm.a libgcc2.a libgcc2.ready
-	-rm -f libgcc1.null
+	-rm -f libgcc.a libgcc.ready
 	-rm -f *.dvi
 	-rm -f */*.dvi
 	-if [ -f md.pre-cpp ]; then \
===================================================================
Index: cp/Make-lang.in
--- cp/Make-lang.in	2000/05/20 11:36:23	1.50
+++ cp/Make-lang.in	2000/05/27 00:13:17
@@ -178,7 +178,7 @@ vec.o: cc1plus$(exeext) $(srcdir)/cp/vec
 	  -c $(srcdir)/cp/vec.cc -o vec.o
 
 # We want to update cplib2.txt if any of the source files change...
-cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
+cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS)
 	case " $(LANGUAGES) " in \
 	*" "[cC]"++ "*) \
 	  echo $(CXX_LIB2FUNCS) > cplib2.new;; \
@@ -187,27 +187,6 @@ cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_
 	esac
 	mv -f cplib2.new cplib2.txt 
 
-# Or if it would be different.
-# Don't try to do write if `.' is not writable;
-# in that case, we're installing from someone else's directory.
-# But go ahead and fail if that directory hasn't been properly built.
-cplib2.ready: $(GCC_PASSES) stmp-int-hdrs $(STMP_FIXPROTO) cc1plus$(exeext)
-	@if [ -r cplib2.txt -a -w . ]; then \
-	  case " $(LANGUAGES) " in \
-	  *" "[cC]"++ "*) \
-	    echo $(CXX_LIB2FUNCS) > cplib2.new;; \
-	  *) \
-	    echo "" > cplib2.new;; \
-	  esac; \
-	  if cmp -s cplib2.new cplib2.txt; then true; else \
-	    touch cplib2.ready; \
-	  fi; \
-	  rm -f cplib2.new; \
-	else true ; \
-	fi
-	@if [ -f cplib2.ready ]; then true; else \
-	  touch cplib2.ready; \
-	fi
 #
 # Install hooks:
 # cc1plus is installed elsewhere as part of $(COMPILERS).
@@ -277,7 +256,7 @@ c++.uninstall:
 c++.mostlyclean:
 	-rm -f cp/*$(objext) $(DEMANGLER_PROG)
 c++.clean:
-	-rm -f cplib2.txt cplib2.ready
+	-rm -f cplib2.txt
 c++.distclean:
 	-rm -f cp/config.status cp/Makefile
 	-rm -f cp/parse.output

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