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]

Re: PATH for libstdc++ Makefile



>>>>> "Mark" == Mark Mitchell <mark@markmitchell.com> writes:

    Mark> I just got bitten by an odd situation.  The line to build
    Mark> libstdc++.so is something like:

    Mark>   xgcc -g -O2 -fvtable-thunks -D_GNU_SOURCE
    Mark> -fno-implicit-templates -Wl,-soname,libstdc++-libc6.0-1.so.2
    Mark> -shared -o libstdc++-2-libc6.0-1-2.9.0.so `cat piclist` -lm

    Mark> But, this passes `-lgcc' to the linker and the directories
    Mark> searched do not include the directory containing the
    Mark> recently built libgcc.a.  Therefore, you get whatever
    Mark> libgcc.a is lying around in /usr/local/lib, etc.

I withdrew my suggested patch.  But, I bootstrapped again, later, and
found that the same problem recurred.  Here's the log from the
bootstrap:

  make[3]: Leaving directory `/mnt/u3/mitchell/egcs/objdir/i686-pc-linux-gnu/libstdc++'
  gcc -g -O2 -fvtable-thunks -D_GNU_SOURCE -fno-implicit-templates -Wl,-soname,libstdc++-libc6.0-1.so.2 -shared -o libstdc++-2-libc6.0-1-2.9.0.so `cat piclist` -lm

My original patch was, as Manfred pointed out, no good on multilibbed
targets.  But, clearly, I was not dreaming.  

The cause of the trouble is this patch:

1998-09-20  Mark Mitchell  <mark@markmitchell.com>

	* Makefile.in (bootstrap): Pass TARGET_FLAGS_TO_PASS to `make all'.

which causes the last step of a bootstrap to be:

  make ... "CC_FOR_TARGET=$(CC_FOR_TARGET)" ... all

The top-level Makefile sets CC_FOR_TARGET like this:

CC_FOR_TARGET = ` \
  if [ -f $$r/gcc/xgcc ] ; then \
    if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
      if [ -f $$r/$(TARGET_SUBDIR)/winsup/Makefile ] ; then \
        echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/$(TARGET_SUBDIR)/newlib/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
      else \
        echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
      fi; \
    else \
      echo $$r/gcc/xgcc -B$$r/gcc/; \
    fi; \
  else \
    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
      echo $(CC); \
    else \
      t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
    fi; \
  fi`

so this expression is actually evaluted before being passed down, which is
not what we want here. 

Here's a revised patch, which preserves that desirable behavior, but
does not result in the breakage reported above.  I hope one of the
maintainers will take the time to look at this patch in the very near
future; I suspect we will otherwise start seeing widespread
complaints, as I believe my previous patch completely one-tree builds
of cross-toolchains.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-09-22  Mark Mitchell  <mark@markmitchell.com>

	* Makefile.in (TARGET_TOOLS): New macro, split out from
	BASE_FLAGS_TO_PASS.
	(BASE_FLAGS_WITHOUT_TARGET_TOOLS): Likewise.
	(BASE_FLAGS_TO_PASS): Combine them.
	(bootstrap): Use BASE_FLAGS_WITHOUT_TARGET_TOOLS instead of
	TARGET_FLAGS_TO_PASS.

Index: Makefile.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/Makefile.in,v
retrieving revision 1.29
diff -c -p -r1.29 Makefile.in
*** Makefile.in	1998/09/20 11:21:12	1.29
--- Makefile.in	1998/09/22 18:38:41
*************** NM_FOR_TARGET = ` \
*** 316,344 ****
  #### host and target specific makefile fragments come in here.
  ###
  
! # Flags to pass down to all sub-makes.
! # Please keep these in alphabetical order.
! BASE_FLAGS_TO_PASS = \
! 	"AR_FLAGS=$(AR_FLAGS)" \
  	"AR_FOR_TARGET=$(AR_FOR_TARGET)" \
  	"AS_FOR_TARGET=$(AS_FOR_TARGET)" \
  	"BISON=$(BISON)" \
  	"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
- 	"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
  	"CFLAGS=$(CFLAGS)" \
  	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
  	"CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
  	"CXXFLAGS=$(CXXFLAGS)" \
  	"CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \
- 	"CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
- 	"DLLTOOL_FOR_TARGET=$(DLLTOOL_FOR_TARGET)" \
  	"INSTALL=$(INSTALL)" \
  	"INSTALL_DATA=$(INSTALL_DATA)" \
  	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
  	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
  	"LDFLAGS=$(LDFLAGS)" \
  	"LEX=$(LEX)" \
- 	"LD_FOR_TARGET=$(LD_FOR_TARGET)" \
  	"LIBCFLAGS=$(LIBCFLAGS)" \
  	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
  	"LIBCXXFLAGS=$(LIBCXXFLAGS)" \
--- 316,350 ----
  #### host and target specific makefile fragments come in here.
  ###
  
! # Flags that define tools to use when building things for the target.
! TARGET_TOOLS = \
  	"AR_FOR_TARGET=$(AR_FOR_TARGET)" \
  	"AS_FOR_TARGET=$(AS_FOR_TARGET)" \
+ 	"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
+ 	"CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
+ 	"DLLTOOL_FOR_TARGET=$(DLLTOOL_FOR_TARGET)" \
+ 	"LD_FOR_TARGET=$(LD_FOR_TARGET)" \
+ 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
+ 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" 
+ 
+ # Flags to pass down to sub-makes, without the names of the target 
+ # tools.
+ # Please keep these in alphabetical order.
+ BASE_FLAGS_WITHOUT_TARGET_TOOLS = \
+ 	"AR_FLAGS=$(AR_FLAGS)" \
  	"BISON=$(BISON)" \
  	"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
  	"CFLAGS=$(CFLAGS)" \
  	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
  	"CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
  	"CXXFLAGS=$(CXXFLAGS)" \
  	"CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \
  	"INSTALL=$(INSTALL)" \
  	"INSTALL_DATA=$(INSTALL_DATA)" \
  	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
  	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
  	"LDFLAGS=$(LDFLAGS)" \
  	"LEX=$(LEX)" \
  	"LIBCFLAGS=$(LIBCFLAGS)" \
  	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
  	"LIBCXXFLAGS=$(LIBCXXFLAGS)" \
*************** BASE_FLAGS_TO_PASS = \
*** 346,353 ****
  	"M4=$(M4)" \
  	"MAKE=$(MAKE)" \
  	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
- 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
- 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
  	"SHELL=$(SHELL)" \
  	"EXPECT=$(EXPECT)" \
  	"RUNTEST=$(RUNTEST)" \
--- 352,357 ----
*************** BASE_FLAGS_TO_PASS = \
*** 364,369 ****
--- 368,378 ----
  	"target_alias=$(target_alias)" \
  	"libsubdir=$(libsubdir)"
  
+ # Flags to pass down to all sub-makes.
+ BASE_FLAGS_TO_PASS = \
+ 	$(TARGET_TOOLS) \
+ 	$(BASE_FLAGS_WITHOUT_TARGET_TOOLS)
+ 
  # 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.
*************** all-gcc:
*** 1327,1333 ****
  #
  # In theory, on an SMP all those dependencies can be resolved
  # in parallel.
! #
  .PHONY: bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean
  bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
  	@r=`pwd`; export r; \
--- 1336,1349 ----
  #
  # In theory, on an SMP all those dependencies can be resolved
  # in parallel.
! 
! # Note that when we build run-time libraries at the end of this step,
! # we use BASE_FLAGS_WITHOUT_TARGET_TOOLS rather than
! # BASE_FLAGS_TO_PASS.  That's because things like CC_FOR_TARGET are
! # calculated dynamically above, depending on whether or not programs
! # exist in the tree.  They didn't exist when we calculated them
! # before, but they do now; we built them during the bootstrap.
! 
  .PHONY: bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean
  bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
  	@r=`pwd`; export r; \
*************** bootstrap bootstrap-lean bootstrap2 boot
*** 1352,1358 ****
  	echo "$$msg"; \
  	cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) $$compare
  	@echo "Building runtime libraries"; \
! 	$(MAKE) $(TARGET_FLAGS_TO_PASS) all
  
  .PHONY: cross
  cross: all-texinfo all-bison all-byacc all-binutils all-gas all-ld
--- 1368,1374 ----
  	echo "$$msg"; \
  	cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) $$compare
  	@echo "Building runtime libraries"; \
! 	$(MAKE) $(BASE_FLAGS_WITHOUT_TARGET_TOOLS) all
  
  .PHONY: cross
  cross: all-texinfo all-bison all-byacc all-binutils all-gas all-ld


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