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]

system include directories


Hi,
here are three patches concerning system include directories and changing
their search ordering.

The first patch changes cppinit.c to warn whenever -I options conspire to
change the search order for a system directory.

The second patch shows that a -isystem ./include is unnecessary in the
makefile as gcc will add the directory via a -B ./ option anyway

The third patch shows a problem with -frepo and collect. The toplevel
gcc will pass down its search path in environment variables COMPILER_PATH
and LIBRARY_PATH. tlink will pass all the original search paths directly
as they are in the .rpo file. The subgcc will merge these and either
1) complain about system search order changing
2) have the wrong search order

booted and tested on i686-pc-linux-gnu. ok for mainline?
I'd originally wanted this patch on the branch, given libstdc++'s &
fixinclude's sensitivity to system search order, but as it's affected some
other areas, I'm minded to be more cautious.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-05-08  Nathan Sidwell  <nathan@codesourcery.com>

	* cppinit.c (remove_dup_dirs): Inform if a system include
        directory is being reordered.

Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.157
diff -c -3 -p -r1.157 cppinit.c
*** cppinit.c	2001/04/06 07:21:59	1.157
--- cppinit.c	2001/05/08 15:47:02
*************** append_include_chain (pfile, dir, path, 
*** 264,269 ****
--- 264,270 ----
  /* Handle a duplicated include path.  PREV is the link in the chain
     before the duplicate.  The duplicate is removed from the chain and
     freed.  Returns PREV.  */
+ 
  struct search_path *
  remove_dup_dir (pfile, prev)
       cpp_reader *pfile;
*************** remove_dup_dir (pfile, prev)
*** 285,290 ****
--- 286,292 ----
     chain, or NULL if the chain is empty.  This algorithm is quadratic
     in the number of -I switches, which is acceptable since there
     aren't usually that many of them.  */
+ 
  struct search_path *
  remove_dup_dirs (pfile, head)
       cpp_reader *pfile;
*************** remove_dup_dirs (pfile, head)
*** 297,302 ****
--- 299,320 ----
        for (other = head; other != cur; other = other->next)
          if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
  	  {
+ 	    if (cur->sysp)
+ 	      {
+ 		const char *non = other->sysp ? "" : "non-";
+ 		
+ 		cpp_warning (pfile,
+ 			     _("changing search order for system directory \"%s\""),
+ 			     cur->name);
+ 		if (strcmp (cur->name, other->name))
+ 		  cpp_warning (pfile,
+ 			       _("  as it is aliased to %ssystem directory \"%s\""),
+ 			       non, other->name);
+ 		else
+ 		  cpp_warning (pfile,
+ 			       _("  as it has already been specified as a %ssystem directory"),
+ 			       non);
+ 	      }
  	    cur = remove_dup_dir (pfile, prev);
  	    break;
  	  }
*************** merge_include_chains (pfile)
*** 370,375 ****
--- 388,394 ----
  
  /* Sets internal flags correctly for a given language, and defines
     macros if necessary.  */
+ 
  static void
  set_lang (pfile, lang)
       cpp_reader *pfile;
2001-05-08  Nathan Sidwell  <nathan@codesourcery.com>

	* Makefile.in (GCC_FLAGS): Remove `-isystem ./include'.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.656
diff -c -3 -p -r1.656 Makefile.in
*** Makefile.in	2001/05/07 04:30:01	1.656
--- Makefile.in	2001/05/08 15:46:42
*************** INSTALL_ASSERT_H = install-assert-h
*** 182,190 ****
  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./.
! # It also specifies -isystem ./include to find, e.g., stddef.h.
! GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_WARN) -isystem ./include $(TCFLAGS)
  
  # Sed command to transform gcc to installed name.  Overwritten by configure.
  program_transform_name = @program_transform_name@
--- 182,191 ----
  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./
! # We do not need to add -isystem ./include, as that is implicitly added
! # because of the -B./
! GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_WARN) $(TCFLAGS)
  
  # Sed command to transform gcc to installed name.  Overwritten by configure.
  program_transform_name = @program_transform_name@
2001-05-08  Nathan Sidwell  <nathan@codesourcery.com>

	* tlink.c (recompile_files): Remove COMPILER_PATH and
	LIBRARY_PATH from the environment.

Index: tlink.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tlink.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 tlink.c
*** tlink.c	2001/05/04 14:36:38	1.34
--- tlink.c	2001/05/08 15:47:03
*************** recompile_files ()
*** 495,500 ****
--- 495,503 ----
  {
    file *f;
  
+   putenv ("COMPILER_PATH");
+   putenv ("LIBRARY_PATH");
+   
    while ((f = file_pop ()) != NULL)
      {
        char *line, *command;

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