1 /* Support for GCC plugin mechanism.
2 Copyright (C) 2009, 2010 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. */
26 /* If plugin support is not enabled, do not try to execute any code
27 that may reference libdl. The generic code is still compiled in to
28 avoid including too many conditional compilation paths in the rest
34 #include "coretypes.h"
35 #include "diagnostic-core.h"
37 #include "tree-pass.h"
44 #include "plugin-version.h"
47 #define GCC_PLUGIN_STRINGIFY0(X) #X
48 #define GCC_PLUGIN_STRINGIFY1(X) GCC_PLUGIN_STRINGIFY0 (X)
50 /* Event names as strings. Keep in sync with enum plugin_event. */
51 static const char *plugin_event_name_init
[] =
53 # define DEFEVENT(NAME) GCC_PLUGIN_STRINGIFY1 (NAME),
54 # include "plugin.def"
58 /* A printf format large enough for the largest event above. */
59 #define FMT_FOR_PLUGIN_EVENT "%-32s"
61 const char **plugin_event_name
= plugin_event_name_init
;
63 /* A hash table to map event names to the position of the names in the
64 plugin_event_name table. */
65 static htab_t event_tab
;
67 /* Keep track of the limit of allocated events and space ready for
69 static int event_last
= PLUGIN_EVENT_FIRST_DYNAMIC
;
70 static int event_horizon
= PLUGIN_EVENT_FIRST_DYNAMIC
;
72 /* Hash table for the plugin_name_args objects created during command-line
74 static htab_t plugin_name_args_tab
= NULL
;
76 /* List node for keeping track of plugin-registered callback. */
79 const char *plugin_name
; /* Name of plugin that registers the callback. */
80 plugin_callback_func func
; /* Callback to be called. */
81 void *user_data
; /* plugin-specified data. */
82 struct callback_info
*next
;
85 /* An array of lists of 'callback_info' objects indexed by the event id. */
86 static struct callback_info
*plugin_callbacks_init
[PLUGIN_EVENT_FIRST_DYNAMIC
];
87 static struct callback_info
**plugin_callbacks
= plugin_callbacks_init
;
89 /* For invoke_plugin_callbacks(), see plugin.h. */
90 bool flag_plugin_added
= false;
93 /* Each plugin should define an initialization function with exactly
95 static const char *str_plugin_init_func_name
= "plugin_init";
97 /* Each plugin should define this symbol to assert that it is
98 distributed under a GPL-compatible license. */
99 static const char *str_license
= "plugin_is_GPL_compatible";
102 /* Helper function for the hash table that compares the base_name of the
103 existing entry (S1) with the given string (S2). */
106 htab_str_eq (const void *s1
, const void *s2
)
108 const struct plugin_name_args
*plugin
= (const struct plugin_name_args
*) s1
;
109 return !strcmp (plugin
->base_name
, (const char *) s2
);
113 /* Given a plugin's full-path name FULL_NAME, e.g. /pass/to/NAME.so,
117 get_plugin_base_name (const char *full_name
)
119 /* First get the base name part of the full-path name, i.e. NAME.so. */
120 char *base_name
= xstrdup (lbasename (full_name
));
122 /* Then get rid of '.so' part of the name. */
123 strip_off_ending (base_name
, strlen (base_name
));
129 /* Create a plugin_name_args object for the given plugin and insert it
130 to the hash table. This function is called when
131 -fplugin=/path/to/NAME.so or -fplugin=NAME option is processed. */
134 add_new_plugin (const char* plugin_name
)
136 struct plugin_name_args
*plugin
;
142 flag_plugin_added
= true;
144 /* Replace short names by their full path when relevant. */
145 name_is_short
= !IS_ABSOLUTE_PATH (plugin_name
);
146 for (pc
= plugin_name
; name_is_short
&& *pc
; pc
++)
147 if (*pc
== '.' || IS_DIR_SEPARATOR (*pc
))
148 name_is_short
= false;
152 base_name
= CONST_CAST (char*, plugin_name
);
153 /* FIXME: the ".so" suffix is currently builtin, since plugins
154 only work on ELF host systems like e.g. Linux or Solaris.
155 When plugins shall be available on non ELF systems such as
156 Windows or MacOS, this code has to be greatly improved. */
157 plugin_name
= concat (default_plugin_dir_name (), "/",
158 plugin_name
, ".so", NULL
);
159 if (access (plugin_name
, R_OK
))
161 ("inacessible plugin file %s expanded from short plugin name %s: %m",
162 plugin_name
, base_name
);
165 base_name
= get_plugin_base_name (plugin_name
);
167 /* If this is the first -fplugin= option we encounter, create
168 'plugin_name_args_tab' hash table. */
169 if (!plugin_name_args_tab
)
170 plugin_name_args_tab
= htab_create (10, htab_hash_string
, htab_str_eq
,
173 slot
= htab_find_slot (plugin_name_args_tab
, base_name
, INSERT
);
175 /* If the same plugin (name) has been specified earlier, either emit an
176 error or a warning message depending on if they have identical full
180 plugin
= (struct plugin_name_args
*) *slot
;
181 if (strcmp (plugin
->full_name
, plugin_name
))
182 error ("plugin %s was specified with different paths:\n%s\n%s",
183 plugin
->base_name
, plugin
->full_name
, plugin_name
);
187 plugin
= XCNEW (struct plugin_name_args
);
188 plugin
->base_name
= base_name
;
189 plugin
->full_name
= plugin_name
;
195 /* Parse the -fplugin-arg-<name>-<key>[=<value>] option and create a
196 'plugin_argument' object for the parsed key-value pair. ARG is
197 the <name>-<key>[=<value>] part of the option. */
200 parse_plugin_arg_opt (const char *arg
)
202 size_t len
= 0, name_len
= 0, key_len
= 0, value_len
= 0;
203 const char *ptr
, *name_start
= arg
, *key_start
= NULL
, *value_start
= NULL
;
204 char *name
, *key
, *value
;
206 bool name_parsed
= false, key_parsed
= false;
208 /* Iterate over the ARG string and identify the starting character position
209 of 'name', 'key', and 'value' and their lengths. */
210 for (ptr
= arg
; *ptr
; ++ptr
)
212 /* Only the first '-' encountered is considered a separator between
213 'name' and 'key'. All the subsequent '-'s are considered part of
214 'key'. For example, given -fplugin-arg-foo-bar-primary-key=value,
215 the plugin name is 'foo' and the key is 'bar-primary-key'. */
216 if (*ptr
== '-' && !name_parsed
)
224 else if (*ptr
== '=')
228 error ("malformed option -fplugin-arg-%s (multiple '=' signs)",
234 value_start
= ptr
+ 1;
244 error ("malformed option -fplugin-arg-%s (missing -<key>[=<value>])",
249 /* If the option doesn't contain the 'value' part, LEN is the KEY_LEN.
250 Otherwise, it is the VALUE_LEN. */
256 name
= XNEWVEC (char, name_len
+ 1);
257 strncpy (name
, name_start
, name_len
);
258 name
[name_len
] = '\0';
260 /* Check if the named plugin has already been specified earlier in the
262 if (plugin_name_args_tab
263 && ((slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
))
266 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
268 key
= XNEWVEC (char, key_len
+ 1);
269 strncpy (key
, key_start
, key_len
);
273 value
= XNEWVEC (char, value_len
+ 1);
274 strncpy (value
, value_start
, value_len
);
275 value
[value_len
] = '\0';
280 /* Create a plugin_argument object for the parsed key-value pair.
281 If there are already arguments for this plugin, we will need to
282 adjust the argument array size by creating a new array and deleting
283 the old one. If the performance ever becomes an issue, we can
284 change the code by pre-allocating a larger array first. */
285 if (plugin
->argc
> 0)
287 struct plugin_argument
*args
= XNEWVEC (struct plugin_argument
,
289 memcpy (args
, plugin
->argv
,
290 sizeof (struct plugin_argument
) * plugin
->argc
);
291 XDELETEVEC (plugin
->argv
);
297 gcc_assert (plugin
->argv
== NULL
);
298 plugin
->argv
= XNEWVEC (struct plugin_argument
, 1);
302 plugin
->argv
[plugin
->argc
- 1].key
= key
;
303 plugin
->argv
[plugin
->argc
- 1].value
= value
;
306 error ("plugin %s should be specified before -fplugin-arg-%s "
307 "in the command line", name
, arg
);
309 /* We don't need the plugin's name anymore. Just release it. */
313 /* Register additional plugin information. NAME is the name passed to
314 plugin_init. INFO is the information that should be registered. */
317 register_plugin_info (const char* name
, struct plugin_info
*info
)
319 void **slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
);
320 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
321 plugin
->version
= info
->version
;
322 plugin
->help
= info
->help
;
325 /* Helper function for the event hash table that compares the name of an
326 existing entry (E1) with the given string (S2). */
329 htab_event_eq (const void *e1
, const void *s2
)
331 const char *s1
= *(const char * const *) e1
;
332 return !strcmp (s1
, (const char *) s2
);
335 /* Look up the event id for NAME. If the name is not found, return -1
336 if INSERT is NO_INSERT. */
339 get_named_event_id (const char *name
, enum insert_option insert
)
347 event_tab
= htab_create (150, htab_hash_string
, htab_event_eq
, NULL
);
348 for (i
= 0; i
< event_last
; i
++)
350 slot
= htab_find_slot (event_tab
, plugin_event_name
[i
], INSERT
);
351 gcc_assert (*slot
== HTAB_EMPTY_ENTRY
);
352 *slot
= &plugin_event_name
[i
];
355 slot
= htab_find_slot (event_tab
, name
, insert
);
358 if (*slot
!= HTAB_EMPTY_ENTRY
)
359 return (const char **) *slot
- &plugin_event_name
[0];
361 if (event_last
>= event_horizon
)
363 event_horizon
= event_last
* 2;
364 if (plugin_event_name
== plugin_event_name_init
)
366 plugin_event_name
= XNEWVEC (const char *, event_horizon
);
367 memcpy (plugin_event_name
, plugin_event_name_init
,
368 sizeof plugin_event_name_init
);
369 plugin_callbacks
= XNEWVEC (struct callback_info
*, event_horizon
);
370 memcpy (plugin_callbacks
, plugin_callbacks_init
,
371 sizeof plugin_callbacks_init
);
376 = XRESIZEVEC (const char *, plugin_event_name
, event_horizon
);
377 plugin_callbacks
= XRESIZEVEC (struct callback_info
*,
378 plugin_callbacks
, event_horizon
);
380 /* All the pointers in the hash table will need to be updated. */
381 htab_delete (event_tab
);
385 *slot
= &plugin_event_name
[event_last
];
386 plugin_event_name
[event_last
] = name
;
390 /* Called from the plugin's initialization code. Register a single callback.
391 This function can be called multiple times.
393 PLUGIN_NAME - display name for this plugin
394 EVENT - which event the callback is for
395 CALLBACK - the callback to be called at the event
396 USER_DATA - plugin-provided data */
399 register_callback (const char *plugin_name
,
401 plugin_callback_func callback
,
406 case PLUGIN_PASS_MANAGER_SETUP
:
407 gcc_assert (!callback
);
408 register_pass ((struct register_pass_info
*) user_data
);
411 gcc_assert (!callback
);
412 register_plugin_info (plugin_name
, (struct plugin_info
*) user_data
);
414 case PLUGIN_REGISTER_GGC_ROOTS
:
415 gcc_assert (!callback
);
416 ggc_register_root_tab ((const struct ggc_root_tab
*) user_data
);
418 case PLUGIN_REGISTER_GGC_CACHES
:
419 gcc_assert (!callback
);
420 ggc_register_cache_tab ((const struct ggc_cache_tab
*) user_data
);
422 case PLUGIN_EVENT_FIRST_DYNAMIC
:
424 if (event
< PLUGIN_EVENT_FIRST_DYNAMIC
|| event
>= event_last
)
426 error ("unknown callback event registered by plugin %s",
431 case PLUGIN_FINISH_TYPE
:
432 case PLUGIN_START_UNIT
:
433 case PLUGIN_FINISH_UNIT
:
434 case PLUGIN_PRE_GENERICIZE
:
435 case PLUGIN_GGC_START
:
436 case PLUGIN_GGC_MARKING
:
438 case PLUGIN_ATTRIBUTES
:
441 case PLUGIN_ALL_PASSES_START
:
442 case PLUGIN_ALL_PASSES_END
:
443 case PLUGIN_ALL_IPA_PASSES_START
:
444 case PLUGIN_ALL_IPA_PASSES_END
:
445 case PLUGIN_OVERRIDE_GATE
:
446 case PLUGIN_PASS_EXECUTION
:
447 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
448 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
449 case PLUGIN_NEW_PASS
:
451 struct callback_info
*new_callback
;
454 error ("plugin %s registered a null callback function "
455 "for event %s", plugin_name
, plugin_event_name
[event
]);
458 new_callback
= XNEW (struct callback_info
);
459 new_callback
->plugin_name
= plugin_name
;
460 new_callback
->func
= callback
;
461 new_callback
->user_data
= user_data
;
462 new_callback
->next
= plugin_callbacks
[event
];
463 plugin_callbacks
[event
] = new_callback
;
469 /* Remove a callback for EVENT which has been registered with for a plugin
470 PLUGIN_NAME. Return PLUGEVT_SUCCESS if a matching callback was
471 found & removed, PLUGEVT_NO_CALLBACK if the event does not have a matching
472 callback, and PLUGEVT_NO_SUCH_EVENT if EVENT is invalid. */
474 unregister_callback (const char *plugin_name
, int event
)
476 struct callback_info
*callback
, **cbp
;
478 if (event
>= event_last
)
479 return PLUGEVT_NO_SUCH_EVENT
;
481 for (cbp
= &plugin_callbacks
[event
]; (callback
= *cbp
); cbp
= &callback
->next
)
482 if (strcmp (callback
->plugin_name
, plugin_name
) == 0)
484 *cbp
= callback
->next
;
485 return PLUGEVT_SUCCESS
;
487 return PLUGEVT_NO_CALLBACK
;
490 /* Invoke all plugin callbacks registered with the specified event,
491 called from invoke_plugin_callbacks(). */
494 invoke_plugin_callbacks_full (int event
, void *gcc_data
)
496 int retval
= PLUGEVT_SUCCESS
;
498 timevar_push (TV_PLUGIN_RUN
);
502 case PLUGIN_EVENT_FIRST_DYNAMIC
:
504 gcc_assert (event
>= PLUGIN_EVENT_FIRST_DYNAMIC
);
505 gcc_assert (event
< event_last
);
507 case PLUGIN_FINISH_TYPE
:
508 case PLUGIN_START_UNIT
:
509 case PLUGIN_FINISH_UNIT
:
510 case PLUGIN_PRE_GENERICIZE
:
511 case PLUGIN_ATTRIBUTES
:
514 case PLUGIN_GGC_START
:
515 case PLUGIN_GGC_MARKING
:
517 case PLUGIN_ALL_PASSES_START
:
518 case PLUGIN_ALL_PASSES_END
:
519 case PLUGIN_ALL_IPA_PASSES_START
:
520 case PLUGIN_ALL_IPA_PASSES_END
:
521 case PLUGIN_OVERRIDE_GATE
:
522 case PLUGIN_PASS_EXECUTION
:
523 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
524 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
525 case PLUGIN_NEW_PASS
:
527 /* Iterate over every callback registered with this event and
529 struct callback_info
*callback
= plugin_callbacks
[event
];
532 retval
= PLUGEVT_NO_CALLBACK
;
533 for ( ; callback
; callback
= callback
->next
)
534 (*callback
->func
) (gcc_data
, callback
->user_data
);
538 case PLUGIN_PASS_MANAGER_SETUP
:
539 case PLUGIN_REGISTER_GGC_ROOTS
:
540 case PLUGIN_REGISTER_GGC_CACHES
:
544 timevar_pop (TV_PLUGIN_RUN
);
549 /* We need a union to cast dlsym return value to a function pointer
550 as ISO C forbids assignment between function pointer and 'void *'.
551 Use explicit union instead of __extension__(<union_cast>) for
553 #define PTR_UNION_TYPE(TOTYPE) union { void *_q; TOTYPE _nq; }
554 #define PTR_UNION_AS_VOID_PTR(NAME) (NAME._q)
555 #define PTR_UNION_AS_CAST_PTR(NAME) (NAME._nq)
557 /* Try to initialize PLUGIN. Return true if successful. */
560 try_init_one_plugin (struct plugin_name_args
*plugin
)
563 plugin_init_func plugin_init
;
565 PTR_UNION_TYPE (plugin_init_func
) plugin_init_union
;
567 /* We use RTLD_NOW to accelerate binding and detect any mismatch
568 between the API expected by the plugin and the GCC API; we use
569 RTLD_GLOBAL which is useful to plugins which themselves call
571 dl_handle
= dlopen (plugin
->full_name
, RTLD_NOW
| RTLD_GLOBAL
);
574 error ("cannot load plugin %s\n%s", plugin
->full_name
, dlerror ());
578 /* Clear any existing error. */
581 /* Check the plugin license. */
582 if (dlsym (dl_handle
, str_license
) == NULL
)
583 fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
584 "%s", plugin
->full_name
, dlerror ());
586 PTR_UNION_AS_VOID_PTR (plugin_init_union
) =
587 dlsym (dl_handle
, str_plugin_init_func_name
);
588 plugin_init
= PTR_UNION_AS_CAST_PTR (plugin_init_union
);
590 if ((err
= dlerror ()) != NULL
)
592 error ("cannot find %s in plugin %s\n%s", str_plugin_init_func_name
,
593 plugin
->full_name
, err
);
597 /* Call the plugin-provided initialization routine with the arguments. */
598 if ((*plugin_init
) (plugin
, &gcc_version
))
600 error ("fail to initialize plugin %s", plugin
->full_name
);
608 /* Routine to dlopen and initialize one plugin. This function is passed to
609 (and called by) the hash table traverse routine. Return 1 for the
610 htab_traverse to continue scan, 0 to stop.
612 SLOT - slot of the hash table element
613 INFO - auxiliary pointer handed to hash table traverse routine
614 (unused in this function) */
617 init_one_plugin (void **slot
, void * ARG_UNUSED (info
))
619 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
620 bool ok
= try_init_one_plugin (plugin
);
623 htab_remove_elt (plugin_name_args_tab
, plugin
->base_name
);
629 #endif /* ENABLE_PLUGIN */
631 /* Main plugin initialization function. Called from compile_file() in
635 initialize_plugins (void)
637 /* If no plugin was specified in the command-line, simply return. */
638 if (!plugin_name_args_tab
)
641 timevar_push (TV_PLUGIN_INIT
);
644 /* Traverse and initialize each plugin specified in the command-line. */
645 htab_traverse_noresize (plugin_name_args_tab
, init_one_plugin
, NULL
);
648 timevar_pop (TV_PLUGIN_INIT
);
651 /* Release memory used by one plugin. */
654 finalize_one_plugin (void **slot
, void * ARG_UNUSED (info
))
656 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
661 /* Free memory allocated by the plugin system. */
664 finalize_plugins (void)
666 if (!plugin_name_args_tab
)
669 /* We can now delete the plugin_name_args object as it will no longer
670 be used. Note that base_name and argv fields (both of which were also
671 dynamically allocated) are not freed as they could still be used by
674 htab_traverse_noresize (plugin_name_args_tab
, finalize_one_plugin
, NULL
);
676 /* PLUGIN_NAME_ARGS_TAB is no longer needed, just delete it. */
677 htab_delete (plugin_name_args_tab
);
678 plugin_name_args_tab
= NULL
;
681 /* Used to pass options to htab_traverse callbacks. */
689 /* Print the version of one plugin. */
692 print_version_one_plugin (void **slot
, void *data
)
694 struct print_options
*opt
= (struct print_options
*) data
;
695 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
696 const char *version
= plugin
->version
? plugin
->version
: "Unknown version.";
698 fprintf (opt
->file
, " %s%s: %s\n", opt
->indent
, plugin
->base_name
, version
);
702 /* Print the version of each plugin. */
705 print_plugins_versions (FILE *file
, const char *indent
)
707 struct print_options opt
;
710 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
713 fprintf (file
, "%sVersions of loaded plugins:\n", indent
);
714 htab_traverse_noresize (plugin_name_args_tab
, print_version_one_plugin
, &opt
);
717 /* Print help for one plugin. SLOT is the hash table slot. DATA is the
718 argument to htab_traverse_noresize. */
721 print_help_one_plugin (void **slot
, void *data
)
723 struct print_options
*opt
= (struct print_options
*) data
;
724 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
725 const char *help
= plugin
->help
? plugin
->help
: "No help available .";
727 char *dup
= xstrdup (help
);
729 fprintf (opt
->file
, " %s%s:\n", opt
->indent
, plugin
->base_name
);
731 for (p
= nl
= dup
; nl
; p
= nl
)
733 nl
= strchr (nl
, '\n');
739 fprintf (opt
->file
, " %s %s\n", opt
->indent
, p
);
746 /* Print help for each plugin. The output goes to FILE and every line starts
750 print_plugins_help (FILE *file
, const char *indent
)
752 struct print_options opt
;
755 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
758 fprintf (file
, "%sHelp for the loaded plugins:\n", indent
);
759 htab_traverse_noresize (plugin_name_args_tab
, print_help_one_plugin
, &opt
);
763 /* Return true if plugins have been loaded. */
766 plugins_active_p (void)
770 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
771 if (plugin_callbacks
[event
])
778 /* Dump to FILE the names and associated events for all the active
782 dump_active_plugins (FILE *file
)
786 if (!plugins_active_p ())
789 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" | %s\n", _("Event"), _("Plugins"));
790 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
791 if (plugin_callbacks
[event
])
793 struct callback_info
*ci
;
795 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" |", plugin_event_name
[event
]);
797 for (ci
= plugin_callbacks
[event
]; ci
; ci
= ci
->next
)
798 fprintf (file
, " %s", ci
->plugin_name
);
805 /* Dump active plugins to stderr. */
808 debug_active_plugins (void)
810 dump_active_plugins (stderr
);
813 /* Give a warning if plugins are present, before an ICE message asking
814 to submit a bug report. */
817 warn_if_plugins (void)
819 if (plugins_active_p ())
821 fnotice (stderr
, "*** WARNING *** there are active plugins, do not report"
822 " this as a bug unless you can reproduce it without enabling"
824 dump_active_plugins (stderr
);
829 /* Likewise, as a callback from the diagnostics code. */
832 plugins_internal_error_function (diagnostic_context
*context ATTRIBUTE_UNUSED
,
833 const char *msgid ATTRIBUTE_UNUSED
,
834 va_list *ap ATTRIBUTE_UNUSED
)
839 /* The default version check. Compares every field in VERSION. */
842 plugin_default_version_check (struct plugin_gcc_version
*gcc_version
,
843 struct plugin_gcc_version
*plugin_version
)
845 if (!gcc_version
|| !plugin_version
)
848 if (strcmp (gcc_version
->basever
, plugin_version
->basever
))
850 if (strcmp (gcc_version
->datestamp
, plugin_version
->datestamp
))
852 if (strcmp (gcc_version
->devphase
, plugin_version
->devphase
))
854 if (strcmp (gcc_version
->revision
, plugin_version
->revision
))
856 if (strcmp (gcc_version
->configuration_arguments
,
857 plugin_version
->configuration_arguments
))
863 /* Return the current value of event_last, so that plugins which provide
864 additional functionality for events for the benefit of high-level plugins
865 know how many valid entries plugin_event_name holds. */
868 get_event_last (void)
874 /* Retrieve the default plugin directory. The gcc driver should have passed
875 it as -iplugindir <dir> to the cc1 program, and it is queriable thru the
876 -print-file-name=plugin option to gcc. */
878 default_plugin_dir_name (void)
880 if (!plugindir_string
)
881 fatal_error ("-iplugindir <dir> option not passed from the gcc driver");
882 return plugindir_string
;