diff options
author | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-12 23:58:18 +0000 |
---|---|---|
committer | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-12 23:58:18 +0000 |
commit | 19bc000dc88439a5b78345f454d688eb00d99ce2 (patch) | |
tree | 03b93cac03234238b2a22c3947bc8bcd44f3d7fb /gcc/plugin.c | |
parent | 5bc45119b856a18c139f4ff2ffc0f13efe39328e (diff) | |
download | gcc-19bc000dc88439a5b78345f454d688eb00d99ce2.tar.gz |
gcc/
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.
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.
gcc/testsuite/
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158247 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/plugin.c')
-rw-r--r-- | gcc/plugin.c | 48 |
1 files changed, 43 insertions, 5 deletions
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; +} |