This is the mail archive of the gcc@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]

Re: [PATCH] Re: A clue for the libstdc++ problem.


On Apr  1, 2001, "Zack Weinberg" <zackw@Stanford.EDU> wrote:

> Your patch doesn't change the fact that presently only
> libstdc++/src/Makefile knows the proper switches to use when building
> libraries against the just-built libstdc++.

Which is a good thing, IMO.  We concentrate the information about how
to find libstdc++ headers and libraries in libstdc++, and export it in
a form any other tool can use; in particular, the top-level Makefile
can use it.  My plan is to do something similar for newlib, and,
perhaps, libgloss, so that we can get rid of the many places in which
these flags are hardcoded again and again.

> I don't think it will work with my shell.  It looks like it uses the
> same construct as your previous patch that didn't work.  I could be
> wrong.

You probably are.  I believe I could never reproduce your problem
because I'd always run `make all' after bootstrapping the compiler,
assuming they were equivalent.  Whenever I ended up with one of the
weird problems of libtool not being able to infer the tag name, I
attributed it to cache polution, cleaned the cache and run, guess
what: `make all', not `make bootstrap'.  So, my suspicion that it was
just the cache that got dirty somehow was ``confirmed.''

The construct that didn't work for you, and probably for nobody at
all, had the problem that it was expanded in the top-level Makefile
when re-entering itself after bootstrap, as you found out.

Or maybe you're referring to my Friday's patch, that said:

        "CXX_FOR_TARGET='$(CXX_FOR_TARGET)'"

The double quotes around the whole thing messed it up, because
single-quotes aren't taken out.  I had meant to not have the double
quotes.  Unfortunately, taking them out was not enough, for the
reasons explained in the comment in configure.in, in the following
revised (comments-only) patch, that I'm checking in for now.

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

	* Makefile.in (CXX_FOR_TARGET_FOR_RECURSIVE_MAKE, RECURSE_FLAGS):
	New macros.
	(bootstrap, cross): Use RECURSE_FLAGS.
	* configure.in: Subst CXX_FOR_TARGET_FOR_RECURSIVE_MAKE.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/Makefile.in,v
retrieving revision 1.79
diff -u -p -r1.79 Makefile.in
--- Makefile.in 2001/03/23 23:59:17 1.79
+++ Makefile.in 2001/04/02 01:23:39
@@ -218,6 +218,7 @@ FLAGS_FOR_TARGET =
 CC_FOR_TARGET =
 CHILL_FOR_TARGET =
 CXX_FOR_TARGET =
+CXX_FOR_TARGET_FOR_RECURSIVE_MAKE =
 GCJ_FOR_TARGET =
 
 # If GCC_FOR_TARGET is not overriden on the command line, then this
@@ -390,6 +391,14 @@ BASE_FLAGS_TO_PASS = \
 	"gcc_version_trigger=$(gcc_version_trigger)" \
 	"target_alias=$(target_alias)" 
 
+# For any flags above that may contain shell code that varies from one
+# target library to another.  When doing recursive invocations of the
+# top-level Makefile, we don't want the outer make to evaluate them,
+# so we pass these variables down unchanged.  They must not contain
+# single nor double quotes.
+RECURSE_FLAGS = \
+	CXX_FOR_TARGET='$(CXX_FOR_TARGET_FOR_RECURSIVE_MAKE)'
+
 # Flags to pass down to most sub-makes, in which we're building with
 # the host environment.
 # If any variables are added here, they must be added to do-*, below.
@@ -1345,7 +1354,8 @@ $(ALL_TARGET_MODULES):
 	  r=`pwd`; export r; \
 	  s=`cd $(srcdir); pwd`; export s; \
 	  $(SET_LIB_PATH) \
-	  (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \
+	  (cd $(TARGET_SUBDIR)/$${dir}; \
+	    $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \
 	else \
 	  true; \
 	fi
@@ -1359,7 +1369,8 @@ $(CHECK_TARGET_MODULES):
 	  r=`pwd`; export r; \
 	  s=`cd $(srcdir); pwd`; export s; \
 	  $(SET_LIB_PATH) \
-	  (cd $(TARGET_SUBDIR)/$${dir};$(MAKE) $(TARGET_FLAGS_TO_PASS) check);\
+	  (cd $(TARGET_SUBDIR)/$${dir}; \
+	    $(MAKE) $(TARGET_FLAGS_TO_PASS) check);\
 	else \
 	  true; \
 	fi
@@ -1474,7 +1485,7 @@ bootstrap bootstrap-lean bootstrap2 boot
 	s=`cd $(srcdir); pwd` ; export s; \
 	$(SET_LIB_PATH) \
 	echo "Building runtime libraries"; \
-	$(MAKE) $(BASE_FLAGS_TO_PASS) all
+	$(MAKE) $(BASE_FLAGS_TO_PASS) $(RECURSE_FLAGS) all
 
 .PHONY: cross
 cross: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
@@ -1487,7 +1498,8 @@ cross: all-texinfo all-bison all-byacc a
 	s=`cd $(srcdir); pwd` ; export s; \
 	$(SET_LIB_PATH) \
 	echo "Building runtime libraries"; \
-	$(MAKE) $(BASE_FLAGS_TO_PASS) all LANGUAGES="c c++"
+	$(MAKE) $(BASE_FLAGS_TO_PASS) $(RECURSE_FLAGS) \
+	  LANGUAGES="c c++" all
 
 .PHONY: check-gcc
 check-gcc:
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/configure.in,v
retrieving revision 1.96
diff -u -p -r1.96 configure.in
--- configure.in 2001/03/28 01:18:00 1.96
+++ configure.in 2001/04/02 01:23:39
@@ -1466,8 +1466,16 @@ case $CXX_FOR_TARGET in
 *' $(FLAGS_FOR_TARGET)') ;;
 *) CXX_FOR_TARGET=$CXX_FOR_TARGET' $(FLAGS_FOR_TARGET)' ;;
 esac
-qCXX_FOR_TARGET=`echo "$CXX_FOR_TARGET" | sed 's,&,\\\&,g'`
+qCXX_FOR_TARGET=`echo "$CXX_FOR_TARGET" | sed 's,[&%],\\\&,g'`
 
+# We want to defer the evaluation of `cmd`s and shell variables in
+# CXX_FOR_TARGET when recursing in the top-level Makefile, such as for
+# bootstrap.  We'll enclose CXX_FOR_TARGET_FOR_RECURSIVE_MAKE in single
+# quotes, but we still have to duplicate `$'s so that shell variables
+# can be expanded by the nested make as shell variables, not as make
+# macros.
+qqCXX_FOR_TARGET=`echo "$qCXX_FOR_TARGET" | sed -e 's,[$][$],$$$$,g'`
+
 targargs="--cache-file=../config.cache --host=${target_alias} --build=${build_alias} ${targargs}"
 sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
     -e "s%^CONFIG_ARGUMENTS[ 	]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
@@ -1476,6 +1484,7 @@ sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TA
     -e "s%^CHILL_FOR_TARGET[ 	]*=.*$%CHILL_FOR_TARGET = ${CHILL_FOR_TARGET}%" \
     -e "s%^GCJ_FOR_TARGET[      ]*=.*$%GCJ_FOR_TARGET = ${GCJ_FOR_TARGET}%" \
     -e "s%^CXX_FOR_TARGET[ 	]*=.*$%CXX_FOR_TARGET = ${qCXX_FOR_TARGET}%" \
+    -e "s%^CXX_FOR_TARGET_FOR_RECURSIVE_MAKE[ 	]*=.*$%CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = ${qqCXX_FOR_TARGET}%" \
     -e "s%^TARGET_SUBDIR[ 	]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
     -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
        Makefile > Makefile.tem

-- 
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]