This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: trunk patch: documenting how to build plugins.
On Wed, Jun 17, 2009 at 09:04, Basile
STARYNKEVITCH<basile@starynkevitch.net> wrote:
> The last sentence explains that some plugin could indeed need the source or
> build tree. This could happen because of gengtype, or because the plugin
> might want to use some feature or function of GCC which is not declared
> inside the plugin/include directory. IIRC the plugin dogma (which I agree
> with) is : there is no stable GCC internal API!
Sure, but the header files should be in plugin/include just the
same. The only time a build tree is needed should be for
gengtype usage.
> +If plugins are enabled, GCC installs the headers needed to build a
> +plugin (somehwere in the installation tree, e.g. under
> +@code{/usr/local}).
s/@code/@file/
> In particular a @code{plugin} directory has been
> +installed, and it contains a @code{plugin/include} sub-directory with
> +all the header files useful for building plugins.
Rephrase as 'In particular, a @file{plugin/include} directory is
installed, containing all the header files needed to build
plugins.'
> +
> +On most systems, you can query this @code{plugin} directory by
> +invoking @code{@var{gcc} -print-file-name=plugin} (replace if needed
s/@code/@command/
s/@var//
> +@var{gcc} with the appropriate program path).
s/@var/@command/
> +
> +The following GNU Makefile except shows how to build a simple plugin:
s/except/excerpt/
> +@smallexample
> +GCC=gcc
> +PLUGIN_SOURCE_FILES= plugin1.c plugin2.c
> +PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
> +GCCPLUGINS_DIR:= $(shell $(GCC) -print-file-name=plugin)
> +CFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -O2
> +
> +plugin.so: $(PLUGIN_OBJECT_FILES)
> + $(GCC) -shared $^ -o $@
> +@end smallexample
> +
> +A single source file plugin could even be built with @code{gcc -I`gcc
s/could even be/may be/
s/@code/@command/
> +-print-file-name=plugin`/include -fPIC -shared -O2 plugin.c -o
> +plugin.so}, using backquote shell syntax to query the @code{plugin}
s/@code/@file/
> +Some complex plugins (e.g. those needing @code{gengtype} or using GCC
> +stuff outside of @code{plugin/ionclude}) could require both source and
> +build directories of GCC.
No. The only plugins that need src/bld trees are those using
gengtype. Rephrase as "Plugins needing to use @command{gengtype}
require a GCC build directory for the same version of GCC that
they will be linked against."
OK with those changes.
Diego.