This is the mail archive of the 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]
Other format: [Raw text]

Re: plugins & PCH are incompatible ...

Joseph S. Myers wrote:
On Tue, 28 Apr 2009, Basile STARYNKEVITCH wrote:

2009-04-28 Basile Starynkevitch <>
* plugin.c: Added include of "c-common.h" for pch_file.

In general including a front-end header from non-front-end code indicates a bug somewhere. (Yes, various existing files include c-common.h / c-tree.h / c-pragma.h that shouldn't.)
A big thanks for the insight. I would even dare suggesting documenting the above rule somewhere (unless it is already documented).
In this case, what would happen when building the compiler for a non-C language where the variable whose declaration you are using does not exist at all
This suggests to test the plugins in c-pch.c. Hence the attached patch (bootstrapped on x86_64-linux-gnu with C enabled).


2009-04-28 Basile Starynkevitch <>

       * c-pch.c: Added include "plugin.h".
   (pch_init) Issue an error when generating a PCH file with plugins.

Ok for trunk?


Index: gcc/c-pch.c
--- gcc/c-pch.c	(revision 146891)
+++ gcc/c-pch.c	(working copy)
@@ -1,6 +1,8 @@
 /* Precompiled header implementation for the C languages.
-   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free
+   Software Foundation, Inc.
 This file is part of GCC.
 GCC is free software; you can redistribute it and/or modify
@@ -34,6 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "hosthooks.h"
 #include "target.h"
 #include "opts.h"
+#include "plugin.h"
 /* This is a list of flag variables that must match exactly, and their
    names for the error message.  The possible values for *flag_var must
@@ -126,9 +129,21 @@ pch_init (void)
   if (!pch_file)
+  /* plugins are incompatible with precompiled headers generation,
+     because at PCH reload time the plugins might not be available or
+     similar enough. */
+  if (plugins_active_p ())
+    {
+      error ("Plugins are incompatible with precompiled headers generation.");
+      return;
+    }
   f = fopen (pch_file, "w+b");
   if (f == NULL)
     fatal_error ("can%'t create precompiled header %s: %m", pch_file);
   pch_outfile = f;
   gcc_assert (memcmp (executable_checksum, no_checksum, 16) != 0);

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