This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Don't output pch info for plugins
- From: Rafael Espindola <espindola at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at google dot com>, Basile STARYNKEVITCH <basile at starynkevitch dot net>, Duncan Sands <baldrick at free dot fr>
- Date: Thu, 24 Sep 2009 12:07:51 -0400
- Subject: [patch] Don't output pch info for plugins
Plugins don't work with precompiled headers. This patch avoids printing
pch info in plugin mode.
2009-09-24 Basile Starynkevitch <basile@starynkevitch.net>
Rafael Avila de Espindola <espindola@google.com>
* gengtype.c (write_root, write_roots): Add a emit_pch argument.
Don't print pch related info if it is false.
(main): Don't print pch info in plugin mode.
Cheers,
--
Rafael Ãvila de EspÃndola
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index f93e427..f34324d 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -1907,10 +1907,10 @@ static void finish_root_table (struct flist *flp, const char *pfx,
const char *tname, const char *lastname,
const char *name);
static void write_root (outf_p , pair_p, type_p, const char *, int,
- struct fileloc *, const char *);
+ struct fileloc *, const char *, bool);
static void write_array (outf_p f, pair_p v,
const struct write_types_data *wtd);
-static void write_roots (pair_p);
+static void write_roots (pair_p, bool);
/* Parameters for walk_type. */
@@ -3131,7 +3131,7 @@ finish_root_table (struct flist *flp, const char *pfx, const char *lastname,
static void
write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
- struct fileloc *line, const char *if_marked)
+ struct fileloc *line, const char *if_marked, bool emit_pch)
{
switch (type->kind)
{
@@ -3187,7 +3187,7 @@ write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
newname = xasprintf ("%s.%s.%s",
name, fld->name, validf->name);
write_root (f, v, validf->type, newname, 0, line,
- if_marked);
+ if_marked, emit_pch);
free (newname);
}
}
@@ -3199,7 +3199,8 @@ write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
{
char *newname;
newname = xasprintf ("%s.%s", name, fld->name);
- write_root (f, v, fld->type, newname, 0, line, if_marked);
+ write_root (f, v, fld->type, newname, 0, line, if_marked,
+ emit_pch);
free (newname);
}
}
@@ -3210,7 +3211,8 @@ write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
{
char *newname;
newname = xasprintf ("%s[0]", name);
- write_root (f, v, type->u.a.p, newname, has_length, line, if_marked);
+ write_root (f, v, type->u.a.p, newname, has_length, line, if_marked,
+ emit_pch);
free (newname);
}
break;
@@ -3239,20 +3241,31 @@ write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
if (! has_length && UNION_OR_STRUCT_P (tp))
{
oprintf (f, " >_ggc_mx_%s,\n", tp->u.s.tag);
- oprintf (f, " >_pch_nx_%s", tp->u.s.tag);
+ if (emit_pch)
+ oprintf (f, " >_pch_nx_%s", tp->u.s.tag);
+ else
+ oprintf (f, " NULL");
}
else if (! has_length && tp->kind == TYPE_PARAM_STRUCT)
{
oprintf (f, " >_ggc_m_");
output_mangled_typename (f, tp);
- oprintf (f, ",\n >_pch_n_");
- output_mangled_typename (f, tp);
+ if (emit_pch)
+ {
+ oprintf (f, ",\n >_pch_n_");
+ output_mangled_typename (f, tp);
+ }
+ else
+ oprintf (f, ",\n NULL");
}
else if (has_length
&& (tp->kind == TYPE_POINTER || UNION_OR_STRUCT_P (tp)))
{
oprintf (f, " >_ggc_ma_%s,\n", name);
- oprintf (f, " >_pch_na_%s", name);
+ if (emit_pch)
+ oprintf (f, " >_pch_na_%s", name);
+ else
+ oprintf (f, " NULL");
}
else
{
@@ -3341,7 +3354,7 @@ write_array (outf_p f, pair_p v, const struct write_types_data *wtd)
/* Output a table describing the locations and types of VARIABLES. */
static void
-write_roots (pair_p variables)
+write_roots (pair_p variables, bool emit_pch)
{
pair_p v;
struct flist *flp = NULL;
@@ -3429,7 +3442,7 @@ write_roots (pair_p variables)
oprintf (f, "[] = {\n");
}
- write_root (f, v, v->type, v->name, length_p, &v->line, NULL);
+ write_root (f, v, v->type, v->name, length_p, &v->line, NULL, emit_pch);
}
finish_root_table (flp, "ggc_r", "LAST_GGC_ROOT_TAB", "ggc_root_tab",
@@ -3508,12 +3521,15 @@ write_roots (pair_p variables)
}
write_root (f, v, v->type->u.p->u.param_struct.param[0],
- v->name, length_p, &v->line, if_marked);
+ v->name, length_p, &v->line, if_marked, emit_pch);
}
finish_root_table (flp, "ggc_rc", "LAST_GGC_CACHE_TAB", "ggc_cache_tab",
"gt_ggc_cache_rtab");
+ if (!emit_pch)
+ return;
+
for (v = variables; v; v = v->next)
{
outf_p f = get_output_file_with_visibility (v->line.file);
@@ -3543,7 +3559,7 @@ write_roots (pair_p variables)
oprintf (f, "[] = {\n");
}
- write_root (f, v, v->type, v->name, length_p, &v->line, NULL);
+ write_root (f, v, v->type, v->name, length_p, &v->line, NULL, emit_pch);
}
finish_root_table (flp, "pch_rc", "LAST_GGC_ROOT_TAB", "ggc_root_tab",
@@ -3720,9 +3736,12 @@ main (int argc, char **argv)
write_enum_defn (structures, param_structs);
output_header = plugin_output ? plugin_output : header_file;
write_types (output_header, structures, param_structs, &ggc_wtd);
- write_types (output_header, structures, param_structs, &pch_wtd);
- write_local (output_header, structures, param_structs);
- write_roots (variables);
+ if (plugin_output == NULL)
+ {
+ write_types (output_header, structures, param_structs, &pch_wtd);
+ write_local (output_header, structures, param_structs);
+ }
+ write_roots (variables, plugin_output == NULL);
write_rtx_next ();
close_output_files ();