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: [rfa] Keep -B... in order


On Jul 25, 2000, Jason Merrill <jason@redhat.com> wrote:

>>> >>>>> Andrew Cagney <ac131313@cygnus.com> writes:

>>> > is searched in the order that it is specified.  This ``bug'' really
>>> > hurts when building gcc -  ``xgcc -B/build/dir -B/dest/dir'' is run.

> OK, I'm convinced.  Please make the necessary Makefile adjustments (both to
> the toplevel and gcc Makefile.in) and check in your patch.

I'm taking this task over, since I'm currently rewriting the top-level
handling of these flags anyway.  Here's the patch for the gcc
sub-directory, followed by the revised patch for the top level.  Ok to
install them all (as long as a i686-pc-linux-gnu bootstrap and
a x-mn10300-elf build complete successfully)?

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

	* Makefile.in (bootstrap): Move -BstageN/ back to the beginning.

Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.484
diff -u -r1.484 Makefile.in
--- gcc/Makefile.in	2000/07/24 17:43:42	1.484
+++ gcc/Makefile.in	2000/07/26 06:11:02
@@ -165,7 +165,7 @@
 # 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
+GCC_FOR_TARGET = ./xgcc -B./ -B$(build_tooldir)/bin/ -isystem $(build_tooldir)/include
 
 # This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET.
 # It omits XCFLAGS, and specifies -B./.
@@ -2763,22 +2764,22 @@
 # To prevent `make install' from compiling alloca.o and then relinking cc1
 # because alloca.o is newer, we permit these recursive makes to compile
 # alloca.o.  Then cc1 is newer, so it won't have to be relinked.
-	$(MAKE) CC="stage1/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage1/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage1/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage1/xgcc$(exeext) -Bstage1/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage1/ LANGUAGES="$(LANGUAGES)"
 	$(MAKE) stage2
 	-if test $@ = bootstrap-lean; then rm -rf stage1; cd stage2 ; rm -f $(VOL_FILES); else true; fi
-	$(MAKE) CC="stage2/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage2/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage2/xgcc$(exeext) -Bstage2/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
 
 bootstrap2 bootstrap2-lean: force
-	$(MAKE) CC="stage1/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage1/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage1/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage1/xgcc$(exeext) -Bstage1/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage1/ LANGUAGES="$(LANGUAGES)"
 	$(MAKE) stage2
 	-if test $@ = bootstrap2-lean; then rm -rf stage1; cd stage2 ; rm -f $(VOL_FILES); else true; fi
-	$(MAKE) CC="stage2/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage2/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage2/xgcc$(exeext) -Bstage2/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
 
 bootstrap3 bootstrap3-lean: force
-	$(MAKE) CC="stage2/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage2/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage2/xgcc$(exeext) -Bstage2/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage2/ LANGUAGES="$(LANGUAGES)"
 
 bootstrap4 bootstrap4-lean: force
-	$(MAKE) CC="stage3/xgcc$(exeext) -B$(build_tooldir)/bin/ -Bstage3/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage3/ LANGUAGES="$(LANGUAGES)"
+	$(MAKE) CC="stage3/xgcc$(exeext) -Bstage3/ -B$(build_tooldir)/bin/" CFLAGS="$(WARN_CFLAGS) $(BOOT_CFLAGS)" LDFLAGS="$(BOOT_LDFLAGS)" libdir=$(libdir) STAGE_PREFIX=stage3/ LANGUAGES="$(LANGUAGES)"
 
 # Compare the object files in the current directory with those in the
 # stage2 directory.
Index: ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* Makefile.in (FLAGS_FOR_TARGET): New macro.
	(GCC_FOR_TARGET): Use it.
	(CC_FOR_TARGET, CXX_FOR_TARGET, CHILL_FOR_TARGET): Now defined...
	* configure.in: ... here.
	(FLAGS_FOR_TARGET): Define.  Add ld build dir to -L path.
	(libstdcxx_flags): Define and append to CXX_FOR_TARGET.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/Makefile.in,v
retrieving revision 1.50
diff -u -c -r1.50 Makefile.in
*** Makefile.in	2000/07/24 04:33:01	1.50
--- Makefile.in	2000/07/26 06:04:50
***************
*** 210,275 ****
  	$(INSTALL_X11_MODULES) \
  	$(INSTALL_DOSREL)
  
! CC_FOR_TARGET = ` \
!   if [ -f $$r/gcc/xgcc ] ; then \
!     if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
!       case "$(target_canonical)" in \
!         i[3456]86-*-cygwin*) \
!           echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -L$$r/$(TARGET_SUBDIR)/winsup -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/include -idirafter $$s/winsup/cygwin/include -idirafter $$s/winsup/w32api/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc; \
!           ;; \
!         *) \
!           echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \
! 	  ;; \
!       esac \
!     else \
!       echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include; \
!     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`
  
! # If CC_FOR_TARGET is not overriden on the command line, then this
  # variable is passed down to the gcc Makefile, where it is used to
  # build libgcc2.a.  We define it here so that it can itself be
  # overridden on the command line.
! GCC_FOR_TARGET = $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include
! 
! CHILL_FOR_TARGET = ` \
!   if [ -f $$r/gcc/xgcc ] ; then \
!     echo $$r/gcc/xgcc -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -L$$r/gcc/ch/runtime/; \
!   else \
!     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
!       echo $(CC); \
!     else \
!       t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \
!     fi; \
!   fi`
! 
! CXX_FOR_TARGET = ` \
!   if [ -f $$r/gcc/g++ ] ; then \
!     if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \
!       case "$(target_canonical)" in \
!         i[3456]86-*-cygwin*) \
!           echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/winsup/cygwin/include -idirafter $$s/winsup/w32api/include -idirafter $$s/newlib/libc/include -idirafter $$s/newlib/libc/sys/cygwin -idirafter $$s/newlib/libc/sys/cygwin32 -nostdinc -L$$r/$(TARGET_SUBDIR)/libstdc++; \
!           ;; \
!         *) \
!           echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$$r/$(TARGET_SUBDIR)/newlib/ -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc -L$$r/$(TARGET_SUBDIR)/libstdc++; \
! 	  ;; \
!       esac \
!     else \
!       echo $$r/gcc/g++ -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -B$$r/gcc/ -isystem $(build_tooldir)/include -L$$r/$(TARGET_SUBDIR)/libstdc++; \
!     fi; \
!   else \
!     if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
!       echo $(CXX); \
!     else \
!       t='$(program_transform_name)'; echo c++ | sed -e 's/x/x/' $$t; \
!     fi; \
!   fi`
  
  AS_FOR_TARGET = ` \
    if [ -f $$r/gas/as-new ] ; then \
--- 210,226 ----
  	$(INSTALL_X11_MODULES) \
  	$(INSTALL_DOSREL)
  
! # Should be substed by configure.in
! FLAGS_FOR_TARGET =
! CC_FOR_TARGET =
! CHILL_FOR_TARGET =
! CXX_FOR_TARGET =
  
! # If GCC_FOR_TARGET is not overriden on the command line, then this
  # variable is passed down to the gcc Makefile, where it is used to
  # build libgcc2.a.  We define it here so that it can itself be
  # overridden on the command line.
! GCC_FOR_TARGET = $$r/gcc/xgcc $(FLAGS_FOR_TARGET)
  
  AS_FOR_TARGET = ` \
    if [ -f $$r/gas/as-new ] ; then \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/configure.in,v
retrieving revision 1.53
diff -u -c -r1.53 configure.in
*** configure.in	2000/07/24 04:29:33	1.53
--- configure.in	2000/07/26 06:04:51
***************
*** 48,57 ****
  fi
  
  # Set up configure/Makefile variables if libstdc++-v3 is to be built.
! if [ "${enable_libstdcxx_v3}" = "yes" ] ; then
          libstdcxx_version="target-libstdc++-v3"
  else
          libstdcxx_version="target-libio target-libstdc++"
  fi
  
  # these tools are built for the host environment
--- 48,60 ----
  fi
  
  # Set up configure/Makefile variables if libstdc++-v3 is to be built.
! if [ "${enable_libstdcxx_v3}" = "yes" ] && test -d $srcdir/libstdc++-v3; then
          libstdcxx_version="target-libstdc++-v3"
+ 	# Don't use libstdc++-v3's flags to configure/build itself.
+ 	libstdcxx_flags='`test "x$$dir" != xlibstdc++-v3 && test -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/mkcheck && $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/mkcheck 2 $$r/$(TARGET_SUBDIR)/libstdc++-v3 $$s/libstdc++-v3 | sed -e "s/-I/-isystem /g"` -L$$r/$(TARGET_SUBDIR)/libstd++-v3/src -L$$r/$(TARGET_SUBDIR)/libstd++-v3/src/.libs'
  else
          libstdcxx_version="target-libio target-libstdc++"
+         libstdcxx_flags='-isystem $$s/libstdc++ -isystem $$s/libstdc++/std -isystem $$s/libstdc++/stl -isystem $$s/libio/ -isystem $$s/libio/stdio -L$$r/$(TARGET_SUBDIR)/libstdc++'
  fi
  
  # these tools are built for the host environment
***************
*** 1216,1224 ****
--- 1219,1296 ----
    gxx_include_dir=${gxx_include_dir}
  fi
  
+ FLAGS_FOR_TARGET=
+ if test -d ${topsrcdir}/gcc; then
+   # Directories specified with -B are searched for libraries after those
+   # specified with -L, but for headers (in sub-directory `include')
+   # before those specified with -I and -isystem.  Fortunately, we don't
+   # expect include directories to exist in build_tooldir/{bin,lib} (see
+   # below), and we want gcc/include to be searched first.
+   FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/gcc/'
+ fi
+ case " $skipdirs " in
+ *" target-newlib "*) ;;
+ *)
+    case "$target" in
+    i[3456]86-*-cygwin*)
+      FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -L$$r/$(TARGET_SUBDIR)/winsup/w32api/lib -isystem $$s/winsup/include -isystem $$s/winsup/cygwin/include -isystem $$s/winsup/w32api/include -isystem $$s/newlib/libc/sys/cygwin -isystem $$s/newlib/libc/sys/cygwin32' ;;
+    esac
+ 
+    # If we're building newlib, use its generic headers last, but search
+    # for any libc-related directories first (so make it the last -B
+    # switch).
+    FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -nostdinc -B$$r/$(TARGET_SUBDIR)/newlib/ -isystem $$r/$(TARGET_SUBDIR)/newlib/targ-include -isystem $$s/newlib/libc/include'
+    ;;
+ esac
+ if test -d ${topsrcdir}/gcc; then
+   # Search for pre-installed headers if nothing else fits.
+   FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include'
+ fi
+ if test "x${use_gnu_ld}" = x && test "x${with_gnu_ld}" != xno &&
+    echo " ${configdirs} " | grep " ld " > /dev/null &&
+    test -d ${srcdir}/ld; then
+   # Arrange for us to find uninstalled linker scripts.
+   FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/ld'
+ fi
+ 
+ if test -d ${topsrcdir}/gcc; then
+   CC_FOR_TARGET='$$r/gcc/xgcc'
+ elif test "$host" = "$target"; then
+   CC_FOR_TARGET='$(CC)'
+ else
+   CC_FOR_TARGET=`echo gcc | sed -e 's/x/x/' ${program_transform_name}`
+ fi
+ CC_FOR_TARGET=$CC_FOR_TARGET' $(FLAGS_FOR_TARGET)'
+ 
+ if test -d ${topsrcdir}/gcc &&
+    echo ",${enable_languages-${LANGUAGES-CHILL}}," |
+    grep ,CHILL, > /dev/null ; then
+   CHILL_FOR_TARGET='$$r/gcc/xgcc -L$$r/gcc/ch/runtime/'
+ elif test "$host" = "$target"; then
+   CHILL_FOR_TARGET='$(CC)'
+ else
+   CHILL_FOR_TARGET=`echo gcc | sed -e 's/x/x/' ${program_transform_name}`
+ fi
+ CHILL_FOR_TARGET=$CHILL_FOR_TARGET' $(FLAGS_FOR_TARGET)'
+ 
+ if test -d ${topsrcdir}/gcc &&
+    echo ",${enable_languages-${LANGUAGES-c++}}," |
+    grep ',c[+][+],' > /dev/null ; then
+   CXX_FOR_TARGET='$$r/gcc/g++ -nostdinc++ '$libstdcxx_flags
+ elif test "$host" = "$target"; then
+   CXX_FOR_TARGET='$(CXX)'
+ else
+   CXX_FOR_TARGET=`echo c++ | sed -e 's/x/x/' ${program_transform_name}`
+ fi
+ CXX_FOR_TARGET=$CXX_FOR_TARGET' $(FLAGS_FOR_TARGET)'
+ 
  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}%" \
+     -e "s%^FLAGS_FOR_TARGET[ 	]*=.*$%FLAGS_FOR_TARGET = ${FLAGS_FOR_TARGET}%" \
+     -e "s%^CC_FOR_TARGET[ 	]*=.*$%CC_FOR_TARGET = ${CC_FOR_TARGET}%" \
+     -e "s%^CHILL_FOR_TARGET[ 	]*=.*$%CHILL_FOR_TARGET = ${CHILL_FOR_TARGET}%" \
+     -e "s%^CXX_FOR_TARGET[ 	]*=.*$%CXX_FOR_TARGET = ${CXX_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]