fixincludes:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Mar 2007 15:50:28 +0000 (15:50 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Mar 2007 15:50:28 +0000 (15:50 +0000)
* mkheaders.in: Fix headers for each multilib required.

gcc:
PR bootstrap/31020
* configure.ac (CROSS_SYSTEM_HEADER_DIR, build_system_header_dir):
Define using $${sysroot_headers_suffix}.
* configure: Regenerate.
* cppdefault.c (cpp_include_defaults): Make FIXED_INCLUDE_DIR a
multilib-suffixed directory if SYSROOT_HEADERS_SUFFIX_SPEC
defined.
* doc/invoke.texi (-print-sysroot-headers-suffix): Document.
* gcc.c (print_sysroot_headers_suffix): New.
(option_map): Include --print-sysroot-headers-suffix.
(display_help): Mention -print-sysroot-headers-suffix.
(process_command): Handle -print-sysroot-headers-suffix.
(do_spec_1): Append multilib directory to include-fixed path if
sysroot suffixes in use.
(main): Handle -print-sysroot-headers-suffix.
* Makefile.in (start.encap): Don't depend on xlimits.h
(xlimits.h): Remove.
(stmp-int-hdrs): Don't depend on xlimits.h.  Inline generation of
limits.h for each multilib in fixinc_list.
(fixinc_list, s-fixinc_list): New.
(stmp-fixinc): Depend on fixinc_list.  If not copying headers,
generate them for each multilib in fixinc_list.
(stmp-fixproto): Use include-fixed.  Run fixproto for each
multilib in fixinc_list.
(mostlyclean): Don't remove xlimits.h.
(clean): Remove include-fixed.
(real-install-headers-tar, real-install-headers-cpio,
real-install-headers-cp): Don't copy include, only include-fixed.
(install-mkheaders): Depend on fixinc_list.  Don't depend on
xlimits.h.  Save limits.h files for each multilib in fixinc_list.
Always save mkinstalldirs.  Preserve ${sysroot_headers_suffix} in
SYSTEM_HEADER_DIR setting in mkheaders.conf.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122620 138bc75d-0d04-0410-961f-82ee72b054a4

fixincludes/ChangeLog
fixincludes/mkheaders.in
gcc/ChangeLog
gcc/Makefile.in
gcc/configure
gcc/configure.ac
gcc/cppdefault.c
gcc/doc/invoke.texi
gcc/gcc.c

index 61f0bfe..35187bd 100644 (file)
@@ -1,3 +1,7 @@
+2007-03-06  Joseph Myers  <joseph@codesourcery.com>
+
+       * mkheaders.in: Fix headers for each multilib required.
+
 2007-03-01  Brooks Moses  <brooks.moses@codesourcery.com>
 
        * Makefile.in: Add dummy install-pdf target.
index cfe826e..b584b68 100644 (file)
@@ -78,29 +78,33 @@ libexecsubdir=${libexecdir}/gcc/${target_noncanonical}/${version}
 itoolsdir=${libexecsubdir}/install-tools
 itoolsdatadir=${libsubdir}/install-tools
 incdir=${libsubdir}/include-fixed
-
-. ${itoolsdatadir}/mkheaders.conf
+mkinstalldirs="@SHELL@ ${itoolsdir}/mkinstalldirs"
 
 cd ${itoolsdir}
 rm -rf ${incdir}/*
 
-if [ x${STMP_FIXINC} != x ] ; then
+for ml in `cat ${itoolsdatadir}/fixinc_list`; do
+  sysroot_headers_suffix=`echo ${ml} | sed -e 's/;.*$//'`
+  multi_dir=`echo ${ml} | sed -e 's/^[^;]*;//'`
+  subincdir=${incdir}${multi_dir}
+  . ${itoolsdatadir}/mkheaders.conf
+  if [ x${STMP_FIXINC} != x ] ; then
        TARGET_MACHINE="${target}" target_canonical="${target}" \
            MACRO_LIST="${itoolsdatadir}/macro_list" \
-           @SHELL@ ./fixinc.sh ${incdir} \
+           @SHELL@ ./fixinc.sh ${subincdir} \
            ${isysroot}${SYSTEM_HEADER_DIR} ${OTHER_FIXINCLUDES_DIRS}
-       rm -f ${incdir}/syslimits.h
-       if [ -f ${incdir}/limits.h ]; then
-         mv ${incdir}/limits.h ${incdir}/syslimits.h
+       rm -f ${subincdir}/syslimits.h
+       if [ -f ${subincdir}/limits.h ]; then
+         mv ${subincdir}/limits.h ${subincdir}/syslimits.h
        else
-         cp ${itoolsdatadir}/gsyslimits.h ${incdir}/syslimits.h
+         cp ${itoolsdatadir}/gsyslimits.h ${subincdir}/syslimits.h
        fi
-fi
+  fi
 
-cp ${itoolsdatadir}/include/* ${incdir}
+  cp ${itoolsdatadir}/include${multi_dir}/limits.h ${subincdir}
 
-if [ x${STMP_FIXPROTO} != x ] ; then
-  mkinstalldirs="@SHELL@ ${itoolsdir}/mkinstalldirs"
-  export FIXPROTO_DEFINES mkinstalldirs
-  @SHELL@ fixproto ${incdir} ${incdir} ${isysroot}${SYSTEM_HEADER_DIR} || exit 1
-fi
+  if [ x${STMP_FIXPROTO} != x ] ; then
+    export FIXPROTO_DEFINES mkinstalldirs
+    @SHELL@ fixproto ${subincdir} ${subincdir} ${isysroot}${SYSTEM_HEADER_DIR} || exit 1
+  fi
+done
index 55c90f4..4430d04 100644 (file)
@@ -1,3 +1,38 @@
+2007-03-06  Joseph Myers  <joseph@codesourcery.com>
+
+       PR bootstrap/31020
+       * configure.ac (CROSS_SYSTEM_HEADER_DIR, build_system_header_dir):
+       Define using $${sysroot_headers_suffix}.
+       * configure: Regenerate.
+       * cppdefault.c (cpp_include_defaults): Make FIXED_INCLUDE_DIR a
+       multilib-suffixed directory if SYSROOT_HEADERS_SUFFIX_SPEC
+       defined.
+       * doc/invoke.texi (-print-sysroot-headers-suffix): Document.
+       * gcc.c (print_sysroot_headers_suffix): New.
+       (option_map): Include --print-sysroot-headers-suffix.
+       (display_help): Mention -print-sysroot-headers-suffix.
+       (process_command): Handle -print-sysroot-headers-suffix.
+       (do_spec_1): Append multilib directory to include-fixed path if
+       sysroot suffixes in use.
+       (main): Handle -print-sysroot-headers-suffix.
+       * Makefile.in (start.encap): Don't depend on xlimits.h
+       (xlimits.h): Remove.
+       (stmp-int-hdrs): Don't depend on xlimits.h.  Inline generation of
+       limits.h for each multilib in fixinc_list.
+       (fixinc_list, s-fixinc_list): New.
+       (stmp-fixinc): Depend on fixinc_list.  If not copying headers,
+       generate them for each multilib in fixinc_list.
+       (stmp-fixproto): Use include-fixed.  Run fixproto for each
+       multilib in fixinc_list.
+       (mostlyclean): Don't remove xlimits.h.
+       (clean): Remove include-fixed.
+       (real-install-headers-tar, real-install-headers-cpio,
+       real-install-headers-cp): Don't copy include, only include-fixed.
+       (install-mkheaders): Depend on fixinc_list.  Don't depend on
+       xlimits.h.  Save limits.h files for each multilib in fixinc_list.
+       Always save mkinstalldirs.  Preserve ${sysroot_headers_suffix} in
+       SYSTEM_HEADER_DIR setting in mkheaders.conf.
+
 2007-03-06  Jan Hubicka  <jh@suse.cz>
 
        * regstack.c (reg_to_stack): When in 64bit PIC mode, we still can load
index b29a52c..4feaa9f 100644 (file)
@@ -1418,7 +1418,7 @@ all.cross: native gcc-cross$(exeext) cpp$(exeext) specs \
        libgcc-support lang.all.cross doc @GENINSRC@ srcextra
 # This is what must be made before installing GCC and converting libraries.
 start.encap: native xgcc$(exeext) cpp$(exeext) specs \
-       libgcc-support xlimits.h lang.start.encap @GENINSRC@ srcextra
+       libgcc-support lang.start.encap @GENINSRC@ srcextra
 # These can't be made until after GCC can run.
 rest.encap: $(STMP_FIXPROTO) lang.rest.encap
 # This is what is made with the host's compiler
@@ -1542,14 +1542,6 @@ cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) cc1-checksum.o \
          $(BACKEND) $(LIBS)
 
-# Build the version of limits.h that we will install.
-xlimits.h: glimits.h limitx.h limity.h
-       if $(LIMITS_H_TEST) ; then \
-         cat $(srcdir)/limitx.h $(srcdir)/glimits.h $(srcdir)/limity.h > tmp-xlimits.h; \
-       else \
-         cat $(srcdir)/glimits.h > tmp-xlimits.h; \
-       fi
-       mv tmp-xlimits.h xlimits.h
 #\f
 # Build libgcc.a.
 
@@ -3325,7 +3317,7 @@ gcov-dump$(exeext): $(GCOV_DUMP_OBJS) $(LIBDEPS)
 # be rebuilt.
 
 # Build the include directories.
-stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) xlimits.h $(UNWIND_H)
+stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) $(UNWIND_H)
 # Copy in the headers provided with gcc.
 # The sed command gets just the last file name component;
 # this is necessary because VPATH could add a dirname.
@@ -3342,11 +3334,23 @@ stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) xlimits.h $(UNWIND_H)
            chmod a+r include/$$realfile; \
          fi; \
        done
-       rm -f include-fixed/limits.h
-       cp xlimits.h include-fixed/limits.h
-       chmod a+r include-fixed/limits.h
        rm -f include/unwind.h
        cp $(UNWIND_H) include/unwind.h
+       set -e; for ml in `cat fixinc_list`; do \
+         sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
+         multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
+         fix_dir=include-fixed$${multi_dir}; \
+         if $(LIMITS_H_TEST) ; then \
+           cat $(srcdir)/limitx.h $(srcdir)/glimits.h $(srcdir)/limity.h > tmp-xlimits.h; \
+         else \
+           cat $(srcdir)/glimits.h > tmp-xlimits.h; \
+         fi; \
+         $(mkinstalldirs) $${fix_dir}; \
+         chmod a+rx $${fix_dir} || true; \
+         rm -f $${fix_dir}/limits.h; \
+         mv tmp-xlimits.h $${fix_dir}/limits.h; \
+         chmod a+r $${fix_dir}/limits.h; \
+       done
 # Install the README
        rm -f include-fixed/README
        cp $(srcdir)/../fixincludes/README-fixinc include-fixed/README
@@ -3366,6 +3370,28 @@ s-macro_list : $(GCC_PASSES)
        $(SHELL) $(srcdir)/../move-if-change tmp-macro_list macro_list
        $(STAMP) s-macro_list
 
+fixinc_list: s-fixinc_list; @true
+s-fixinc_list : $(GCC_PASSES)
+# Build up a list of multilib directories and corresponding sysroot
+# suffixes, in form sysroot;multilib.
+       if $(GCC_FOR_TARGET) -print-sysroot-headers-suffix > /dev/null 2>&1; then \
+         set -e; for ml in `$(GCC_FOR_TARGET) -print-multi-lib`; do \
+           multi_dir=`echo $${ml} | sed -e 's/;.*$$//'`; \
+           flags=`echo $${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
+           sfx=`$(GCC_FOR_TARGET) $${flags} -print-sysroot-headers-suffix`; \
+           if [ "$${multi_dir}" = "." ]; \
+             then multi_dir=""; \
+           else \
+             multi_dir=/$${multi_dir}; \
+           fi; \
+           echo "$${sfx};$${multi_dir}"; \
+         done; \
+       else \
+         echo ";"; \
+       fi > tmp-fixinc_list
+       $(SHELL) $(srcdir)/../move-if-change tmp-fixinc_list fixinc_list
+       $(STAMP) s-fixinc_list
+
 # The line below is supposed to avoid accidentally matching the
 # built-in suffix rule `.o:' to build fixincl out of fixincl.o.  You'd
 # expect fixincl to be newer than fixincl.o, such that this situation
@@ -3383,16 +3409,9 @@ s-macro_list : $(GCC_PASSES)
 # Build fixed copies of system files.
 # Abort if no system headers available, unless building a crosscompiler.
 # FIXME: abort unless building --without-headers would be more accurate and less ugly
-stmp-fixinc: gsyslimits.h macro_list \
+stmp-fixinc: gsyslimits.h macro_list fixinc_list \
   $(build_objdir)/fixincludes/fixincl \
   $(build_objdir)/fixincludes/fixinc.sh
-       @if ! $(inhibit_libc) && test ! -d ${SYSTEM_HEADER_DIR}; then \
-         echo The directory that should contain system headers does not exist: >&2 ; \
-         echo "  ${SYSTEM_HEADER_DIR}" >&2 ; \
-         tooldir_sysinc=`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \
-         if test "x${SYSTEM_HEADER_DIR}" = "x$${tooldir_sysinc}"; \
-         then sleep 1; else exit 1; fi; \
-       fi
        rm -rf include-fixed; mkdir include-fixed
        -chmod a+rx include-fixed
        if [ -d ../prev-gcc ]; then \
@@ -3400,20 +3419,34 @@ stmp-fixinc: gsyslimits.h macro_list \
          $(MAKE) real-$(INSTALL_HEADERS_DIR) DESTDIR=`pwd`/../gcc/ \
            libsubdir=. ; \
        else \
-         (TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); ${PWD_COMMAND}`; \
-           SHELL='$(SHELL)'; MACRO_LIST=`${PWD_COMMAND}`/macro_list ; \
-           export TARGET_MACHINE srcdir SHELL MACRO_LIST && \
-           cd $(build_objdir)/fixincludes && \
-           $(SHELL) ./fixinc.sh ../../gcc/include-fixed \
-             $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS) ); \
-         rm -f include-fixed/syslimits.h; \
-         if [ -f include-fixed/limits.h ]; then \
-           mv include-fixed/limits.h include-fixed/syslimits.h; \
-         else \
-           cp $(srcdir)/gsyslimits.h include-fixed/syslimits.h; \
-         fi; \
+         set -e; for ml in `cat fixinc_list`; do \
+           sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
+           multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
+           fix_dir=include-fixed$${multi_dir}; \
+           if ! $(inhibit_libc) && test ! -d ${SYSTEM_HEADER_DIR}; then \
+             echo The directory that should contain system headers does not exist: >&2 ; \
+             echo "  ${SYSTEM_HEADER_DIR}" >&2 ; \
+             tooldir_sysinc=`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \
+             if test "x${SYSTEM_HEADER_DIR}" = "x$${tooldir_sysinc}"; \
+             then sleep 1; else exit 1; fi; \
+           fi; \
+           $(mkinstalldirs) $${fix_dir}; \
+           chmod a+rx $${fix_dir} || true; \
+           (TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); ${PWD_COMMAND}`; \
+             SHELL='$(SHELL)'; MACRO_LIST=`${PWD_COMMAND}`/macro_list ; \
+             export TARGET_MACHINE srcdir SHELL MACRO_LIST && \
+             cd $(build_objdir)/fixincludes && \
+             $(SHELL) ./fixinc.sh ../../gcc/$${fix_dir} \
+               $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS) ); \
+           rm -f $${fix_dir}/syslimits.h; \
+           if [ -f $${fix_dir}/limits.h ]; then \
+             mv $${fix_dir}/limits.h $${fix_dir}/syslimits.h; \
+           else \
+             cp $(srcdir)/gsyslimits.h $${fix_dir}/syslimits.h; \
+           fi; \
+           chmod a+r $${fix_dir}/syslimits.h; \
+         done; \
        fi
-       chmod a+r include-fixed/syslimits.h
        $(STAMP) stmp-fixinc
 
 # Files related to the fixproto script.
@@ -3480,21 +3513,26 @@ fixhdr.ready: build/fix-header$(build_exeext)
 
 # stmp-int-hdrs is to make sure fixincludes has already finished.
 # The if statement is so that we don't run fixproto a second time
-# if it has already been run on the files in `include'.
-stmp-fixproto: fixhdr.ready fixproto stmp-int-hdrs
-       if [ -f include/fixed ] ; then true; \
-       else \
-         : This line works around a 'make' bug in BSDI 1.1.; \
-         FIXPROTO_DEFINES="$(FIXPROTO_DEFINES)"; export FIXPROTO_DEFINES; \
-         FIX_HEADER="build/fix-header$(build_exeext)"; export FIX_HEADER; \
-         mkinstalldirs="$(mkinstalldirs)"; \
-           export mkinstalldirs; \
-         if [ -d "$(SYSTEM_HEADER_DIR)" ]; then \
-           $(SHELL) ${srcdir}/fixproto include include $(SYSTEM_HEADER_DIR); \
-           if [ $$? -eq 0 ] ; then true ; else exit 1 ; fi ; \
-         else true; fi; \
-         $(STAMP) include/fixed; \
-       fi
+# if it has already been run on the files in `include-fixed'.
+stmp-fixproto: fixhdr.ready fixproto fixinc_list stmp-int-hdrs
+       set -e; for ml in `cat fixinc_list`; do \
+         sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
+         multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
+         fix_dir=include-fixed$${multi_dir}; \
+         if [ -f $${fix_dir}/fixed ] ; then true; \
+         else \
+           : This line works around a 'make' bug in BSDI 1.1.; \
+           FIXPROTO_DEFINES="$(FIXPROTO_DEFINES)"; export FIXPROTO_DEFINES; \
+           FIX_HEADER="build/fix-header$(build_exeext)"; export FIX_HEADER; \
+           mkinstalldirs="$(mkinstalldirs)"; \
+             export mkinstalldirs; \
+           if [ -d "$(SYSTEM_HEADER_DIR)" ]; then \
+             $(SHELL) ${srcdir}/fixproto $${fix_dir} $${fix_dir} $(SYSTEM_HEADER_DIR); \
+             if [ $$? -eq 0 ] ; then true ; else exit 1 ; fi ; \
+           else true; fi; \
+           $(STAMP) $${fix_dir}/fixed; \
+         fi; \
+       done
        $(STAMP) stmp-fixproto
 
 # We can't run fixproto (it's being built for a different host), but we still
@@ -3696,8 +3734,6 @@ mostlyclean: lang.mostlyclean
 # Delete build programs
        -rm -f build/*
        -rm -f mddeps.mk
-# Delete the temp files made in the course of building libgcc.a.
-       -rm -f xlimits.h
 # Delete other built files.
        -rm -f xsys-protos.hT
        -rm -f specs.h gencheck.h options.c options.h
@@ -3738,8 +3774,8 @@ clean: mostlyclean lang.clean
        -rm -f cs-*
        -rm -f doc/*.dvi
        -rm -f doc/*.pdf
-# Delete the include directory.
-       -rm -rf include
+# Delete the include directories.
+       -rm -rf include include-fixed
 # Delete files used by the "multilib" facility (including libgcc subdirs).
        -rm -f multilib.h tmpmultilib*
        -if [ "x$(MULTILIB_DIRNAMES)" != x ] ; then \
@@ -4017,36 +4053,37 @@ install-headers-cp: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
 
 # Targets without dependencies, for use in prev-gcc during bootstrap.
 real-install-headers-tar:
-       (cd `${PWD_COMMAND}`/include ; \
-        tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include; tar xpf - )
        (cd `${PWD_COMMAND}`/include-fixed ; \
         tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include-fixed; tar xpf - )
 
 real-install-headers-cpio:
-       cd `${PWD_COMMAND}`/include ; \
-       find . -print | cpio -pdum $(DESTDIR)$(libsubdir)/include
        cd `${PWD_COMMAND}`/include-fixed ; \
        find . -print | cpio -pdum $(DESTDIR)$(libsubdir)/include-fixed
 
 real-install-headers-cp:
-       cp -p -r include $(DESTDIR)$(libsubdir)
        cp -p -r include-fixed $(DESTDIR)$(libsubdir)
 
 # Install supporting files for fixincludes to be run later.
 install-mkheaders: stmp-int-hdrs $(STMP_FIXPROTO) install-itoolsdirs \
-  macro_list xlimits.h
-       $(INSTALL_DATA) xlimits.h $(DESTDIR)$(itoolsdatadir)/include/limits.h
+  macro_list fixinc_list
        $(INSTALL_DATA) $(srcdir)/gsyslimits.h \
          $(DESTDIR)$(itoolsdatadir)/gsyslimits.h
        $(INSTALL_DATA) macro_list $(DESTDIR)$(itoolsdatadir)/macro_list
-       if [ x$(STMP_FIXPROTO) != x ] ; then \
-         $(INSTALL_SCRIPT) $(mkinstalldirs) \
+       $(INSTALL_DATA) fixinc_list $(DESTDIR)$(itoolsdatadir)/fixinc_list
+       set -e; for ml in `cat fixinc_list`; do \
+         multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
+         $(mkinstalldirs) $(DESTDIR)$(itoolsdatadir)/include$${multi_dir}; \
+         $(INSTALL_DATA) include-fixed$${multidir}/limits.h $(DESTDIR)$(itoolsdatadir)/include$${multi_dir}/limits.h; \
+       done
+       $(INSTALL_SCRIPT) $(srcdir)/../mkinstalldirs \
                $(DESTDIR)$(itoolsdir)/mkinstalldirs ; \
+       if [ x$(STMP_FIXPROTO) != x ] ; then \
          $(INSTALL_SCRIPT) $(srcdir)/fixproto $(DESTDIR)$(itoolsdir)/fixproto ; \
          $(INSTALL_PROGRAM) build/fix-header$(build_exeext) \
                $(DESTDIR)$(itoolsdir)/fix-header$(build_exeext) ; \
        else :; fi
-       echo 'SYSTEM_HEADER_DIR="'"$(SYSTEM_HEADER_DIR)"'"' \
+       sysroot_headers_suffix='$${sysroot_headers_suffix}'; \
+               echo 'SYSTEM_HEADER_DIR="'"$(SYSTEM_HEADER_DIR)"'"' \
                > $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
        echo 'OTHER_FIXINCLUDES_DIRS="$(OTHER_FIXINCLUDES_DIRS)"' \
                >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
index fcbcb4f..15e9b31 100755 (executable)
@@ -7128,7 +7128,7 @@ if test "${with_sysroot+set}" = set; then
  esac
 
  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
- CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)'
+ CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
 
  if test "x$exec_prefix" = xNONE; then
   if test "x$prefix" = xNONE; then
@@ -13121,7 +13121,7 @@ ALL=all.internal
 SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)'
 
 if test "x$with_build_sysroot" != x; then
-  build_system_header_dir=$with_build_sysroot'$(NATIVE_SYSTEM_HEADER_DIR)'
+  build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
 else
   # This value is used, even on a native system, because
   # CROSS_SYSTEM_HEADER_DIR is just
index 0d30652..2a0c86c 100644 (file)
@@ -754,7 +754,7 @@ AC_ARG_WITH(sysroot,
  esac
    
  TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
- CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)'
+ CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
        
  if test "x$exec_prefix" = xNONE; then
   if test "x$prefix" = xNONE; then
@@ -1704,7 +1704,7 @@ ALL=all.internal                          AC_SUBST(ALL)
 SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADER_DIR)'        AC_SUBST(SYSTEM_HEADER_DIR)
 
 if test "x$with_build_sysroot" != x; then
-  build_system_header_dir=$with_build_sysroot'$(NATIVE_SYSTEM_HEADER_DIR)'
+  build_system_header_dir=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
 else
   # This value is used, even on a native system, because 
   # CROSS_SYSTEM_HEADER_DIR is just 
index afe358e..597988e 100644 (file)
@@ -71,7 +71,15 @@ const struct default_include cpp_include_defaults[]
 #endif
 #ifdef FIXED_INCLUDE_DIR
     /* This is the dir for fixincludes.  */
-    { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
+    { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
+      /* A multilib suffix needs adding if different multilibs use
+        different headers.  */
+#ifdef SYSROOT_HEADERS_SUFFIX_SPEC
+      1
+#else
+      0
+#endif
+    },
 #endif
 #ifdef CROSS_INCLUDE_DIR
     /* One place the target system's headers might be.  */
index 3d5c06c..84dd396 100644 (file)
@@ -302,6 +302,7 @@ Objective-C and Objective-C++ Dialects}.
 -p  -pg  -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
+-print-sysroot-headers-suffix @gol
 -save-temps  -time}
 
 @item Optimization Options
@@ -4697,6 +4698,12 @@ variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
 Don't forget the trailing @samp{/}.
 @xref{Environment Variables}.
 
+@item -print-sysroot-headers-suffix
+@opindex print-sysroot-headers-suffix
+Print the suffix added to the target sysroot when searching for
+headers, or give an error if the compiler is not configured with such
+a suffix---and don't do anything else.
+
 @item -dumpmachine
 @opindex dumpmachine
 Print the compiler's target machine (for example,
index 9cdf7c5..7a5056a 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -168,6 +168,11 @@ static int print_multi_lib;
 
 static int print_help_list;
 
+/* Flag saying to print the sysroot suffix used for searching for
+   headers.  */
+
+static int print_sysroot_headers_suffix;
+
 /* Flag indicating whether we should print the command and arguments */
 
 static int verbose_flag;
@@ -1125,6 +1130,7 @@ static const struct option_map option_map[] =
    {"--print-multi-directory", "-print-multi-directory", 0},
    {"--print-multi-os-directory", "-print-multi-os-directory", 0},
    {"--print-prog-name", "-print-prog-name=", "aj"},
+   {"--print-sysroot-headers-suffix", "-print-sysroot-headers-suffix", 0},
    {"--profile", "-p", 0},
    {"--profile-blocks", "-a", 0},
    {"--quiet", "-q", 0},
@@ -3193,6 +3199,7 @@ display_help (void)
   -print-multi-lib         Display the mapping between command line options and\n\
                            multiple library search directories\n"), stdout);
   fputs (_("  -print-multi-os-directory Display the relative path to OS libraries\n"), stdout);
+  fputs (_("  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers\n"), stdout);
   fputs (_("  -Wa,<options>            Pass comma-separated <options> on to the assembler\n"), stdout);
   fputs (_("  -Wp,<options>            Pass comma-separated <options> on to the preprocessor\n"), stdout);
   fputs (_("  -Wl,<options>            Pass comma-separated <options> on to the linker\n"), stdout);
@@ -3637,6 +3644,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
        print_multi_directory = 1;
       else if (! strcmp (argv[i], "-print-multi-os-directory"))
        print_multi_os_directory = 1;
+      else if (! strcmp (argv[i], "-print-sysroot-headers-suffix"))
+       print_sysroot_headers_suffix = 1;
       else if (! strncmp (argv[i], "-Wa,", 4))
        {
          int prev, j;
@@ -4066,6 +4075,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
        ;
       else if (! strcmp (argv[i], "-print-multi-os-directory"))
        ;
+      else if (! strcmp (argv[i], "-print-sysroot-headers-suffix"))
+       ;
       else if (! strncmp (argv[i], "--sysroot=", strlen ("--sysroot=")))
        {
          target_system_root = argv[i] + strlen ("--sysroot=");
@@ -4978,6 +4989,9 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
                             spec_path, &info);
 
              info.append = "include-fixed";
+             if (*sysroot_hdrs_suffix_spec)
+               info.append = concat (info.append, dir_separator_str,
+                                     multilib_dir, NULL);
              info.append_len = strlen (info.append);
              for_each_path (&include_prefixes, false, info.append_len,
                             spec_path, &info);
@@ -6394,6 +6408,19 @@ main (int argc, char **argv)
       return (0);
     }
 
+  if (print_sysroot_headers_suffix)
+    {
+      if (*sysroot_hdrs_suffix_spec)
+       {
+         printf("%s\n", target_sysroot_hdrs_suffix);
+         return (0);
+       }
+      else
+       /* The error status indicates that only one set of fixed
+          headers should be built.  */
+       fatal ("not configured with sysroot headers suffix");
+    }
+
   if (print_help_list)
     {
       display_help ();