diff mbox

[PLUGIN] compile and install gengtype, install gtype.state

Message ID CAF+LTecS4Kn4spf+apk5DUG2UtyGbzqiT19=--0_DX8xedViWA@mail.gmail.com
State New
Headers show

Commit Message

Romain Geissler July 18, 2011, 2:29 p.m. UTC
Hi,

This patch allows a third party plugin to define new GTY-ed types
by compiling and installing gengtype for host and installing gtype.state
in plugin_includedir.

Builds and installs fine on a x86_64 red hat.

Ok for the trunk ?

Romain Geissler

gcc/

2011-07-18  Romain Geissler  <romain.geissler@gmail.com>

	* gengtype-state.c (#include "bconfig.h"): #include "config.h"
	with host CC
	* gengtype.c: Likewise
	* gengtype-lex.l: Likewise
	* gengtype-parse.c: Likewise

	* Makefile.in (gengtype): compile and install for host when
	enable_plugins
	(gtype.state): install when enable_plugins



build/gen%.o $(BUILD_LIBDEPS)
@@ -4641,8 +4664,15 @@ s-header-vars: Makefile
 	$(SHELL) $(srcdir)/../move-if-change tmp-header-vars b-header-vars
 	$(STAMP) s-header-vars

+# Install gengtype
+install-gengtype: installdirs gengtype$(exeext) gtype.state
+	$(mkinstalldirs) $(DESTDIR)$(plugindir)
+	$(INSTALL_DATA) gtype.state $(DESTDIR)$(plugindir)/gtype.state
+	$(mkinstalldirs) $(DESTDIR)$(plugin_bindir)
+	$(INSTALL_PROGRAM) gengtype$(exeext)
$(DESTDIR)$(plugin_bindir)/gengtype$(exeext)
+
 # Install the headers needed to build a plugin.
-install-plugin: installdirs lang.install-plugin s-header-vars
+install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
 # We keep the directory structure for files in config and .def files. All
 # other files are flattened to a single directory.
 	$(mkinstalldirs) $(DESTDIR)$(plugin_includedir)

Comments

Basile Starynkevitch July 18, 2011, 2:38 p.m. UTC | #1
On Mon, Jul 18, 2011 at 04:29:29PM +0200, Romain Geissler wrote:
> Hi,
> 
> This patch allows a third party plugin to define new GTY-ed types
> by compiling and installing gengtype for host and installing gtype.state
> in plugin_includedir.
> 
> Builds and installs fine on a x86_64 red hat.


I am not authorized to approve that patch, but I really hope it will be approved.

(I am guilty of not having gengtype being installed)

Cheers.
Laurynas Biveinis July 19, 2011, 12:09 p.m. UTC | #2
2011/7/18 Romain Geissler <romain.geissler@gmail.com>:
>        * gengtype-state.c (#include "bconfig.h"): #include "config.h"
>        with host CC

include "bconfig.h" if GENERATOR_FILE is defined, "config.h" otherwise.

>        * gengtype.c: Likewise
>        * gengtype-lex.l: Likewise
>        * gengtype-parse.c: Likewise


"Likewise.", full stops.

>        * Makefile.in (gengtype): compile and install for host when
>        enable_plugins

"compile and install for host when $enable_plugin is set.", also full stop.

>        (gtype.state): install when enable_plugins

Similar to above, and full stop.

The non-Makefile changes are OK.

Thank you,
Romain Geissler July 19, 2011, 12:26 p.m. UTC | #3
2011/7/19 Laurynas Biveinis <laurynas.biveinis@gmail.com>:
> 2011/7/18 Romain Geissler <romain.geissler@gmail.com>:
>>        * gengtype-state.c (#include "bconfig.h"): #include "config.h"
>>        with host CC
>
> include "bconfig.h" if GENERATOR_FILE is defined, "config.h" otherwise.
>
>>        * gengtype.c: Likewise
>>        * gengtype-lex.l: Likewise
>>        * gengtype-parse.c: Likewise
>
>
> "Likewise.", full stops.
>
>>        * Makefile.in (gengtype): compile and install for host when
>>        enable_plugins
>
> "compile and install for host when $enable_plugin is set.", also full stop.
>
>>        (gtype.state): install when enable_plugins
>
> Similar to above, and full stop.
>
> The non-Makefile changes are OK.
>
> Thank you,
> --
> Laurynas

Thank you for correcting me, i'm still not very comfortable with ChangeLogs.

Here is the new Changelog:

2011-07-18  Romain Geissler  <romain.geissler@gmail.com>

	* gengtype-state.c (#include "bconfig.h"): include "bconfig.h"
	if GENERATOR_FILE is defined, "config.h" otherwise.
	* gengtype.c: Likewise.
	* gengtype-lex.l: Likewise.
	* gengtype-parse.c: Likewise.
	* Makefile.in (gengtype): compile and install for host when
	$enable_plugins is set to "yes".
	(gtype.state): install when $enable_plugins is set to "yes".


Romain Geissler
Jakub Jelinek July 19, 2011, 12:30 p.m. UTC | #4
On Tue, Jul 19, 2011 at 02:26:32PM +0200, Romain Geissler wrote:
> 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
> 
> 	* gengtype-state.c (#include "bconfig.h"): include "bconfig.h"
> 	if GENERATOR_FILE is defined, "config.h" otherwise.
> 	* gengtype.c: Likewise.
> 	* gengtype-lex.l: Likewise.
> 	* gengtype-parse.c: Likewise.
> 	* Makefile.in (gengtype): compile and install for host when
> 	$enable_plugins is set to "yes".
> 	(gtype.state): install when $enable_plugins is set to "yes".

s/: include/: Include/;s/: compile/: Compile/;s/: install/: Install/

	Jakub
Romain Geissler July 19, 2011, 12:41 p.m. UTC | #5
2011/7/19 Jakub Jelinek <jakub@redhat.com>:
> On Tue, Jul 19, 2011 at 02:26:32PM +0200, Romain Geissler wrote:
>> 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
>>
>>       * gengtype-state.c (#include "bconfig.h"): include "bconfig.h"
>>       if GENERATOR_FILE is defined, "config.h" otherwise.
>>       * gengtype.c: Likewise.
>>       * gengtype-lex.l: Likewise.
>>       * gengtype-parse.c: Likewise.
>>       * Makefile.in (gengtype): compile and install for host when
>>       $enable_plugins is set to "yes".
>>       (gtype.state): install when $enable_plugins is set to "yes".
>
> s/: include/: Include/;s/: compile/: Compile/;s/: install/: Install/
>
>        Jakub
>

Fixed

Romain Geissler

2011-07-18  Romain Geissler  <romain.geissler@gmail.com>

	* gengtype-state.c (#include "bconfig.h"): Include "bconfig.h"
	if GENERATOR_FILE is defined, "config.h" otherwise.
	* gengtype.c: Likewise.
	* gengtype-lex.l: Likewise.
	* gengtype-parse.c: Likewise.
	* Makefile.in (gengtype): Compile and install for host when
	$enable_plugins is set to "yes".
	(gtype.state): Install when $enable_plugins is set to "yes".
Romain Geissler July 25, 2011, 7:10 p.m. UTC | #6
Le 19 juil. 2011 à 14:41, Romain Geissler a écrit :

> 2011/7/19 Jakub Jelinek <jakub@redhat.com>:
>> On Tue, Jul 19, 2011 at 02:26:32PM +0200, Romain Geissler wrote:
>>> 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
>>> 
>>>       * gengtype-state.c (#include "bconfig.h"): include "bconfig.h"
>>>       if GENERATOR_FILE is defined, "config.h" otherwise.
>>>       * gengtype.c: Likewise.
>>>       * gengtype-lex.l: Likewise.
>>>       * gengtype-parse.c: Likewise.
>>>       * Makefile.in (gengtype): compile and install for host when
>>>       $enable_plugins is set to "yes".
>>>       (gtype.state): install when $enable_plugins is set to "yes".
>> 
>> s/: include/: Include/;s/: compile/: Compile/;s/: install/: Install/
>> 
>>        Jakub
>> 
> 
> Fixed
> 
> Romain Geissler
> 
> 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
> 
> 	* gengtype-state.c (#include "bconfig.h"): Include "bconfig.h"
> 	if GENERATOR_FILE is defined, "config.h" otherwise.
> 	* gengtype.c: Likewise.
> 	* gengtype-lex.l: Likewise.
> 	* gengtype-parse.c: Likewise.
> 	* Makefile.in (gengtype): Compile and install for host when
> 	$enable_plugins is set to "yes".
> 	(gtype.state): Install when $enable_plugins is set to "yes".


Ping !
Jakub Jelinek July 25, 2011, 7:27 p.m. UTC | #7
On Mon, Jul 25, 2011 at 09:10:55PM +0200, Romain Geissler wrote:
> > 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
> > 
> > 	* gengtype-state.c (#include "bconfig.h"): Include "bconfig.h"
> > 	if GENERATOR_FILE is defined, "config.h" otherwise.

Still not right, this should have been
	* gengtype-state.c: Include "bconfig.h" if GENERATOR_FILE is
	define, "config.h" otherwise.

> > 	* gengtype.c: Likewise.
> > 	* gengtype-lex.l: Likewise.
> > 	* gengtype-parse.c: Likewise.

> > 	* Makefile.in (gengtype): Compile and install for host when
> > 	$enable_plugins is set to "yes".
> > 	(gtype.state): Install when $enable_plugins is set to "yes".

And this should list all the Makefile.in goals you've changed, added etc.

Ok with those changes.

	Jakub
diff mbox

Patch

Index: gcc/gengtype-state.c
===================================================================
--- gcc/gengtype-state.c	(revision 175907)
+++ gcc/gengtype-state.c	(working copy)
@@ -23,7 +23,11 @@ 
    and Basile Starynkevitch <basile@starynkevitch.net>
 */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "errors.h"	/* For fatal.  */
 #include "double-int.h"
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 175907)
+++ gcc/gengtype.c	(working copy)
@@ -18,7 +18,11 @@ 
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "errors.h"		/* for fatal */
 #include "getopt.h"
Index: gcc/gengtype-lex.l
===================================================================
--- gcc/gengtype-lex.l	(revision 175907)
+++ gcc/gengtype-lex.l	(working copy)
@@ -22,7 +22,11 @@  along with GCC; see the file COPYING3.
 %option noinput

 %{
+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"

 #define malloc xmalloc
Index: gcc/gengtype-parse.c
===================================================================
--- gcc/gengtype-parse.c	(revision 175907)
+++ gcc/gengtype-parse.c	(working copy)
@@ -17,7 +17,11 @@ 
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "gengtype.h"

Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 175907)
+++ gcc/Makefile.in	(working copy)
@@ -192,6 +192,7 @@  GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D
 # be subject to -Werror:
 # flex output may yield harmless "no previous prototype" warnings
 build/gengtype-lex.o-warn = -Wno-error
+gengtype-lex.o-warn = -Wno-error
 # mips-tfile.c contains -Wcast-qual warnings.
 mips-tfile.o-warn = -Wno-error
 expmed.o-warn = -Wno-error
@@ -566,8 +567,12 @@  libexecdir = @libexecdir@
 libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)
 # Directory in which the compiler finds executables
 libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version)
-# Directory in which plugin headers are installed
-plugin_includedir = $(libsubdir)/plugin/include
+# Directory in which all plugin resources are installed
+plugindir = $(libsubdir)/plugin
+ # Directory in which plugin headers are installed
+plugin_includedir = $(plugindir)/include
+# Directory in which plugin specific executables are installed
+plugin_bindir = $(plugindir)/bin
 # Used to produce a relative $(gcc_tooldir) in gcc.o
 unlibsubdir = ../../..
 # $(prefix), expressed as a path relative to $(libsubdir).
@@ -1532,8 +1537,8 @@  MOSTLYCLEANFILES = insn-flags.h insn-con
  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
  $(SPECS) collect2$(exeext) lto-wrapper$(exeext) \
  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
- *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a libcommon-target.a \
- libcommon.a libgcc.mk
+ gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
+ libcommon-target.a libcommon.a libgcc.mk

 # Defined in libgcc2.c, included only in the static library.
 LIB2FUNCS_ST = _eprintf __gcc_bcmp
@@ -1825,6 +1830,10 @@  rest.encap: lang.rest.encap
 native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
 	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext)

+ifeq ($(enable_plugin),yes)
+native: gengtype$(exeext)
+endif
+
 # Define the names for selecting languages in LANGUAGES.
 c: cc1$(exeext)

@@ -3879,7 +3888,7 @@  ALL_GTFILES_H := $(sort $(GTFILES_H) $(G
 # write it out to a file (taking care not to do that in a way that
 # overflows a command line!) and then have gengtype read the file in.

-$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h : s-gtype ; @true
+$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gtype.state: s-gtype ; @true

 ### Common flags to gengtype [e.g. -v or -B backupdir]
 GENGTYPE_FLAGS=
@@ -3894,9 +3903,10 @@  s-gtype: build/gengtype$(build_exeext) $
 	 gtyp-input.list
 # First, parse all files and save a state file.
 	$(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
-                    -S $(srcdir) -I gtyp-input.list -w gtype.state
+                    -S $(srcdir) -I gtyp-input.list -w tmp-gtype.state
 # Second, read the state file and generate all files.  This ensure that
 # gtype.state is correctly read:
+	$(SHELL) $(srcdir)/../move-if-change tmp-gtype.state gtype.state
 	$(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
                     -r gtype.state
 	$(STAMP) s-gtype
@@ -3993,14 +4003,23 @@  build/genextract.o : genextract.c $(RTL_
 build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)	\
   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
-build/gengtype-lex.o : gengtype-lex.c gengtype.h $(BCONFIG_H) $(SYSTEM_H)
-build/gengtype-parse.o : gengtype-parse.c gengtype.h $(BCONFIG_H)	\
+gengtype-lex.o build/gengtype-lex.o : gengtype-lex.c gengtype.h $(SYSTEM_H)
+gengtype-lex.o: $(CONFIG_H)
+build/gengtype-lex.o: $(BCONFIG_H)
+gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
   $(SYSTEM_H)
-build/gengtype-state.o: gengtype-state.c gengtype.h $(BCONFIG_H)	\
-  $(SYSTEM_H) errors.h
-build/gengtype.o : gengtype.c $(BCONFIG_H) $(SYSTEM_H) gengtype.h 	\
-  rtl.def insn-notes.def errors.h double-int.h $(HASHTAB_H)             \
+gengtype-parse.o: $(CONFIG_H)
+build/gengtype-parse.o: $(BCONFIG_H)
+gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
+  gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
+  $(XREGEX_H)
+gengtype-state.o: $(CONFIG_H)
+build/gengtype-state.o: $(BCONFIG_H)
+gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h 	\
+  rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
   $(OBSTACK_H) $(XREGEX_H)
+gengtype.o: $(CONFIG_H)
+build/gengtype.o: $(BCONFIG_H)
 build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
   errors.h $(READ_MD_H)
 build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h		\
@@ -4044,7 +4063,11 @@  build/genautomata$(build_exeext) : BUILD

 # These programs are not linked with the MD reader.
 build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
-              build/gengtype-state.o build/version.o
+              build/gengtype-state.o build/version.o build/errors.o
+
+gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
+              gengtype-state.o version.o errors.o $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) -o $@ $(filter-out ($LIBDEPS), $^) $(LIBS)

 # Rule for the generator programs:
 $(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext):