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]
Other format: [Raw text]

Re: [patch] in pluign mode, send gengtype output to a user specified file


Diego Novillo wrote:
On Thu, Sep 24, 2009 at 10:17, Rafael Espindola <espindola@google.com> wrote:
This patch changes gengtype to output all plugin information to a single file
specified in the command line.

2009-09-24  Basile Starynkevitch  <basile@starynkevitch.net>
           Rafael Avila de Espindola  <espindola@google.com>

       * gengtype.c (plugin_output): New.
       (get_output_file_with_visibility): Return plugin_output for plugins.
       (main): Parse and use the -P option.
       * gty.texi: Update the command line format.

Looks fine. I don't think '-p' should be renamed to '-P', though. Basile, what's the point of that?

Well long time ago, since the original -p behavior did not work well, I thought that giving explicitly the generated file name is better, and I thought that since the command syntax changed (by adding that file name) it was better to change the letter. I otherwise dont care on -p vs -P provided we do explicitly give the generated file name.


Perhaps gengtype should be installed as gcc-gengtype somewhere and obey the usual GNU conventions (including --help & --version).

However, I was not able to cleanly apply the patch in http://gcc.gnu.org/ml/gcc-patches/2009-09/msg01717.html. I had to manually correct it. And when applying the attached *nonworking* patch to gcc trunk rev 152279 I am getting
ranlib libbackend.a
gcc -g -fkeep-inline-functions -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common -DHAVE_CONFIG_H -o cc1-dummy c-lang.o stub-objc.o attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o c-ppoutput.o c-cppbuiltin.o c-objc-common.o c-dump.o c-pch.o c-parser.o i386-c.o c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o \
dummy-checksum.o main.o tree-browser.o libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcpp/libcpp.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -L/usr/lib -lcloog -L/usr/lib -lppl_c -lppl -lgmpxx -lmpc -lmpfr -lgmp -rdynamic -ldl
/usr/bin/ld: libbackend.a(ggc-common.o): in function gt_pch_save:/usr/src/Lang/gcc-trunk-bstarynk/gcc/ggc-common.c:511: error: undefined reference to 'gt_pch_cache_rtab'
/usr/bin/ld: libbackend.a(ggc-common.o): in function gt_pch_save:/usr/src/Lang/gcc-trunk-bstarynk/gcc/ggc-common.c:539: error: undefined reference to 'gt_pch_scalar_rtab'
/usr/bin/ld: libbackend.a(ggc-common.o): in function gt_pch_save:/usr/src/Lang/gcc-trunk-bstarynk/gcc/ggc-common.c:546: error: undefined reference to 'gt_pch_cache_rtab'
/usr/bin/ld: libbackend.a(ggc-common.o): in function gt_pch_restore:/usr/src/Lang/gcc-trunk-bstarynk/gcc/ggc-common.c:616: error: undefined reference to 'gt_pch_scalar_rtab'
/usr/bin/ld: libbackend.a(ggc-common.o): in function gt_pch_restore:/usr/src/Lang/gcc-trunk-bstarynk/gcc/ggc-common.c:629: error: undefined reference to 'gt_pch_cache_rtab'
collect2: ld returned 1 exit status
make[3]: *** [cc1-dummy] Error 1
rm gfdl.pod cpp.pod gcc.pod gcov.pod fsf-funding.pod
make[3]: Leaving directory `/usr/src/Lang/_Boot_Gcctrunk/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/usr/src/Lang/_Boot_Gcctrunk'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/src/Lang/_Boot_Gcctrunk'
make: *** [all] Error 2



So obviously I did something wrong.



If Rafael managed to patch the trunk to have something working (if possible try the test case on gengtype provided by MELT & explained in http://gcc.gnu.org/ml/gcc-patches/2009-09/msg02057.html) I would be grateful and delighted to get the patch relative to trunk.


I don't understand what is happenning. Very probably I patched wrongly the trunk. Sorry about that, but I don't understand what did I miss.

Regards.
--
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 152279)
+++ gcc/gengtype.c	(working copy)
@@ -145,6 +145,8 @@ static outf_p output_files;
    directory.  */
 static char** plugin_files;
 static size_t nb_plugin_files;
+/* the generated plugin output name & file */
+static outf_p plugin_output;
 
 /* The output header file that is included into pretty much every
    source file.  */
@@ -1714,15 +1716,14 @@ get_output_file_with_visibility (const char *input
 
   /* In plugin mode, return NULL unless the input_file is one of the
      plugin_files.  */
-  if (plugin_files && nb_plugin_files > 0) 
-    { 
-      int ix= -1;
+  if (plugin_files)
+    {
       size_t i;
-      for (i = 0; i < nb_plugin_files && ix < 0; i++)
-      if (strcmp (input_file, plugin_files[i]) == 0) 
-	ix = i;
-      if (ix < 0) 
-	return NULL;
+      for (i = 0; i < nb_plugin_files; i++)
+	if (strcmp (input_file, plugin_files[i]) == 0)
+	  return plugin_output;
+
+      return NULL;
     }
 
   /* Determine the output file name.  */
@@ -3667,20 +3668,24 @@ main (int argc, char **argv)
   size_t i;
   static struct fileloc pos = { this_file, 0 };
   char* inputlist = 0;
+  outf_p output_header;
+  char* plugin_output_filename = NULL;
   /* fatal uses this */
   progname = "gengtype";
 
-  if (argc >= 5 && !strcmp (argv[1], "-p")) 
+  if (argc >= 6 && !strcmp (argv[1], "-P"))
     {
-      srcdir = argv[2];
-      inputlist = argv[3];
-      nb_plugin_files = argc-4;
+      plugin_output_filename = argv[2];
+      plugin_output = create_file ("GCC", plugin_output_filename);
+      srcdir = argv[3];
+      inputlist = argv[4];
+      nb_plugin_files = argc - 5;
       plugin_files = XCNEWVEC (char *, nb_plugin_files);
       for (i = 0; i < nb_plugin_files; i++)
       {
         /* Place an all zero lang_bitmap before the plugin file
 	   name.  */
-        char *name = argv[i + 4];
+        char *name = argv[i + 5];
         int len = strlen(name) + 1 + sizeof (lang_bitmap);
         plugin_files[i] = XCNEWVEC (char, len) + sizeof (lang_bitmap);
         strcpy (plugin_files[i], name);
@@ -3692,7 +3697,8 @@ main (int argc, char **argv)
       inputlist = argv[2];
     } 
   else
-    fatal ("usage: gengtype [-p] srcdir input-list [file1 file2 ... fileN]");
+    fatal ("usage: gengtype [-P pluginout.h] srcdir input-list "
+           "[file1 file2 ... fileN]");
 
   srcdir_len = strlen (srcdir);
 
@@ -3728,13 +3734,11 @@ main (int argc, char **argv)
 
   open_base_files ();
   write_enum_defn (structures, param_structs);
-  write_types (header_file, structures, param_structs, &ggc_wtd);
-  if (plugin_files == NULL)
-    {
-      write_types (header_file, structures, param_structs, &pch_wtd);
-      write_local (header_file, structures, param_structs);
-    }
-  write_roots (variables, plugin_files == NULL);
+  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, plugin_output != NULL);
   write_rtx_next ();
   close_output_files ();
 

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