diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 33 | ||||
-rw-r--r-- | gcc/Makefile.in | 4 | ||||
-rw-r--r-- | gcc/common.opt | 4 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 11 | ||||
-rw-r--r-- | gcc/doc/plugins.texi | 8 | ||||
-rw-r--r-- | gcc/gcc-plugin.h | 6 | ||||
-rw-r--r-- | gcc/gcc.c | 20 | ||||
-rw-r--r-- | gcc/plugin.c | 48 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugindir1.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugindir2.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugindir3.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/plugindir4.c | 4 |
13 files changed, 149 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c2a25d7afd..3e197ab5ecd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,36 @@ +2010-04-13 Matthias Klose <doko@ubuntu.com> + + * gcc.c (cc1_options): Handle -iplugindir before processing + the cc1 spec. Only add -iplugindir once. + (cpp_unique_options): Add -iplugindir option if -fplugin* options + found. + * common.opt (iplugindir): Remove `Separate' property, initialize. + * plugin.c (default_plugin_dir_name): Error with missing -iplugindir + option. + * Makefile.in (check-%, check-parallel-%): Create plugin dir. + (distclean): Remove plugin dir. + * doc/invoke.texi: Document -iplugindir. + +2010-04-13 Basile Starynkevitch <basile@starynkevitch.net> + + * doc/plugins.texi (Loading Plugins): Document short + -fplugin=foo option. + (Plugin API): Mention default_plugin_dir_name function. + + * gcc.c (find_file_spec_function): Add new declaration. + (static_spec_func): Use it for "find-file". + (find_file_spec_function): Add new function. + (cc1_options): Add -iplugindir option if -fplugin* options found. + + * gcc-plugin.h (default_plugin_dir_name): Added new declaration. + + * plugin.c (add_new_plugin): Updated comment, and handle short + plugin name. + (default_plugin_dir_name): Added new function. + + * common.opt (iplugindir): New option to set the plugin + directory. + 2010-04-12 Uros Bizjak <ubizjak@gmail.com> * config/i386/i386.md (any_rotate): New code iterator. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index c1cec397253..3fada585d95 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -4233,7 +4233,7 @@ distclean: clean lang.distclean -rm -f gcov.pod # Delete po/*.gmo only if we are not building in the source directory. -if [ ! -f po/exgettext ]; then rm -f po/*.gmo; fi - -rmdir ada cp f java objc intl po testsuite 2>/dev/null + -rmdir ada cp f java objc intl po testsuite plugin 2>/dev/null # Get rid of every file that's generated from some other file, except for `configure'. # Most of these files ARE PRESENT in the GCC distribution. @@ -4690,6 +4690,7 @@ $(TESTSUITEDIR)/site.exp: site.exp # This is only used for check-% targets that aren't parallelized. $(filter-out $(lang_checks_parallelized),$(lang_checks)): check-% : site.exp + -test -d plugin || mkdir plugin -test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR) test -d $(TESTSUITEDIR)/$* || mkdir $(TESTSUITEDIR)/$* -(rootme=`${PWD_COMMAND}`; export rootme; \ @@ -4777,6 +4778,7 @@ $(patsubst %,%-subtargets,$(lang_checks_parallelized)): check-%-subtargets: # Otherwise check-$lang isn't parallelized and runtest is invoked just with # the $(RUNTESTFLAGS) arguments. check-parallel-% : site.exp + -test -d plugin || mkdir plugin -test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR) test -d $(TESTSUITEDIR)/$(check_p_subdir) || mkdir $(TESTSUITEDIR)/$(check_p_subdir) -(rootme=`${PWD_COMMAND}`; export rootme; \ diff --git a/gcc/common.opt b/gcc/common.opt index d5f00a0bd9a..6e9e6965f22 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1539,6 +1539,10 @@ gxcoff+ Common JoinedOrMissing Negative(gcoff) Generate debug information in extended XCOFF format +iplugindir= +Common Joined Var(plugindir_string) Init(0) +-iplugindir=<dir> Set <dir> to be the default plugin directory + o Common Joined Separate -o <file> Place output into <file> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ad7d097990f..1c52a3a5464 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -425,8 +425,9 @@ Objective-C and Objective-C++ Dialects}. @item Directory Options @xref{Directory Options,,Options for Directory Search}. -@gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} --specs=@var{file} -I- --sysroot=@var{dir}} +@gccoptlist{-B@var{prefix} -I@var{dir} -iplugindir=@var{dir}} +-iquote@var{dir} -L@var{dir} -specs=@var{file} -I- +--sysroot=@var{dir} @item Machine Dependent Options @xref{Submodel Options,,Hardware Models and Configurations}. @@ -8892,6 +8893,12 @@ the ordering for the include_next directive are not inadvertently changed. If you really need to change the search order for system directories, use the @option{-nostdinc} and/or @option{-isystem} options. +@item -iplugindir=@var{dir} +Set the directory to search for plugins which are passed +by @option{-fplugin=@var{name}} instead of +@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant +to be used by the user, but only passed by the driver. + @item -iquote@var{dir} @opindex iquote Add the directory @var{dir} to the head of the list of directories to diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi index a938e02bb61..77000fee646 100644 --- a/gcc/doc/plugins.texi +++ b/gcc/doc/plugins.texi @@ -22,6 +22,11 @@ The plugin arguments are parsed by GCC and passed to respective plugins as key-value pairs. Multiple plugins can be invoked by specifying multiple @option{-fplugin} arguments. +A plugin can be simply given by its short name (no dots or +slashes). When simply passing @option{-fplugin=NAME}, the plugin is +loaded from the @file{plugin} directory, so @option{-fplugin=NAME} is +the same as @option{-fplugin=`gcc -print-file-name=plugin`/NAME.so}, +using backquote shell syntax to query the @file{plugin} directory. @section Plugin API @@ -407,6 +412,9 @@ On most systems, you can query this @code{plugin} directory by invoking @command{gcc -print-file-name=plugin} (replace if needed @command{gcc} with the appropriate program path). +Inside plugins, this @code{plugin} directory name can be queried by +calling @code{default_plugin_dir_name ()}. + The following GNU Makefile excerpt shows how to build a simple plugin: @smallexample diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h index 275be1d980a..948c4397570 100644 --- a/gcc/gcc-plugin.h +++ b/gcc/gcc-plugin.h @@ -141,4 +141,10 @@ extern void register_callback (const char *plugin_name, extern int unregister_callback (const char *plugin_name, int event); + +/* Retrieve the plugin directory name, as returned by the + -fprint-file-name=plugin argument to the gcc program, which is the + -iplugindir program argument to cc1. */ +extern const char* default_plugin_dir_name (void); + #endif /* GCC_PLUGIN_H */ diff --git a/gcc/gcc.c b/gcc/gcc.c index cee4bf7767b..d2190533796 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -403,6 +403,7 @@ static const char *if_exists_else_spec_function (int, const char **); static const char *replace_outfile_spec_function (int, const char **); static const char *version_compare_spec_function (int, const char **); static const char *include_spec_function (int, const char **); +static const char *find_file_spec_function (int, const char **); static const char *print_asm_header_spec_function (int, const char **); static const char *compare_debug_dump_opt_spec_function (int, const char **); static const char *compare_debug_self_opt_spec_function (int, const char **); @@ -872,6 +873,7 @@ static const char *cpp_unique_options = %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*}\ %{!E:%{!M:%{!MM:%{!MT:%{!MQ:%{MD|MMD:%{o*:-MQ %*}}}}}}}\ %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\ + %{!iplugindir*:%{fplugin*:-iplugindir=%:find-file(plugin)}}\ %{H} %C %{D*&U*&A*} %{i*} %Z %i\ %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ @@ -894,6 +896,7 @@ static const char *cpp_debug_options = "%{d*}"; /* NB: This is shared amongst all front-ends, except for Ada. */ static const char *cc1_options = "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ + %{!iplugindir*:%{fplugin*:-iplugindir=%:find-file(plugin)}}\ %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{a*}\ %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \ %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \ @@ -1726,6 +1729,7 @@ static const struct spec_function static_spec_functions[] = { "replace-outfile", replace_outfile_spec_function }, { "version-compare", version_compare_spec_function }, { "include", include_spec_function }, + { "find-file", find_file_spec_function }, { "print-asm-header", print_asm_header_spec_function }, { "compare-debug-dump-opt", compare_debug_dump_opt_spec_function }, { "compare-debug-self-opt", compare_debug_self_opt_spec_function }, @@ -8710,6 +8714,22 @@ include_spec_function (int argc, const char **argv) return NULL; } +/* %:find-file spec function. This function replace its argument by + the file found thru find_file, that is the -print-file-name gcc + program option. */ +static const char * +find_file_spec_function (int argc, const char**argv) +{ + const char *file; + + if (argc != 1) + abort (); + + file = find_file (argv[0]); + return file; +} + + /* %:print-asm-header spec function. Print a banner to say that the following output is from the assembler. */ diff --git a/gcc/plugin.c b/gcc/plugin.c index 25e5b95be8f..9e1b5f4ada1 100644 --- a/gcc/plugin.c +++ b/gcc/plugin.c @@ -1,5 +1,5 @@ /* Support for GCC plugin mechanism. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -124,16 +124,41 @@ get_plugin_base_name (const char *full_name) } -/* Create a plugin_name_args object for the give plugin and insert it to - the hash table. This function is called when -fplugin=/path/to/NAME.so - option is processed. */ +/* Create a plugin_name_args object for the given plugin and insert it + to the hash table. This function is called when + -fplugin=/path/to/NAME.so or -fplugin=NAME option is processed. */ void add_new_plugin (const char* plugin_name) { struct plugin_name_args *plugin; void **slot; - char *base_name = get_plugin_base_name (plugin_name); + char *base_name; + bool name_is_short; + const char *pc; + + /* Replace short names by their full path when relevant. */ + name_is_short = !IS_ABSOLUTE_PATH (plugin_name); + for (pc = plugin_name; name_is_short && *pc; pc++) + if (*pc == '.' || IS_DIR_SEPARATOR (*pc)) + name_is_short = false; + + if (name_is_short) + { + base_name = CONST_CAST (char*, plugin_name); + /* FIXME: the ".so" suffix is currently builtin, since plugins + only work on ELF host systems like e.g. Linux or Solaris. + When plugins shall be available on non ELF systems such as + Windows or MacOS, this code has to be greatly improved. */ + plugin_name = concat (default_plugin_dir_name (), "/", + plugin_name, ".so", NULL); + if (access (plugin_name, R_OK)) + fatal_error + ("inacessible plugin file %s expanded from short plugin name %s: %m", + plugin_name, base_name); + } + else + base_name = get_plugin_base_name (plugin_name); /* If this is the first -fplugin= option we encounter, create 'plugin_name_args_tab' hash table. */ @@ -809,6 +834,7 @@ plugin_default_version_check (struct plugin_gcc_version *gcc_version, return true; } + /* Return the current value of event_last, so that plugins which provide additional functionality for events for the benefit of high-level plugins know how many valid entries plugin_event_name holds. */ @@ -818,3 +844,15 @@ get_event_last (void) { return event_last; } + + +/* Retrieve the default plugin directory. The gcc driver should have passed + it as -iplugindir <dir> to the cc1 program, and it is queriable thru the + -print-file-name=plugin option to gcc. */ +const char* +default_plugin_dir_name (void) +{ + if (!plugindir_string) + fatal_error ("-iplugindir <dir> option not passed from the gcc driver"); + return plugindir_string; +} diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 68e4aa9e452..d267f5caa5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-04-13 Matthias Klose <doko@ubuntu.com> + + * gcc.dg/plugindir1.c: New testcase. + * gcc.dg/plugindir2.c: New testcase. + * gcc.dg/plugindir3.c: New testcase. + * gcc.dg/plugindir4.c: New testcase. + 2010-04-12 Uros Bizjak <ubizjak@gmail.com> * gcc.target/i386/rotate-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/plugindir1.c b/gcc/testsuite/gcc.dg/plugindir1.c new file mode 100644 index 00000000000..a973ec0c54c --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugindir1.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-c -fplugin=foo" } */ + +/* { dg-prune-output ".*inacessible plugin file.*foo\.so expanded from short plugin name.*" } */ diff --git a/gcc/testsuite/gcc.dg/plugindir2.c b/gcc/testsuite/gcc.dg/plugindir2.c new file mode 100644 index 00000000000..58c1505501a --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugindir2.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-save-temps -c -fplugin=foo" } */ + +/* { dg-prune-output ".*inacessible plugin file.*foo\.so expanded from short plugin name.*" } */ diff --git a/gcc/testsuite/gcc.dg/plugindir3.c b/gcc/testsuite/gcc.dg/plugindir3.c new file mode 100644 index 00000000000..41037534a26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugindir3.c @@ -0,0 +1,4 @@ +/* { dg-do preprocess } */ +/* { dg-options "-fplugin=foo" } */ + +/* { dg-prune-output ".*inacessible plugin file.*foo\.so expanded from short plugin name.*" } */ diff --git a/gcc/testsuite/gcc.dg/plugindir4.c b/gcc/testsuite/gcc.dg/plugindir4.c new file mode 100644 index 00000000000..27b2f24aaf9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugindir4.c @@ -0,0 +1,4 @@ +/* { dg-do preprocess } */ +/* { dg-options "-iplugindir=my-plugindir -fplugin=foo" } */ + +/* { dg-prune-output ".*inacessible plugin file.*my-plugindir/foo\.so expanded from short plugin name.*" } */ |