1 /* Support for GCC plugin mechanism.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* This file contains the support for GCC plugin mechanism based on the
21 APIs described in doc/plugin.texi. */
25 #include "coretypes.h"
26 #include "diagnostic-core.h"
28 #include "tree-pass.h"
34 #include "plugin-version.h"
37 #define GCC_PLUGIN_STRINGIFY0(X) #X
38 #define GCC_PLUGIN_STRINGIFY1(X) GCC_PLUGIN_STRINGIFY0 (X)
40 /* Event names as strings. Keep in sync with enum plugin_event. */
41 static const char *plugin_event_name_init
[] =
43 # define DEFEVENT(NAME) GCC_PLUGIN_STRINGIFY1 (NAME),
44 # include "plugin.def"
48 /* A printf format large enough for the largest event above. */
49 #define FMT_FOR_PLUGIN_EVENT "%-32s"
51 const char **plugin_event_name
= plugin_event_name_init
;
53 /* A hash table to map event names to the position of the names in the
54 plugin_event_name table. */
55 static htab_t event_tab
;
57 /* Keep track of the limit of allocated events and space ready for
59 static int event_last
= PLUGIN_EVENT_FIRST_DYNAMIC
;
60 static int event_horizon
= PLUGIN_EVENT_FIRST_DYNAMIC
;
62 /* Hash table for the plugin_name_args objects created during command-line
64 static htab_t plugin_name_args_tab
= NULL
;
66 /* List node for keeping track of plugin-registered callback. */
69 const char *plugin_name
; /* Name of plugin that registers the callback. */
70 plugin_callback_func func
; /* Callback to be called. */
71 void *user_data
; /* plugin-specified data. */
72 struct callback_info
*next
;
75 /* An array of lists of 'callback_info' objects indexed by the event id. */
76 static struct callback_info
*plugin_callbacks_init
[PLUGIN_EVENT_FIRST_DYNAMIC
];
77 static struct callback_info
**plugin_callbacks
= plugin_callbacks_init
;
79 /* For invoke_plugin_callbacks(), see plugin.h. */
80 bool flag_plugin_added
= false;
83 /* Each plugin should define an initialization function with exactly
85 static const char *str_plugin_init_func_name
= "plugin_init";
87 /* Each plugin should define this symbol to assert that it is
88 distributed under a GPL-compatible license. */
89 static const char *str_license
= "plugin_is_GPL_compatible";
92 /* Helper function for the hash table that compares the base_name of the
93 existing entry (S1) with the given string (S2). */
96 htab_str_eq (const void *s1
, const void *s2
)
98 const struct plugin_name_args
*plugin
= (const struct plugin_name_args
*) s1
;
99 return !strcmp (plugin
->base_name
, (const char *) s2
);
103 /* Given a plugin's full-path name FULL_NAME, e.g. /pass/to/NAME.so,
107 get_plugin_base_name (const char *full_name
)
109 /* First get the base name part of the full-path name, i.e. NAME.so. */
110 char *base_name
= xstrdup (lbasename (full_name
));
112 /* Then get rid of '.so' part of the name. */
113 strip_off_ending (base_name
, strlen (base_name
));
119 /* Create a plugin_name_args object for the given plugin and insert it
120 to the hash table. This function is called when
121 -fplugin=/path/to/NAME.so or -fplugin=NAME option is processed. */
124 add_new_plugin (const char* plugin_name
)
126 struct plugin_name_args
*plugin
;
132 flag_plugin_added
= true;
134 /* Replace short names by their full path when relevant. */
135 name_is_short
= !IS_ABSOLUTE_PATH (plugin_name
);
136 for (pc
= plugin_name
; name_is_short
&& *pc
; pc
++)
137 if (*pc
== '.' || IS_DIR_SEPARATOR (*pc
))
138 name_is_short
= false;
142 base_name
= CONST_CAST (char*, plugin_name
);
143 /* FIXME: the ".so" suffix is currently builtin, since plugins
144 only work on ELF host systems like e.g. Linux or Solaris.
145 When plugins shall be available on non ELF systems such as
146 Windows or MacOS, this code has to be greatly improved. */
147 plugin_name
= concat (default_plugin_dir_name (), "/",
148 plugin_name
, ".so", NULL
);
149 if (access (plugin_name
, R_OK
))
151 ("inaccessible plugin file %s expanded from short plugin name %s: %m",
152 plugin_name
, base_name
);
155 base_name
= get_plugin_base_name (plugin_name
);
157 /* If this is the first -fplugin= option we encounter, create
158 'plugin_name_args_tab' hash table. */
159 if (!plugin_name_args_tab
)
160 plugin_name_args_tab
= htab_create (10, htab_hash_string
, htab_str_eq
,
163 slot
= htab_find_slot (plugin_name_args_tab
, base_name
, INSERT
);
165 /* If the same plugin (name) has been specified earlier, either emit an
166 error or a warning message depending on if they have identical full
170 plugin
= (struct plugin_name_args
*) *slot
;
171 if (strcmp (plugin
->full_name
, plugin_name
))
172 error ("plugin %s was specified with different paths:\n%s\n%s",
173 plugin
->base_name
, plugin
->full_name
, plugin_name
);
177 plugin
= XCNEW (struct plugin_name_args
);
178 plugin
->base_name
= base_name
;
179 plugin
->full_name
= plugin_name
;
185 /* Parse the -fplugin-arg-<name>-<key>[=<value>] option and create a
186 'plugin_argument' object for the parsed key-value pair. ARG is
187 the <name>-<key>[=<value>] part of the option. */
190 parse_plugin_arg_opt (const char *arg
)
192 size_t len
= 0, name_len
= 0, key_len
= 0, value_len
= 0;
193 const char *ptr
, *name_start
= arg
, *key_start
= NULL
, *value_start
= NULL
;
194 char *name
, *key
, *value
;
196 bool name_parsed
= false, key_parsed
= false;
198 /* Iterate over the ARG string and identify the starting character position
199 of 'name', 'key', and 'value' and their lengths. */
200 for (ptr
= arg
; *ptr
; ++ptr
)
202 /* Only the first '-' encountered is considered a separator between
203 'name' and 'key'. All the subsequent '-'s are considered part of
204 'key'. For example, given -fplugin-arg-foo-bar-primary-key=value,
205 the plugin name is 'foo' and the key is 'bar-primary-key'. */
206 if (*ptr
== '-' && !name_parsed
)
214 else if (*ptr
== '=')
218 error ("malformed option -fplugin-arg-%s (multiple '=' signs)",
224 value_start
= ptr
+ 1;
234 error ("malformed option -fplugin-arg-%s (missing -<key>[=<value>])",
239 /* If the option doesn't contain the 'value' part, LEN is the KEY_LEN.
240 Otherwise, it is the VALUE_LEN. */
246 name
= XNEWVEC (char, name_len
+ 1);
247 strncpy (name
, name_start
, name_len
);
248 name
[name_len
] = '\0';
250 /* Check if the named plugin has already been specified earlier in the
252 if (plugin_name_args_tab
253 && ((slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
))
256 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
258 key
= XNEWVEC (char, key_len
+ 1);
259 strncpy (key
, key_start
, key_len
);
263 value
= XNEWVEC (char, value_len
+ 1);
264 strncpy (value
, value_start
, value_len
);
265 value
[value_len
] = '\0';
270 /* Create a plugin_argument object for the parsed key-value pair.
271 If there are already arguments for this plugin, we will need to
272 adjust the argument array size by creating a new array and deleting
273 the old one. If the performance ever becomes an issue, we can
274 change the code by pre-allocating a larger array first. */
275 if (plugin
->argc
> 0)
277 struct plugin_argument
*args
= XNEWVEC (struct plugin_argument
,
279 memcpy (args
, plugin
->argv
,
280 sizeof (struct plugin_argument
) * plugin
->argc
);
281 XDELETEVEC (plugin
->argv
);
287 gcc_assert (plugin
->argv
== NULL
);
288 plugin
->argv
= XNEWVEC (struct plugin_argument
, 1);
292 plugin
->argv
[plugin
->argc
- 1].key
= key
;
293 plugin
->argv
[plugin
->argc
- 1].value
= value
;
296 error ("plugin %s should be specified before -fplugin-arg-%s "
297 "in the command line", name
, arg
);
299 /* We don't need the plugin's name anymore. Just release it. */
303 /* Register additional plugin information. NAME is the name passed to
304 plugin_init. INFO is the information that should be registered. */
307 register_plugin_info (const char* name
, struct plugin_info
*info
)
309 void **slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
);
310 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
311 plugin
->version
= info
->version
;
312 plugin
->help
= info
->help
;
315 /* Helper function for the event hash table that compares the name of an
316 existing entry (E1) with the given string (S2). */
319 htab_event_eq (const void *e1
, const void *s2
)
321 const char *s1
= *(const char * const *) e1
;
322 return !strcmp (s1
, (const char *) s2
);
325 /* Look up the event id for NAME. If the name is not found, return -1
326 if INSERT is NO_INSERT. */
329 get_named_event_id (const char *name
, enum insert_option insert
)
337 event_tab
= htab_create (150, htab_hash_string
, htab_event_eq
, NULL
);
338 for (i
= 0; i
< event_last
; i
++)
340 slot
= htab_find_slot (event_tab
, plugin_event_name
[i
], INSERT
);
341 gcc_assert (*slot
== HTAB_EMPTY_ENTRY
);
342 *slot
= &plugin_event_name
[i
];
345 slot
= htab_find_slot (event_tab
, name
, insert
);
348 if (*slot
!= HTAB_EMPTY_ENTRY
)
349 return (const char **) *slot
- &plugin_event_name
[0];
351 if (event_last
>= event_horizon
)
353 event_horizon
= event_last
* 2;
354 if (plugin_event_name
== plugin_event_name_init
)
356 plugin_event_name
= XNEWVEC (const char *, event_horizon
);
357 memcpy (plugin_event_name
, plugin_event_name_init
,
358 sizeof plugin_event_name_init
);
359 plugin_callbacks
= XNEWVEC (struct callback_info
*, event_horizon
);
360 memcpy (plugin_callbacks
, plugin_callbacks_init
,
361 sizeof plugin_callbacks_init
);
366 = XRESIZEVEC (const char *, plugin_event_name
, event_horizon
);
367 plugin_callbacks
= XRESIZEVEC (struct callback_info
*,
368 plugin_callbacks
, event_horizon
);
370 /* All the pointers in the hash table will need to be updated. */
371 htab_delete (event_tab
);
375 *slot
= &plugin_event_name
[event_last
];
376 plugin_event_name
[event_last
] = name
;
380 /* Called from the plugin's initialization code. Register a single callback.
381 This function can be called multiple times.
383 PLUGIN_NAME - display name for this plugin
384 EVENT - which event the callback is for
385 CALLBACK - the callback to be called at the event
386 USER_DATA - plugin-provided data */
389 register_callback (const char *plugin_name
,
391 plugin_callback_func callback
,
396 case PLUGIN_PASS_MANAGER_SETUP
:
397 gcc_assert (!callback
);
398 register_pass ((struct register_pass_info
*) user_data
);
401 gcc_assert (!callback
);
402 register_plugin_info (plugin_name
, (struct plugin_info
*) user_data
);
404 case PLUGIN_REGISTER_GGC_ROOTS
:
405 gcc_assert (!callback
);
406 ggc_register_root_tab ((const struct ggc_root_tab
*) user_data
);
408 case PLUGIN_REGISTER_GGC_CACHES
:
409 gcc_assert (!callback
);
410 ggc_register_cache_tab ((const struct ggc_cache_tab
*) user_data
);
412 case PLUGIN_EVENT_FIRST_DYNAMIC
:
414 if (event
< PLUGIN_EVENT_FIRST_DYNAMIC
|| event
>= event_last
)
416 error ("unknown callback event registered by plugin %s",
421 case PLUGIN_FINISH_TYPE
:
422 case PLUGIN_FINISH_DECL
:
423 case PLUGIN_START_UNIT
:
424 case PLUGIN_FINISH_UNIT
:
425 case PLUGIN_PRE_GENERICIZE
:
426 case PLUGIN_GGC_START
:
427 case PLUGIN_GGC_MARKING
:
429 case PLUGIN_ATTRIBUTES
:
432 case PLUGIN_ALL_PASSES_START
:
433 case PLUGIN_ALL_PASSES_END
:
434 case PLUGIN_ALL_IPA_PASSES_START
:
435 case PLUGIN_ALL_IPA_PASSES_END
:
436 case PLUGIN_OVERRIDE_GATE
:
437 case PLUGIN_PASS_EXECUTION
:
438 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
439 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
440 case PLUGIN_NEW_PASS
:
442 struct callback_info
*new_callback
;
445 error ("plugin %s registered a null callback function "
446 "for event %s", plugin_name
, plugin_event_name
[event
]);
449 new_callback
= XNEW (struct callback_info
);
450 new_callback
->plugin_name
= plugin_name
;
451 new_callback
->func
= callback
;
452 new_callback
->user_data
= user_data
;
453 new_callback
->next
= plugin_callbacks
[event
];
454 plugin_callbacks
[event
] = new_callback
;
460 /* Remove a callback for EVENT which has been registered with for a plugin
461 PLUGIN_NAME. Return PLUGEVT_SUCCESS if a matching callback was
462 found & removed, PLUGEVT_NO_CALLBACK if the event does not have a matching
463 callback, and PLUGEVT_NO_SUCH_EVENT if EVENT is invalid. */
465 unregister_callback (const char *plugin_name
, int event
)
467 struct callback_info
*callback
, **cbp
;
469 if (event
>= event_last
)
470 return PLUGEVT_NO_SUCH_EVENT
;
472 for (cbp
= &plugin_callbacks
[event
]; (callback
= *cbp
); cbp
= &callback
->next
)
473 if (strcmp (callback
->plugin_name
, plugin_name
) == 0)
475 *cbp
= callback
->next
;
476 return PLUGEVT_SUCCESS
;
478 return PLUGEVT_NO_CALLBACK
;
481 /* Invoke all plugin callbacks registered with the specified event,
482 called from invoke_plugin_callbacks(). */
485 invoke_plugin_callbacks_full (int event
, void *gcc_data
)
487 int retval
= PLUGEVT_SUCCESS
;
489 timevar_push (TV_PLUGIN_RUN
);
493 case PLUGIN_EVENT_FIRST_DYNAMIC
:
495 gcc_assert (event
>= PLUGIN_EVENT_FIRST_DYNAMIC
);
496 gcc_assert (event
< event_last
);
498 case PLUGIN_FINISH_TYPE
:
499 case PLUGIN_FINISH_DECL
:
500 case PLUGIN_START_UNIT
:
501 case PLUGIN_FINISH_UNIT
:
502 case PLUGIN_PRE_GENERICIZE
:
503 case PLUGIN_ATTRIBUTES
:
506 case PLUGIN_GGC_START
:
507 case PLUGIN_GGC_MARKING
:
509 case PLUGIN_ALL_PASSES_START
:
510 case PLUGIN_ALL_PASSES_END
:
511 case PLUGIN_ALL_IPA_PASSES_START
:
512 case PLUGIN_ALL_IPA_PASSES_END
:
513 case PLUGIN_OVERRIDE_GATE
:
514 case PLUGIN_PASS_EXECUTION
:
515 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
516 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
517 case PLUGIN_NEW_PASS
:
519 /* Iterate over every callback registered with this event and
521 struct callback_info
*callback
= plugin_callbacks
[event
];
524 retval
= PLUGEVT_NO_CALLBACK
;
525 for ( ; callback
; callback
= callback
->next
)
526 (*callback
->func
) (gcc_data
, callback
->user_data
);
530 case PLUGIN_PASS_MANAGER_SETUP
:
531 case PLUGIN_REGISTER_GGC_ROOTS
:
532 case PLUGIN_REGISTER_GGC_CACHES
:
536 timevar_pop (TV_PLUGIN_RUN
);
541 /* We need a union to cast dlsym return value to a function pointer
542 as ISO C forbids assignment between function pointer and 'void *'.
543 Use explicit union instead of __extension__(<union_cast>) for
545 #define PTR_UNION_TYPE(TOTYPE) union { void *_q; TOTYPE _nq; }
546 #define PTR_UNION_AS_VOID_PTR(NAME) (NAME._q)
547 #define PTR_UNION_AS_CAST_PTR(NAME) (NAME._nq)
549 /* Try to initialize PLUGIN. Return true if successful. */
552 try_init_one_plugin (struct plugin_name_args
*plugin
)
555 plugin_init_func plugin_init
;
557 PTR_UNION_TYPE (plugin_init_func
) plugin_init_union
;
559 /* We use RTLD_NOW to accelerate binding and detect any mismatch
560 between the API expected by the plugin and the GCC API; we use
561 RTLD_GLOBAL which is useful to plugins which themselves call
563 dl_handle
= dlopen (plugin
->full_name
, RTLD_NOW
| RTLD_GLOBAL
);
566 error ("cannot load plugin %s\n%s", plugin
->full_name
, dlerror ());
570 /* Clear any existing error. */
573 /* Check the plugin license. */
574 if (dlsym (dl_handle
, str_license
) == NULL
)
575 fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
576 "%s", plugin
->full_name
, dlerror ());
578 PTR_UNION_AS_VOID_PTR (plugin_init_union
) =
579 dlsym (dl_handle
, str_plugin_init_func_name
);
580 plugin_init
= PTR_UNION_AS_CAST_PTR (plugin_init_union
);
582 if ((err
= dlerror ()) != NULL
)
584 error ("cannot find %s in plugin %s\n%s", str_plugin_init_func_name
,
585 plugin
->full_name
, err
);
589 /* Call the plugin-provided initialization routine with the arguments. */
590 if ((*plugin_init
) (plugin
, &gcc_version
))
592 error ("fail to initialize plugin %s", plugin
->full_name
);
600 /* Routine to dlopen and initialize one plugin. This function is passed to
601 (and called by) the hash table traverse routine. Return 1 for the
602 htab_traverse to continue scan, 0 to stop.
604 SLOT - slot of the hash table element
605 INFO - auxiliary pointer handed to hash table traverse routine
606 (unused in this function) */
609 init_one_plugin (void **slot
, void * ARG_UNUSED (info
))
611 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
612 bool ok
= try_init_one_plugin (plugin
);
615 htab_remove_elt (plugin_name_args_tab
, plugin
->base_name
);
621 #endif /* ENABLE_PLUGIN */
623 /* Main plugin initialization function. Called from compile_file() in
627 initialize_plugins (void)
629 /* If no plugin was specified in the command-line, simply return. */
630 if (!plugin_name_args_tab
)
633 timevar_push (TV_PLUGIN_INIT
);
636 /* Traverse and initialize each plugin specified in the command-line. */
637 htab_traverse_noresize (plugin_name_args_tab
, init_one_plugin
, NULL
);
640 timevar_pop (TV_PLUGIN_INIT
);
643 /* Release memory used by one plugin. */
646 finalize_one_plugin (void **slot
, void * ARG_UNUSED (info
))
648 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
653 /* Free memory allocated by the plugin system. */
656 finalize_plugins (void)
658 if (!plugin_name_args_tab
)
661 /* We can now delete the plugin_name_args object as it will no longer
662 be used. Note that base_name and argv fields (both of which were also
663 dynamically allocated) are not freed as they could still be used by
666 htab_traverse_noresize (plugin_name_args_tab
, finalize_one_plugin
, NULL
);
668 /* PLUGIN_NAME_ARGS_TAB is no longer needed, just delete it. */
669 htab_delete (plugin_name_args_tab
);
670 plugin_name_args_tab
= NULL
;
673 /* Used to pass options to htab_traverse callbacks. */
681 /* Print the version of one plugin. */
684 print_version_one_plugin (void **slot
, void *data
)
686 struct print_options
*opt
= (struct print_options
*) data
;
687 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
688 const char *version
= plugin
->version
? plugin
->version
: "Unknown version.";
690 fprintf (opt
->file
, " %s%s: %s\n", opt
->indent
, plugin
->base_name
, version
);
694 /* Print the version of each plugin. */
697 print_plugins_versions (FILE *file
, const char *indent
)
699 struct print_options opt
;
702 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
705 fprintf (file
, "%sVersions of loaded plugins:\n", indent
);
706 htab_traverse_noresize (plugin_name_args_tab
, print_version_one_plugin
, &opt
);
709 /* Print help for one plugin. SLOT is the hash table slot. DATA is the
710 argument to htab_traverse_noresize. */
713 print_help_one_plugin (void **slot
, void *data
)
715 struct print_options
*opt
= (struct print_options
*) data
;
716 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
717 const char *help
= plugin
->help
? plugin
->help
: "No help available .";
719 char *dup
= xstrdup (help
);
721 fprintf (opt
->file
, " %s%s:\n", opt
->indent
, plugin
->base_name
);
723 for (p
= nl
= dup
; nl
; p
= nl
)
725 nl
= strchr (nl
, '\n');
731 fprintf (opt
->file
, " %s %s\n", opt
->indent
, p
);
738 /* Print help for each plugin. The output goes to FILE and every line starts
742 print_plugins_help (FILE *file
, const char *indent
)
744 struct print_options opt
;
747 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
750 fprintf (file
, "%sHelp for the loaded plugins:\n", indent
);
751 htab_traverse_noresize (plugin_name_args_tab
, print_help_one_plugin
, &opt
);
755 /* Return true if plugins have been loaded. */
758 plugins_active_p (void)
762 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
763 if (plugin_callbacks
[event
])
770 /* Dump to FILE the names and associated events for all the active
774 dump_active_plugins (FILE *file
)
778 if (!plugins_active_p ())
781 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" | %s\n", _("Event"), _("Plugins"));
782 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
783 if (plugin_callbacks
[event
])
785 struct callback_info
*ci
;
787 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" |", plugin_event_name
[event
]);
789 for (ci
= plugin_callbacks
[event
]; ci
; ci
= ci
->next
)
790 fprintf (file
, " %s", ci
->plugin_name
);
797 /* Dump active plugins to stderr. */
800 debug_active_plugins (void)
802 dump_active_plugins (stderr
);
805 /* Give a warning if plugins are present, before an ICE message asking
806 to submit a bug report. */
809 warn_if_plugins (void)
811 if (plugins_active_p ())
813 fnotice (stderr
, "*** WARNING *** there are active plugins, do not report"
814 " this as a bug unless you can reproduce it without enabling"
816 dump_active_plugins (stderr
);
821 /* Likewise, as a callback from the diagnostics code. */
824 plugins_internal_error_function (diagnostic_context
*context ATTRIBUTE_UNUSED
,
825 const char *msgid ATTRIBUTE_UNUSED
,
826 va_list *ap ATTRIBUTE_UNUSED
)
831 /* The default version check. Compares every field in VERSION. */
834 plugin_default_version_check (struct plugin_gcc_version
*gcc_version
,
835 struct plugin_gcc_version
*plugin_version
)
837 if (!gcc_version
|| !plugin_version
)
840 if (strcmp (gcc_version
->basever
, plugin_version
->basever
))
842 if (strcmp (gcc_version
->datestamp
, plugin_version
->datestamp
))
844 if (strcmp (gcc_version
->devphase
, plugin_version
->devphase
))
846 if (strcmp (gcc_version
->revision
, plugin_version
->revision
))
848 if (strcmp (gcc_version
->configuration_arguments
,
849 plugin_version
->configuration_arguments
))
855 /* Return the current value of event_last, so that plugins which provide
856 additional functionality for events for the benefit of high-level plugins
857 know how many valid entries plugin_event_name holds. */
860 get_event_last (void)
866 /* Retrieve the default plugin directory. The gcc driver should have passed
867 it as -iplugindir <dir> to the cc1 program, and it is queriable through the
868 -print-file-name=plugin option to gcc. */
870 default_plugin_dir_name (void)
872 if (!plugindir_string
)
873 fatal_error ("-iplugindir <dir> option not passed from the gcc driver");
874 return plugindir_string
;