public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH: cpp include directory search order warning
@ 2002-08-07  9:48 John David Anglin
  2002-08-07 11:52 ` Zack Weinberg
  0 siblings, 1 reply; 16+ messages in thread
From: John David Anglin @ 2002-08-07  9:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: zack

Here is a fix for the problems noted in this thread:

<http://gcc.gnu.org/ml/gcc/2002-07/msg01463.html>.

The warning from remove_dup_dirs is changed to an information message
generated only when the "-v" option is used.  This allows various
autoconf macros to reorder the search patch for includes and change
system directories to non-system directories without any warnings from
the preprocessor.  This will fix the problems caused by the warning.
However, don't complain to me about an incorrectly ordered include
search :-)

Without the fix, it is not possible to install libintl, libiconv,
etc in either the GCC prefix or local_prefix directories without
there being cpp warnings building packages which use these libraries.
In some cases, these warnings break configure scripts.

I changed the message itself because it's about the change of a
system directory to a non-system directory, and not about reordering.

The change to configure.in just fixes a minor problem of duplicated
directories when local_prefix and prefix have the same value.

I have attempted to summarize the site configuration issues regarding
include searching and library searching in a paragraph added to
install.texi.

Tested with no regressions on hppa2.0-hp-hpux11.00.

OK for main?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-08-07  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* configure.in (PREFIX_INCLUDE_DIR): Don't define if prefix and
	local_prefix are the same.
	* cppinit.c (remove_dup_dirs): Change warnings to verbose information
	messages.  Revise message text.
	* doc/install.texi (--with-local-prefix): Further document usage of
	this option.
	* configure: Rebuilt.

Index: configure.in
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/configure.in,v
retrieving revision 1.613
diff -u -3 -p -r1.613 configure.in
--- configure.in	2 Aug 2002 15:57:09 -0000	1.613
+++ configure.in	7 Aug 2002 15:37:21 -0000
@@ -2202,7 +2202,7 @@ case "$target" in
     ;;
 esac
 
-if test "$prefix" != "/usr" && test "$prefix" != "/usr/local" ; then
+if test "$prefix" != "/usr" && test "x$prefix" != "x$local_prefix" ; then
   AC_DEFINE_UNQUOTED(PREFIX_INCLUDE_DIR, "$prefix/include")
 fi
 
Index: cppinit.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.249
diff -u -3 -p -r1.249 cppinit.c
--- cppinit.c	6 Aug 2002 20:35:41 -0000	1.249
+++ cppinit.c	7 Aug 2002 15:37:22 -0000
@@ -296,18 +296,16 @@ remove_dup_dirs (pfile, head)
       for (other = head; other != cur; other = other->next)
 	if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
 	  {
-	    if (cur->sysp && !other->sysp)
+	    if (cur->sysp && !other->sysp && CPP_OPTION (pfile, verbose))
 	      {
-		cpp_error (pfile, DL_WARNING,
-			   "changing search order for system directory \"%s\"",
-			   cur->name);
+		fprintf (stderr, _("system directory \"%s\"\n"), cur->name);
 		if (strcmp (cur->name, other->name))
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it is the same as non-system directory \"%s\"",
-			     other->name);
+		  fprintf (stderr,
+			   _("  is the same as non-system directory \"%s\"\n"),
+			   other->name);
 		else
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it has already been specified as a non-system directory");
+		  fprintf (stderr,
+			   _("  was previously specified as a non-system directory\n"));
 	      }
 	    cur = remove_dup_dir (pfile, prev);
 	    break;
Index: doc/install.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.130
diff -u -3 -p -r1.130 install.texi
--- doc/install.texi	6 Aug 2002 15:08:07 -0000	1.130
+++ doc/install.texi	7 Aug 2002 15:37:23 -0000
@@ -467,6 +467,21 @@ any in that directory---are not part of 
 programs---perhaps many others.  (GCC installs its own header files in
 another directory which is based on the @option{--prefix} value.)
 
+The local-prefix include directory is searched before the GCC-prefix
+include directory.  Some autoconf macros use @option{-I} to change the
+search order for directories containing installed packages.  This can
+result in a GCC system directory being changed to a non-system directory.
+It may be advisable to not use either of these two prefixes for package
+installation if this is a concern.  On the otherhand, GCC autmatically
+searches for ordinary libraries using @env{GCC_EXEC_PREFIX} without
+the user having to specify a linker search path.  Therefore, using
+the GCC-prefix directory for packages may provide a site configuration
+that is easier use.  It is possible to use the same value for both
+@option{--with-local-prefix} and @option{--prefix} provided the value
+is not @file{/usr}.  This can be used to avoid the default search of
+@file{/usr/local/include} when GCC is installed in a non-standard
+location.
+
 @strong{Do not} specify @file{/usr} as the @option{--with-local-prefix}!
 The directory you use for @option{--with-local-prefix} @strong{must not}
 contain any of the system's standard header files.  If it did contain

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07  9:48 PATCH: cpp include directory search order warning John David Anglin
@ 2002-08-07 11:52 ` Zack Weinberg
  2002-08-07 12:27   ` Nathan Sidwell
  2002-08-07 13:06   ` PATCH: cpp include directory search order warning John David Anglin
  0 siblings, 2 replies; 16+ messages in thread
From: Zack Weinberg @ 2002-08-07 11:52 UTC (permalink / raw)
  To: John David Anglin, Nathan Sidwell; +Cc: gcc-patches

On Wed, Aug 07, 2002 at 12:48:48PM -0400, John David Anglin wrote:
> Here is a fix for the problems noted in this thread:
> 
> <http://gcc.gnu.org/ml/gcc/2002-07/msg01463.html>.
> 
> The warning from remove_dup_dirs is changed to an information message
> generated only when the "-v" option is used.  This allows various
> autoconf macros to reorder the search patch for includes and change
> system directories to non-system directories without any warnings from
> the preprocessor.  This will fix the problems caused by the warning.
> However, don't complain to me about an incorrectly ordered include
> search :-)
> 
> Without the fix, it is not possible to install libintl, libiconv,
> etc in either the GCC prefix or local_prefix directories without
> there being cpp warnings building packages which use these libraries.
> In some cases, these warnings break configure scripts.

As I said in the previous thread, I don't want to make _any_ changes
to the current behavior until we have consensus from all people
involved that the change is correct.  I'm not even convinced that we
know the scope of the problem.  I would prefer that all involved spend
time doing research into that, _before_ we start tossing patches
around.  We've had several cases come up where the current behavior is
a problem; we've had some handwaving around why -I /usr/include is a
bad idea; that's not nearly exhaustive yet.

The original patch introducing this warning was written by Nathan
Sidwell.  I would like to get his input.  Last time I tried to contact
him on this, the mail bounced; here's trying again.

> The change to configure.in just fixes a minor problem of duplicated
> directories when local_prefix and prefix have the same value.

This change is independent of the warning issue; go ahead and check it
in now.

> I have attempted to summarize the site configuration issues regarding
> include searching and library searching in a paragraph added to
> install.texi.

This is very helpful, thank you.  I see some typos in the text -
please check and correct these.

> +Some autoconf macros use @option{-I} to change the
> +search order for directories containing installed packages.  This can
> +result in a GCC system directory being changed to a non-system directory.

I believe it is more accurate to say that

  Some autoconf macros add @option{-I @var{directory}} options to the
  compiler command line, to ensure that directories containing
  installed packages' headers are searched.  When @var{directory} is
  one of GCC's "system include" directories, this will cause it to
  be treated as a non-system directory.

Note the intent of the autoconf macro in putting the -I option on the
command line.  Not to tweak the search order - just to make sure that
package headers get found.  This raises an alternate possibility for
solving the problem: When we see -I <dir> where <dir> is already on
the default include path, ignore the -I option (give notice of this
under -v).  If the default include path is suppressed by -nostdinc,
then this naturally does not happen.

Would that treatment work in your environment, John?  Anyone else have
an opinion?

zw

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 11:52 ` Zack Weinberg
@ 2002-08-07 12:27   ` Nathan Sidwell
  2002-08-07 13:17     ` John David Anglin
  2002-08-09 14:56     ` PATCH: cpp include directory search order warning (mark 2) John David Anglin
  2002-08-07 13:06   ` PATCH: cpp include directory search order warning John David Anglin
  1 sibling, 2 replies; 16+ messages in thread
From: Nathan Sidwell @ 2002-08-07 12:27 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: John David Anglin, gcc-patches

Zack Weinberg wrote:
> 
> On Wed, Aug 07, 2002 at 12:48:48PM -0400, John David Anglin wrote:
> > Here is a fix for the problems noted in this thread:
> >
> > [warn only when -v]

> The original patch introducing this warning was written by Nathan
> Sidwell.  I would like to get his input.  Last time I tried to contact
> him on this, the mail bounced; here's trying again.
Sorry, I've stopped being Tigger now. I implemented that patch
as I got very confused trying to figure out why some system I was
building something on was malfunctioning. I can't recall if
/usr/include or <prefix>/include was involved.

> Note the intent of the autoconf macro in putting the -I option on the
> command line.  Not to tweak the search order - just to make sure that
> package headers get found.  This raises an alternate possibility for
> solving the problem: When we see -I <dir> where <dir> is already on
> the default include path, ignore the -I option (give notice of this
> under -v).  If the default include path is suppressed by -nostdinc,
> then this naturally does not happen.
I think this solution is almost equivalent to David's patch, but has
a different failure mode.
1) both fixes will only give you information under -v
2) David's patch will change a system dir to a non system dir, and
break any include_nexts that rely on the builtin ordering
3) Zack's (yet to be written) patch will give you a search order
(that might be) different to what you asked for, but does fulfil the
spirit, in that the directory will be searched.

Zack's solution seems safer.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 11:52 ` Zack Weinberg
  2002-08-07 12:27   ` Nathan Sidwell
@ 2002-08-07 13:06   ` John David Anglin
  2002-08-07 13:28     ` Neil Booth
  1 sibling, 1 reply; 16+ messages in thread
From: John David Anglin @ 2002-08-07 13:06 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: nathan, gcc-patches

> Note the intent of the autoconf macro in putting the -I option on the
> command line.  Not to tweak the search order - just to make sure that
> package headers get found.  This raises an alternate possibility for

This was not my impression.  The patch that I originally proposed
to fix the gettext macros checked whether <dir> would generate the
cpp warning and didn't add "-I <dir>" if it did.  I presumed that
the objection was that the search order would be incorrect if the
-I option was dropped.  However, possibly the objection was simply
that it didn't resolve the issue for packages already released
with macros that add -I <dir> rather than anything to do with the
patch itself.

> solving the problem: When we see -I <dir> where <dir> is already on
> the default include path, ignore the -I option (give notice of this
> under -v).  If the default include path is suppressed by -nostdinc,
> then this naturally does not happen.

This is more of a change in behavior than what I proposed.  Previous
versions of gcc allowed users to add any <dir> into the chain with
-I.  When duplicates have been removed, they have been removed from
the tail of the chain.  My thought was to allow the user to order
includes in whatever manner he/she thought best and leave the
removal of duplicates as is.  The only change was to make the warning
a notice under -v.

On the otherhand, the above prevents a user from changing a system
directory to a non-system directory, and reordering the default
search of system directories with -I.  Maybe not a bad idea given
the pitfalls.

> Would that treatment work in your environment, John?  Anyone else have
> an opinion?

It should work.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 12:27   ` Nathan Sidwell
@ 2002-08-07 13:17     ` John David Anglin
  2002-08-09 14:56     ` PATCH: cpp include directory search order warning (mark 2) John David Anglin
  1 sibling, 0 replies; 16+ messages in thread
From: John David Anglin @ 2002-08-07 13:17 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: zack, gcc-patches

> 3) Zack's (yet to be written) patch will give you a search order
> (that might be) different to what you asked for, but does fulfil the
> spirit, in that the directory will be searched.
> 
> Zack's solution seems safer.

OK, I will take a crack at implementing it as I would like to get
an acceptable solution.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 13:06   ` PATCH: cpp include directory search order warning John David Anglin
@ 2002-08-07 13:28     ` Neil Booth
  2002-08-07 13:43       ` John David Anglin
  2002-08-07 14:48       ` John David Anglin
  0 siblings, 2 replies; 16+ messages in thread
From: Neil Booth @ 2002-08-07 13:28 UTC (permalink / raw)
  To: John David Anglin; +Cc: Zack Weinberg, nathan, gcc-patches

John David Anglin wrote:-

> On the otherhand, the above prevents a user from changing a system
> directory to a non-system directory, and reordering the default
> search of system directories with -I.  Maybe not a bad idea given
> the pitfalls.

Is there any good reason why a user might want to make a system directory
be a non-system directory?  If not, then I think Zack's suggestion is
a good plan.

Slightly off-topic:

The only thing I don't like is the listing under -v.  It's always seemed
a bit out of place, and bugged me a bit.  Why does -v display the
directory list anyway?  Do tools in the wild send -v and parse the
output to get this info?

What I'd like to do is get rid of the listing under -v, and implement
something like that suggested in PR preprocessor/4917.  I quote:

"This is an enhancement request to make the -print-search-dirs option
show the #include directory search list.

Currently, the output of gcc -print-search-dirs contains three lines:
    install: ...
    programs: ...
    libraries: ...

This proposal is to add a new line
    sysinclude: ... 
which would contain a :-separated list of directories searched by
#include <...> 

This would be useful for curious humans as well as automated scripts
to generate a tags database."

I believe -print-search-dirs is a driver option.  Sadly, the driver
does not have access to CPP's include list, so it cannot print this
stuff at present.  Further, the driver exits immediately after
dumping the info, making it awkward to pass the flag on to cc1,
particularly as it is effectively language-specific in this case.
However, I think we should do something like this.

I'm not sure what to do about CPP's default compiled-in include path.
We need it for fix-header, which links against cpplib, so I think cpplib
needs to be aware of it (rather than moving the logic into cc1 or even
the driver).  However, cpplib shouldn't be doing command-line switch
parsing, and so -I etc. should be moved to cc1 or to gcc.  cpplib should
export some interface where you pass it a list of paths, and something
equivalent to -nostdinc, and it merges those with its compiled-in default.

Neil.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 13:28     ` Neil Booth
@ 2002-08-07 13:43       ` John David Anglin
  2002-08-07 14:48       ` John David Anglin
  1 sibling, 0 replies; 16+ messages in thread
From: John David Anglin @ 2002-08-07 13:43 UTC (permalink / raw)
  To: Neil Booth; +Cc: zack, nathan, gcc-patches

> Is there any good reason why a user might want to make a system directory
> be a non-system directory?  If not, then I think Zack's suggestion is
> a good plan.

The only reason that I came up with was to actually check headers
with non-system error checking.  However, you can probably use
-nostdinc together with -I for that.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning
  2002-08-07 13:28     ` Neil Booth
  2002-08-07 13:43       ` John David Anglin
@ 2002-08-07 14:48       ` John David Anglin
  1 sibling, 0 replies; 16+ messages in thread
From: John David Anglin @ 2002-08-07 14:48 UTC (permalink / raw)
  To: Neil Booth; +Cc: zack, nathan, gcc-patches

> Slightly off-topic:
> 
> The only thing I don't like is the listing under -v.  It's always seemed
> a bit out of place, and bugged me a bit.  Why does -v display the
> directory list anyway?  Do tools in the wild send -v and parse the
> output to get this info?

I did propose a patch to a couple of autoconf macros to do exactly that.
Given the number of search chains that get merged and the ignoring of
duplicate directories, I think this is still a useful feature to have.

The output of gcc -print-search-dirs varies depending on the setting
of environment variables such as LIBRARY_PATH but it doesn't take into
account -L options.  Don't know about -B.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* PATCH: cpp include directory search order warning (mark 2)
  2002-08-07 12:27   ` Nathan Sidwell
  2002-08-07 13:17     ` John David Anglin
@ 2002-08-09 14:56     ` John David Anglin
  2002-08-12  2:42       ` Nathan Sidwell
  1 sibling, 1 reply; 16+ messages in thread
From: John David Anglin @ 2002-08-09 14:56 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: zack, gcc-patches

> 3) Zack's (yet to be written) patch will give you a search order
> (that might be) different to what you asked for, but does fulfil the
> spirit, in that the directory will be searched.

Here is a crack at implementing Zack's suggestion.  I didn't implement
any warnings because, if the patch is correct, a -I option will never
reorder the system include chain or cause a system include directory to
be ignored.

I have also enclosed a revised version of the text for install.texi
which I think is somewhat clearer and incorporates previous suggestions.

The current version of that patch has survived bootstrap on hppa-linux
and hppa64-hp-hpux11.00.  Regression testing is in progress.  I didn't
see any regressions in previous versions.  I have manually observed
the effect of adding a system directory with -I to the include chain.
I have checked various alternatives at the quote-bracket boundary.
I have sucessfully built a number of packages which add GCC "system
include" directories to CPPFLAGS under hppa2.0w-hp-hpux11.00
with a previous of the patch.  This version does a simpler and more
efficient removal of non-system directories from the quote chain
after it is merged.

Are we getting any closer to a solution?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-08-09  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* cppinit.c (remove_dup_dir): Add head_ptr argument to handle removal
	at head.
	(remove_dup_nonsys_dirs): New function.
	(remove_dup_dirs): Change argument head to head_ptr.  Remove warnings.
	(merge_include_chains): Remove non-system include directories from
	quote and bracket include chains when they duplicate equivalent system
	directories.
	* doc/install.texi (--with-local-prefix): Further document usage of
	this option.

Index: cppinit.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.251
diff -u -3 -p -r1.251 cppinit.c
--- cppinit.c	9 Aug 2002 06:19:08 -0000	1.251
+++ cppinit.c	9 Aug 2002 20:39:46 -0000
@@ -95,9 +95,13 @@ static void mark_named_operators	PARAMS 
 static void append_include_chain	PARAMS ((cpp_reader *,
 						 char *, int, int));
 static struct search_path * remove_dup_dir	PARAMS ((cpp_reader *,
+						 struct search_path *,
+						 struct search_path **));
+static struct search_path * remove_dup_nonsys_dirs PARAMS ((cpp_reader *,
+						 struct search_path **,
 						 struct search_path *));
 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
-						 struct search_path *));
+						 struct search_path **));
 static void merge_include_chains	PARAMS ((cpp_reader *));
 static bool push_include		PARAMS ((cpp_reader *,
 						 struct pending_option *));
@@ -260,55 +264,86 @@ append_include_chain (pfile, dir, path, 
 }
 
 /* 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.  */
+   before the duplicate, or NULL if the duplicate is at the head of
+   the chain.  The duplicate is removed from the chain and freed.
+   Returns PREV.  */
 static struct search_path *
-remove_dup_dir (pfile, prev)
+remove_dup_dir (pfile, prev, head_ptr)
      cpp_reader *pfile;
      struct search_path *prev;
+     struct search_path **head_ptr;
 {
-  struct search_path *cur = prev->next;
+  struct search_path *cur;
+
+  if (prev != NULL)
+    {
+      cur = prev->next;
+      prev->next = cur->next;
+    }
+  else
+    {
+      cur = *head_ptr;
+      *head_ptr = cur->next;
+    }
 
   if (CPP_OPTION (pfile, verbose))
     fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
 
-  prev->next = cur->next;
   free ((PTR) cur->name);
   free (cur);
 
   return prev;
 }
 
+/* Remove duplicate non-system directories for which there is an equivalent
+   system directory latter in the chain.  The range for removal is between
+   *HEAD_PTR and END.  Returns the directory before END, or NULL if none.
+   This algorithm is quadratic in the number of -I switches, which is
+   acceptable since there aren't usually that many of them.  */
+static struct search_path *
+remove_dup_nonsys_dirs (pfile, head_ptr, end)
+     cpp_reader *pfile;
+     struct search_path **head_ptr;
+     struct search_path *end;
+{
+  struct search_path *prev = NULL, *cur, *other;
+
+  for (cur = *head_ptr; cur != end; cur = cur ? cur->next : *head_ptr)
+    {
+      if (!cur->sysp)
+	{
+	  for (other = cur->next; other; other = other->next)
+	    if (INO_T_EQ (cur->ino, other->ino)
+		&& cur->dev == other->dev
+		&& other->sysp)
+	      {
+		cur = remove_dup_dir (pfile, prev, head_ptr);
+		break;
+	      }
+	}
+      prev = cur;
+    }
+
+  return prev;
+}
+
 /* Remove duplicate directories from a chain.  Returns the tail of the
    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.  */
 static struct search_path *
-remove_dup_dirs (pfile, head)
+remove_dup_dirs (pfile, head_ptr)
      cpp_reader *pfile;
-     struct search_path *head;
+     struct search_path **head_ptr;
 {
   struct search_path *prev = NULL, *cur, *other;
 
-  for (cur = head; cur; cur = cur->next)
+  for (cur = *head_ptr; cur; cur = cur->next)
     {
-      for (other = head; other != cur; other = other->next)
+      for (other = *head_ptr; other != cur; other = other->next)
 	if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
 	  {
-	    if (cur->sysp && !other->sysp)
-	      {
-		cpp_error (pfile, DL_WARNING,
-			   "changing search order for system directory \"%s\"",
-			   cur->name);
-		if (strcmp (cur->name, other->name))
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it is the same as non-system directory \"%s\"",
-			     other->name);
-		else
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it has already been specified as a non-system directory");
-	      }
-	    cur = remove_dup_dir (pfile, prev);
+	    cur = remove_dup_dir (pfile, prev, head_ptr);
 	    break;
 	  }
       prev = cur;
@@ -346,28 +381,33 @@ merge_include_chains (pfile)
   else
     brack = systm;
 
-  /* This is a bit tricky.  First we drop dupes from the quote-include
-     list.  Then we drop dupes from the bracket-include list.
-     Finally, if qtail and brack are the same directory, we cut out
-     brack and move brack up to point to qtail.
+  /* This is a bit tricky.  First we drop non-system dupes of system
+     directories from the merged bracket-include list.  Next we drop
+     dupes from the bracket and quote include lists.  Then we drop
+     non-system dupes from the merged quote-include list.  Finally,
+     if qtail and brack are the same directory, we cut out brack and
+     move brack up to point to qtail.
 
      We can't just merge the lists and then uniquify them because
      then we may lose directories from the <> search path that should
-     be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
+     be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux.  It is however
      safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
      -Ibar -I- -Ifoo -Iquux.  */
 
-  remove_dup_dirs (pfile, brack);
-  qtail = remove_dup_dirs (pfile, quote);
+  remove_dup_nonsys_dirs (pfile, &brack, NULL);
+  remove_dup_dirs (pfile, &brack);
 
   if (quote)
     {
+      qtail = remove_dup_dirs (pfile, &quote);
       qtail->next = brack;
 
+      qtail = remove_dup_nonsys_dirs (pfile, &quote, brack);
+
       /* If brack == qtail, remove brack as it's simpler.  */
-      if (brack && INO_T_EQ (qtail->ino, brack->ino)
+      if (qtail && brack && INO_T_EQ (qtail->ino, brack->ino)
 	  && qtail->dev == brack->dev)
-	brack = remove_dup_dir (pfile, qtail);
+	brack = remove_dup_dir (pfile, qtail, &quote);
     }
   else
     quote = brack;
Index: doc/install.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.131
diff -u -3 -p -r1.131 install.texi
--- doc/install.texi	8 Aug 2002 09:10:39 -0000	1.131
+++ doc/install.texi	9 Aug 2002 20:39:47 -0000
@@ -467,6 +467,43 @@ any in that directory---are not part of 
 programs---perhaps many others.  (GCC installs its own header files in
 another directory which is based on the @option{--prefix} value.)
 
+Both the local-prefix include directory and the GCC-prefix include
+directory are part of GCC's "system include" directories.  Although these
+two directories are not fixed, they need to be searched in the proper
+order for the correct processing of the include_next directive.  The
+local-prefix include directory is searched before the GCC-prefix
+include directory.  Another characteristic of system include directories
+is that pedantic warnings are turned off for headers in these directories.
+
+Some autoconf macros add @option{-I @var{directory}} options to the
+compiler command line, to ensure that directories containing installed
+packages' headers are searched.  When @var{directory} is one of GCC's
+system include directories, GCC will ignore the option so that system
+directories are continued to be processed in the correct order.  This
+may result in a search order different from what was specified but the
+directory will still be searched.
+
+GCC automatically searches for ordinary libraries using
+@env{GCC_EXEC_PREFIX}.  Thus, when the same installation prefix is
+used for both GCC and packages, GCC will automatically search for
+both headers and libraries.  This provides a configuration that is
+easy to use.  GCC behaves in a manner similar to that when it is
+installed as a system compiler in @file{/usr}.
+
+Sites that need to install multiple versions of GCC may not want to
+use the above simple configuration.  It is possible to use the
+@option{--program-prefix}, @option{--program-suffix} and
+@option{--program-transform-name} options to install multiple versions
+into a single directory, but it may be simpler to use different prefixes
+and the @option{--with-local-prefix} option to specify the location of the
+site-specific files for each version.  It will then be necessary for
+users to specify explicitly the location of local site libraries
+(e.g., with @env{LIBRARY_PATH}).
+
+The same value can be used for both @option{--with-local-prefix} and
+@option{--prefix} provided it is not @file{/usr}.  This can be used
+to avoid the default search of @file{/usr/local/include}.
+
 @strong{Do not} specify @file{/usr} as the @option{--with-local-prefix}!
 The directory you use for @option{--with-local-prefix} @strong{must not}
 contain any of the system's standard header files.  If it did contain

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 2)
  2002-08-09 14:56     ` PATCH: cpp include directory search order warning (mark 2) John David Anglin
@ 2002-08-12  2:42       ` Nathan Sidwell
  2002-08-13 13:27         ` PATCH: cpp include directory search order warning (mark 3) John David Anglin
  0 siblings, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2002-08-12  2:42 UTC (permalink / raw)
  To: John David Anglin; +Cc: Nathan Sidwell, zack, gcc-patches

John David Anglin wrote:
> 
> > 3) Zack's (yet to be written) patch will give you a search order
> > (that might be) different to what you asked for, but does fulfil the
> > spirit, in that the directory will be searched.
> 
> Here is a crack at implementing Zack's suggestion.  I didn't implement
> any warnings because, if the patch is correct, a -I option will never
> reorder the system include chain or cause a system include directory to
> be ignored.
I think you should get a warning (under -v or whatever), when this happens.
Although the set of directories searched is correct, the order in which
they are traversed might be 'surprising'. This kind of configuration
bug is a pain to track down without such feedback. (There may
be two different foolib headers in different directories, and dammit, why
does the compiler insist on picking up the 'later' one?)

Other than that, fine by me.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-12  2:42       ` Nathan Sidwell
@ 2002-08-13 13:27         ` John David Anglin
  2002-08-14  7:37           ` Nathan Sidwell
  2002-08-20 11:48           ` Zack Weinberg
  0 siblings, 2 replies; 16+ messages in thread
From: John David Anglin @ 2002-08-13 13:27 UTC (permalink / raw)
  To: nathan; +Cc: nathan, zack, gcc-patches

> > Here is a crack at implementing Zack's suggestion.  I didn't implement
> > any warnings because, if the patch is correct, a -I option will never
> > reorder the system include chain or cause a system include directory to
> > be ignored.
> I think you should get a warning (under -v or whatever), when this happens.

I added a warning under -v and updated more of the documentation
to describe the new treatment of -Idir when dir duplicates a system
directory.  I have also implemented a suggestion from Nix regarding
revising the search in remove_dup_nonsys_dirs.  This makes it more
efficient, although it is less obvious now as to what value is being
returned.

Tested by inspection of cpp output with -v and a bootstrap-check
under hppa-linux.

Ok for main?  

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-08-13  John David Anglin  <dave@hiauly1.hia.nrc.ca>

        * cppinit.c (remove_dup_dir): Add head_ptr argument to handle removal
	at head.
	(remove_dup_nonsys_dirs): New function.
	(remove_dup_dirs): Change argument head to head_ptr.  Remove warnings.
	(merge_include_chains): Remove non-system include directories from
	quote and bracket include chains when they duplicate equivalent system
	directories.
	* doc/cpp.texi (-I): Update.
	* doc/cppopts.texi (-I): Update.
	* doc/install.texi (--with-local-prefix): Further document usage of
	this option.
	* doc/invoke.texi (-I): Update.

Index: cppinit.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.257
diff -u -3 -p -r1.257 cppinit.c
--- cppinit.c	12 Aug 2002 22:44:29 -0000	1.257
+++ cppinit.c	13 Aug 2002 19:43:12 -0000
@@ -94,9 +94,13 @@ static void mark_named_operators	PARAMS 
 static void append_include_chain	PARAMS ((cpp_reader *,
 						 char *, int, int));
 static struct search_path * remove_dup_dir	PARAMS ((cpp_reader *,
+						 struct search_path *,
+						 struct search_path **));
+static struct search_path * remove_dup_nonsys_dirs PARAMS ((cpp_reader *,
+						 struct search_path **,
 						 struct search_path *));
 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
-						 struct search_path *));
+						 struct search_path **));
 static void merge_include_chains	PARAMS ((cpp_reader *));
 static bool push_include		PARAMS ((cpp_reader *,
 						 struct pending_option *));
@@ -257,55 +261,91 @@ append_include_chain (pfile, dir, path, 
 }
 
 /* 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.  */
+   before the duplicate, or NULL if the duplicate is at the head of
+   the chain.  The duplicate is removed from the chain and freed.
+   Returns PREV.  */
 static struct search_path *
-remove_dup_dir (pfile, prev)
+remove_dup_dir (pfile, prev, head_ptr)
      cpp_reader *pfile;
      struct search_path *prev;
+     struct search_path **head_ptr;
 {
-  struct search_path *cur = prev->next;
+  struct search_path *cur;
+
+  if (prev != NULL)
+    {
+      cur = prev->next;
+      prev->next = cur->next;
+    }
+  else
+    {
+      cur = *head_ptr;
+      *head_ptr = cur->next;
+    }
 
   if (CPP_OPTION (pfile, verbose))
     fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
 
-  prev->next = cur->next;
   free ((PTR) cur->name);
   free (cur);
 
   return prev;
 }
 
+/* Remove duplicate non-system directories for which there is an equivalent
+   system directory latter in the chain.  The range for removal is between
+   *HEAD_PTR and END.  Returns the directory before END, or NULL if none.
+   This algorithm is quadratic in the number system directories, which is
+   acceptable since there aren't usually that many of them.  */
+static struct search_path *
+remove_dup_nonsys_dirs (pfile, head_ptr, end)
+     cpp_reader *pfile;
+     struct search_path **head_ptr;
+     struct search_path *end;
+{
+  struct search_path *prev, *cur, *other;
+
+  for (cur = *head_ptr; cur; cur = cur->next)
+    {
+      if (cur->sysp)
+	{
+	  for (other = *head_ptr, prev = NULL;
+	       other != end;
+	       other = other ? other->next : *head_ptr)
+	    {
+	      if (!other->sysp
+		  && INO_T_EQ (cur->ino, other->ino)
+		  && cur->dev == other->dev)
+		{
+		  other = remove_dup_dir (pfile, prev, head_ptr);
+		  if (CPP_OPTION (pfile, verbose))
+		    fprintf (stderr, _("  as it is a non-system directory that duplicates a system directory\n"));
+		}
+	      prev = other;
+	    }
+	}
+    }
+
+  return prev;
+}
+
 /* Remove duplicate directories from a chain.  Returns the tail of the
    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.  */
 static struct search_path *
-remove_dup_dirs (pfile, head)
+remove_dup_dirs (pfile, head_ptr)
      cpp_reader *pfile;
-     struct search_path *head;
+     struct search_path **head_ptr;
 {
   struct search_path *prev = NULL, *cur, *other;
 
-  for (cur = head; cur; cur = cur->next)
+  for (cur = *head_ptr; cur; cur = cur->next)
     {
-      for (other = head; other != cur; other = other->next)
+      for (other = *head_ptr; other != cur; other = other->next)
 	if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
 	  {
-	    if (cur->sysp && !other->sysp)
-	      {
-		cpp_error (pfile, DL_WARNING,
-			   "changing search order for system directory \"%s\"",
-			   cur->name);
-		if (strcmp (cur->name, other->name))
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it is the same as non-system directory \"%s\"",
-			     other->name);
-		else
-		  cpp_error (pfile, DL_WARNING,
-			     "  as it has already been specified as a non-system directory");
-	      }
-	    cur = remove_dup_dir (pfile, prev);
+	    cur = remove_dup_dir (pfile, prev, head_ptr);
 	    break;
 	  }
       prev = cur;
@@ -343,28 +383,33 @@ merge_include_chains (pfile)
   else
     brack = systm;
 
-  /* This is a bit tricky.  First we drop dupes from the quote-include
-     list.  Then we drop dupes from the bracket-include list.
-     Finally, if qtail and brack are the same directory, we cut out
-     brack and move brack up to point to qtail.
+  /* This is a bit tricky.  First we drop non-system dupes of system
+     directories from the merged bracket-include list.  Next we drop
+     dupes from the bracket and quote include lists.  Then we drop
+     non-system dupes from the merged quote-include list.  Finally,
+     if qtail and brack are the same directory, we cut out brack and
+     move brack up to point to qtail.
 
      We can't just merge the lists and then uniquify them because
      then we may lose directories from the <> search path that should
-     be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
+     be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux.  It is however
      safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
      -Ibar -I- -Ifoo -Iquux.  */
 
-  remove_dup_dirs (pfile, brack);
-  qtail = remove_dup_dirs (pfile, quote);
+  remove_dup_nonsys_dirs (pfile, &brack, systm);
+  remove_dup_dirs (pfile, &brack);
 
   if (quote)
     {
+      qtail = remove_dup_dirs (pfile, &quote);
       qtail->next = brack;
 
+      qtail = remove_dup_nonsys_dirs (pfile, &quote, brack);
+
       /* If brack == qtail, remove brack as it's simpler.  */
-      if (brack && INO_T_EQ (qtail->ino, brack->ino)
+      if (qtail && brack && INO_T_EQ (qtail->ino, brack->ino)
 	  && qtail->dev == brack->dev)
-	brack = remove_dup_dir (pfile, qtail);
+	brack = remove_dup_dir (pfile, qtail, &quote);
     }
   else
     quote = brack;
Index: doc/cpp.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.40
diff -u -3 -p -r1.40 cpp.texi
--- doc/cpp.texi	6 Aug 2002 20:35:45 -0000	1.40
+++ doc/cpp.texi	13 Aug 2002 19:43:12 -0000
@@ -823,9 +823,18 @@ version of GCC in use.
 
 You can add to this list with the @option{-I@var{dir}} command line
 option.  All the directories named by @option{-I} are searched, in
-left-to-right order, @emph{before} the default directories.  You can
-also prevent GCC from searching any of the default directories with the
-@option{-nostdinc} option.  This is useful when you are compiling an
+left-to-right order, @emph{before} the default directories.  The only
+exception is when @file{dir} is also a default system directory.  In
+this case, the option is ignored and the default search order for system
+directories remains unchanged.
+
+Duplicate directories are removed from the quote and bracket search
+chains before the two chains are merged to make the final search chain.
+Thus, it is possible for a directory to occur twice in the final search
+chain if it was specified in both the quote and bracket chains.
+
+You can prevent GCC from searching any of the default directories with
+the @option{-nostdinc} option.  This is useful when you are compiling an
 operating system kernel or some other program that does not use the
 standard C library facilities, or the standard C library itself.
 
@@ -836,12 +845,6 @@ For example, if @file{/usr/include/sys/s
 @code{@w{#include "types.h"}}, GCC looks for @file{types.h} first in
 @file{/usr/include/sys}, then in its usual search path.
 
-If you name a search directory with @option{-I@var{dir}} that is also a
-system include directory, the @option{-I} wins; the directory will be
-searched according to the @option{-I} ordering, and it will not be
-treated as a system include directory. GCC will warn you when a system
-include directory is hidden in this way.
-
 @samp{#line} (@pxref{Line Control}) does not change GCC's idea of the
 directory containing the current file.
 
@@ -1074,8 +1077,8 @@ found in that directory will be consider
 All directories named by @option{-isystem} are searched @emph{after} all
 directories named by @option{-I}, no matter what their order was on the
 command line.  If the same directory is named by both @option{-I} and
-@option{-isystem}, @option{-I} wins; it is as if the @option{-isystem} option
-had never been specified at all. GCC warns you when this happens.
+@option{-isystem}, the @option{-I} option is ignored.  GCC provides an
+information message when this occurs if @option{-v} is used.
 
 @findex #pragma GCC system_header
 There is also a directive, @code{@w{#pragma GCC system_header}}, which
@@ -1817,9 +1820,7 @@ conformance to the C Standard.  CPP foll
 processing system header files, but when processing user files
 @code{__STDC__} is always 1.  This has been reported to cause problems;
 for instance, some versions of Solaris provide X Windows headers that
-expect @code{__STDC__} to be either undefined or 1.  You may be able to
-work around this sort of problem by using an @option{-I} option to
-cancel treatment of those headers as system headers.  @xref{Invocation}.
+expect @code{__STDC__} to be either undefined or 1.  @xref{Invocation}.
 
 @item __STDC_VERSION__
 This macro expands to the C Standard's version number, a long integer
Index: doc/cppopts.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/cppopts.texi,v
retrieving revision 1.13
diff -u -3 -p -r1.13 cppopts.texi
--- doc/cppopts.texi	10 Aug 2002 20:58:45 -0000	1.13
+++ doc/cppopts.texi	13 Aug 2002 19:43:12 -0000
@@ -51,16 +51,14 @@ for header files.
 @xref{Search Path}.
 @end ifset
 Directories named by @option{-I} are searched before the standard
-system include directories.
-
-It is dangerous to specify a standard system include directory in an
-@option{-I} option.  This defeats the special treatment of system
-headers
+system include directories.  If the directory @var{dir} is a standard
+system include directory, the option is ignored to ensure that the
+default search order for system directories and the special treatment
+of system headers are not defeated
 @ifset cppmanual
 (@pxref{System Headers})
 @end ifset
-.  It can also defeat the repairs to buggy system headers which GCC
-makes when it is installed.
+.
 
 @item -o @var{file}
 @opindex o
Index: doc/install.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/install.texi,v
retrieving revision 1.131
diff -u -3 -p -r1.131 install.texi
--- doc/install.texi	8 Aug 2002 09:10:39 -0000	1.131
+++ doc/install.texi	13 Aug 2002 19:43:12 -0000
@@ -467,6 +467,43 @@ any in that directory---are not part of 
 programs---perhaps many others.  (GCC installs its own header files in
 another directory which is based on the @option{--prefix} value.)
 
+Both the local-prefix include directory and the GCC-prefix include
+directory are part of GCC's "system include" directories.  Although these
+two directories are not fixed, they need to be searched in the proper
+order for the correct processing of the include_next directive.  The
+local-prefix include directory is searched before the GCC-prefix
+include directory.  Another characteristic of system include directories
+is that pedantic warnings are turned off for headers in these directories.
+
+Some autoconf macros add @option{-I @var{directory}} options to the
+compiler command line, to ensure that directories containing installed
+packages' headers are searched.  When @var{directory} is one of GCC's
+system include directories, GCC will ignore the option so that system
+directories continue to be processed in the correct order.  This
+may result in a search order different from what was specified but the
+directory will still be searched.
+
+GCC automatically searches for ordinary libraries using
+@env{GCC_EXEC_PREFIX}.  Thus, when the same installation prefix is
+used for both GCC and packages, GCC will automatically search for
+both headers and libraries.  This provides a configuration that is
+easy to use.  GCC behaves in a manner similar to that when it is
+installed as a system compiler in @file{/usr}.
+
+Sites that need to install multiple versions of GCC may not want to
+use the above simple configuration.  It is possible to use the
+@option{--program-prefix}, @option{--program-suffix} and
+@option{--program-transform-name} options to install multiple versions
+into a single directory, but it may be simpler to use different prefixes
+and the @option{--with-local-prefix} option to specify the location of the
+site-specific files for each version.  It will then be necessary for
+users to specify explicitly the location of local site libraries
+(e.g., with @env{LIBRARY_PATH}).
+
+The same value can be used for both @option{--with-local-prefix} and
+@option{--prefix} provided it is not @file{/usr}.  This can be used
+to avoid the default search of @file{/usr/local/include}.
+
 @strong{Do not} specify @file{/usr} as the @option{--with-local-prefix}!
 The directory you use for @option{--with-local-prefix} @strong{must not}
 contain any of the system's standard header files.  If it did contain
@@ -667,11 +704,24 @@ Microsoft Win32 API thread support.
 
 @item --with-cpu=@var{cpu}
 Specify which cpu variant the
-compiler should generate code for by default.  This is currently
-only supported on the some ports, specifically arm, powerpc, and
-SPARC@.  If configure does not recognize the model name (e.g.@: arm700,
-603e, or ultrasparc) you provide, please check the configure script
-for a complete list of supported models.
+compiler should generate code for by default.  @var{cpu}
+will be used as the default value of the @code{-mcpu=} switch.
+This option is only supported on some ports, including arm, i386, powerpc,
+and SPARC@.
+
+@item --with-schedule=@var{cpu}
+@itemx --with-arch=@var{cpu}
+@itemx --with-tune=@var{cpu}
+These configure options provide default values for the @code{-mschedule=},
+@code{-march=}, and @code{-mtune=} options, respectively.  As with
+@code{--with-cpu} the legal values of @var{CPU} depend on the port; these
+options are not valid for all ports, only those which accept the respective
+options.
+
+@item --with-float=@var{type}
+Specify the default form of floating point.  The normal choices are ``hard''
+and ``soft''.  Which (if any) choices are recognized depends on the port;
+for instance, MIPS also recognizes ``single''.
 
 @item --enable-altivec
 Specify that the target supports AltiVec vector enhancements.  This
Index: doc/invoke.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.170
diff -u -3 -p -r1.170 invoke.texi
--- doc/invoke.texi	11 Aug 2002 09:47:47 -0000	1.170
+++ doc/invoke.texi	13 Aug 2002 19:43:13 -0000
@@ -4311,15 +4311,13 @@ one @option{-I} option, the directories 
 order; the standard system directories come after.
 
 If a standard system include directory, or a directory specified with
-@option{-isystem}, is also specified with @option{-I}, it will be
-searched only in the position requested by @option{-I}.  Also, it will
-not be considered a system include directory.  If that directory really
-does contain system headers, there is a good chance that they will
-break.  For instance, if GCC's installation procedure edited the headers
-in @file{/usr/include} to fix bugs, @samp{-I/usr/include} will cause the
-original, buggy headers to be found instead of the corrected ones.  GCC
-will issue a warning when a system include directory is hidden in this
-way.
+@option{-isystem}, is also specified with @option{-I}, the @option{-I}
+option will be ignored.  The directory will still be searched but as a
+system directory at its normal position in the system include chain.
+This is to ensure that GCC's procedure to fix buggy system headers and
+the ordering for the include_next directive are not inadvertantly changed.
+If you really need to change the search order for system directories,
+use the @option{-nostdinc} and/or @option{-isystem} options.
 
 @item -I-
 @opindex I-

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-13 13:27         ` PATCH: cpp include directory search order warning (mark 3) John David Anglin
@ 2002-08-14  7:37           ` Nathan Sidwell
  2002-08-20 11:48           ` Zack Weinberg
  1 sibling, 0 replies; 16+ messages in thread
From: Nathan Sidwell @ 2002-08-14  7:37 UTC (permalink / raw)
  To: John David Anglin; +Cc: nathan, zack, gcc-patches

John David Anglin wrote:

> I added a warning under -v and updated more of the documentation
> to describe the new treatment of -Idir when dir duplicates a system
> directory.  I have also implemented a suggestion from Nix regarding
> revising the search in remove_dup_nonsys_dirs.  This makes it more
> efficient, although it is less obvious now as to what value is being
> returned.
works for me, but Zack has the final say so.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-13 13:27         ` PATCH: cpp include directory search order warning (mark 3) John David Anglin
  2002-08-14  7:37           ` Nathan Sidwell
@ 2002-08-20 11:48           ` Zack Weinberg
  2002-08-20 12:35             ` Neil Booth
  1 sibling, 1 reply; 16+ messages in thread
From: Zack Weinberg @ 2002-08-20 11:48 UTC (permalink / raw)
  To: John David Anglin; +Cc: nathan, nathan, gcc-patches

On Tue, Aug 13, 2002 at 04:26:50PM -0400, John David Anglin wrote:
> 
> I added a warning under -v and updated more of the documentation
> to describe the new treatment of -Idir when dir duplicates a system
> directory.  I have also implemented a suggestion from Nix regarding
> revising the search in remove_dup_nonsys_dirs.  This makes it more
> efficient, although it is less obvious now as to what value is being
> returned.
> 
> Tested by inspection of cpp output with -v and a bootstrap-check
> under hppa-linux.
> 
> Ok for main?  

Please also mention this in the relevant changes.html(s) and address
the minor issues pointed out below, then apply this patch.

Thank you for working through this problem.

Should we consider this patch for 3.2.1?

zw

> +/* Remove duplicate non-system directories for which there is an equivalent
> +   system directory latter in the chain.  The range for removal is between
> +   *HEAD_PTR and END.  Returns the directory before END, or NULL if none.
> +   This algorithm is quadratic in the number system directories, which is
                                               ^ of
> +   acceptable since there aren't usually that many of them.  */


> +		  if (CPP_OPTION (pfile, verbose))
> +		    fprintf (stderr, _("  as it is a non-system directory that duplicates a system directory\n"));

Put the _("...") on its own line and outdent it as far as necessary to
avoid going past 79 columns.

> -left-to-right order, @emph{before} the default directories.  You can
> -also prevent GCC from searching any of the default directories with the
> -@option{-nostdinc} option.  This is useful when you are compiling an
> +left-to-right order, @emph{before} the default directories.  The only
> +exception is when @file{dir} is also a default system directory.  In

Change "is also a default system directory" to "is already searched by
default."

> +this case, the option is ignored and the default search order for system

Strike "default" from this line.

...
> +You can prevent GCC from searching any of the default directories with
> +the @option{-nostdinc} option.  This is useful when you are compiling an
>  operating system kernel or some other program that does not use the

  ... kernel, some other program ...

>  standard C library facilities, or the standard C library itself.

Add:

   @option{-I} options are not ignored as described above when
   @option{-nostdinc} is in effect.

>  All directories named by @option{-isystem} are searched @emph{after} all
>  directories named by @option{-I}, no matter what their order was on the
>  command line.  If the same directory is named by both @option{-I} and
> -@option{-isystem}, @option{-I} wins; it is as if the @option{-isystem} option
> -had never been specified at all. GCC warns you when this happens.
> +@option{-isystem}, the @option{-I} option is ignored.  GCC provides an
> +information message when this occurs if @option{-v} is used.

"Informational" or "informative" message, please (your choice)

zw

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-20 11:48           ` Zack Weinberg
@ 2002-08-20 12:35             ` Neil Booth
  2002-08-20 12:45               ` Phil Edwards
  2002-08-20 13:07               ` John David Anglin
  0 siblings, 2 replies; 16+ messages in thread
From: Neil Booth @ 2002-08-20 12:35 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: John David Anglin, nathan, nathan, gcc-patches

Zack Weinberg wrote:-

> Please also mention this in the relevant changes.html(s) and address
> the minor issues pointed out below, then apply this patch.
> 
> Thank you for working through this problem.
> 
> Should we consider this patch for 3.2.1?
> 
> zw

Excellent!  Does this patch everyone happy?  I'm quite pleased if
that's the case.

> > +@option{-isystem}, the @option{-I} option is ignored.  GCC provides an
> > +information message when this occurs if @option{-v} is used.
> 
> "Informational" or "informative" message, please (your choice)

I vote informative.

Neil.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-20 12:35             ` Neil Booth
@ 2002-08-20 12:45               ` Phil Edwards
  2002-08-20 13:07               ` John David Anglin
  1 sibling, 0 replies; 16+ messages in thread
From: Phil Edwards @ 2002-08-20 12:45 UTC (permalink / raw)
  To: Neil Booth; +Cc: Zack Weinberg, John David Anglin, nathan, nathan, gcc-patches

On Tue, Aug 20, 2002 at 08:33:32PM +0100, Neil Booth wrote:
> 
> Excellent!  Does this patch everyone happy?

It patches me happy.


Phil

-- 
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
                                                 - Edsger Dijkstra, 1930-2002

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: PATCH: cpp include directory search order warning (mark 3)
  2002-08-20 12:35             ` Neil Booth
  2002-08-20 12:45               ` Phil Edwards
@ 2002-08-20 13:07               ` John David Anglin
  1 sibling, 0 replies; 16+ messages in thread
From: John David Anglin @ 2002-08-20 13:07 UTC (permalink / raw)
  To: Neil Booth; +Cc: zack, nathan, nathan, gcc-patches

> I vote informative.

Installed!  I suggest waiting a few days to see if the change causes
any problems before considering the branch.  I will work up something
for the relevant changes.html(s).

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2002-08-20 20:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-07  9:48 PATCH: cpp include directory search order warning John David Anglin
2002-08-07 11:52 ` Zack Weinberg
2002-08-07 12:27   ` Nathan Sidwell
2002-08-07 13:17     ` John David Anglin
2002-08-09 14:56     ` PATCH: cpp include directory search order warning (mark 2) John David Anglin
2002-08-12  2:42       ` Nathan Sidwell
2002-08-13 13:27         ` PATCH: cpp include directory search order warning (mark 3) John David Anglin
2002-08-14  7:37           ` Nathan Sidwell
2002-08-20 11:48           ` Zack Weinberg
2002-08-20 12:35             ` Neil Booth
2002-08-20 12:45               ` Phil Edwards
2002-08-20 13:07               ` John David Anglin
2002-08-07 13:06   ` PATCH: cpp include directory search order warning John David Anglin
2002-08-07 13:28     ` Neil Booth
2002-08-07 13:43       ` John David Anglin
2002-08-07 14:48       ` John David Anglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).