Replace register_call_by_name call in passes.c with new plugin event.
[official-gcc.git] / gcc / plugin.c
blobc4bda58c0643c3c28939b083da904693a62bc8bc
1 /* Support for GCC plugin mechanism.
2 Copyright (C) 2009 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)
9 any later version.
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. */
23 #include "config.h"
24 #include "system.h"
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
29 of the compiler. */
30 #ifdef ENABLE_PLUGIN
31 #include <dlfcn.h>
32 #endif
34 #include "coretypes.h"
35 #include "toplev.h"
36 #include "tree.h"
37 #include "tree-pass.h"
38 #include "intl.h"
39 #include "plugin.h"
40 #include "timevar.h"
41 #include "ggc.h"
43 #ifdef ENABLE_PLUGIN
44 #include "plugin-version.h"
45 #endif
47 /* Event names as strings. Keep in sync with enum plugin_event. */
48 static const char *plugin_event_name_init[] =
50 "PLUGIN_PASS_MANAGER_SETUP",
51 "PLUGIN_FINISH_TYPE",
52 "PLUGIN_FINISH_UNIT",
53 "PLUGIN_CXX_CP_PRE_GENERICIZE",
54 "PLUGIN_FINISH",
55 "PLUGIN_INFO",
56 "PLUGIN_GGC_START",
57 "PLUGIN_GGC_MARKING",
58 "PLUGIN_GGC_END",
59 "PLUGIN_REGISTER_GGC_ROOTS",
60 "PLUGIN_REGISTER_GGC_CACHES",
61 "PLUGIN_ATTRIBUTES",
62 "PLUGIN_START_UNIT",
63 "PLUGIN_PRAGMAS",
64 "unroll_parameter_handler",
65 "all_passes_start",
66 "all_passes_execution",
67 "all_passes_end",
68 "all_ipa_passes_start",
69 "all_ipa_passes_execution",
70 "all_ipa_passes_end",
71 "avoid_gate",
72 "pass_execution",
73 "early_gimple_passes_start",
74 "early_gimple_passes_end",
75 "PLUGIN_NEW_PASS",
76 "PLUGIN_EVENT_LAST",
79 const char **plugin_event_name = plugin_event_name_init;
81 /* A hash table to map event names to the position of the names in the
82 plugin_event_name table. */
83 static htab_t event_tab;
85 /* Keep track of the limit of allocated events and space ready for
86 allocating events. */
87 int event_last = PLUGIN_EVENT_LAST;
88 static int event_horizon = PLUGIN_EVENT_LAST;
90 /* Hash table for the plugin_name_args objects created during command-line
91 parsing. */
92 static htab_t plugin_name_args_tab = NULL;
94 /* List node for keeping track of plugin-registered callback. */
95 struct callback_info
97 const char *plugin_name; /* Name of plugin that registers the callback. */
98 plugin_callback_func func; /* Callback to be called. */
99 void *user_data; /* plugin-specified data. */
100 struct callback_info *next;
103 /* An array of lists of 'callback_info' objects indexed by the event id. */
104 static struct callback_info *plugin_callbacks_init[PLUGIN_EVENT_LAST];
105 static struct callback_info **plugin_callbacks = plugin_callbacks_init;
108 #ifdef ENABLE_PLUGIN
109 /* Each plugin should define an initialization function with exactly
110 this name. */
111 static const char *str_plugin_init_func_name = "plugin_init";
113 /* Each plugin should define this symbol to assert that it is
114 distributed under a GPL-compatible license. */
115 static const char *str_license = "plugin_is_GPL_compatible";
116 #endif
118 /* Helper function for the hash table that compares the base_name of the
119 existing entry (S1) with the given string (S2). */
121 static int
122 htab_str_eq (const void *s1, const void *s2)
124 const struct plugin_name_args *plugin = (const struct plugin_name_args *) s1;
125 return !strcmp (plugin->base_name, (const char *) s2);
129 /* Given a plugin's full-path name FULL_NAME, e.g. /pass/to/NAME.so,
130 return NAME. */
132 static char *
133 get_plugin_base_name (const char *full_name)
135 /* First get the base name part of the full-path name, i.e. NAME.so. */
136 char *base_name = xstrdup (lbasename (full_name));
138 /* Then get rid of '.so' part of the name. */
139 strip_off_ending (base_name, strlen (base_name));
141 return base_name;
145 /* Create a plugin_name_args object for the give plugin and insert it to
146 the hash table. This function is called when -fplugin=/path/to/NAME.so
147 option is processed. */
149 void
150 add_new_plugin (const char* plugin_name)
152 struct plugin_name_args *plugin;
153 void **slot;
154 char *base_name = get_plugin_base_name (plugin_name);
156 /* If this is the first -fplugin= option we encounter, create
157 'plugin_name_args_tab' hash table. */
158 if (!plugin_name_args_tab)
159 plugin_name_args_tab = htab_create (10, htab_hash_string, htab_str_eq,
160 NULL);
162 slot = htab_find_slot (plugin_name_args_tab, base_name, INSERT);
164 /* If the same plugin (name) has been specified earlier, either emit an
165 error or a warning message depending on if they have identical full
166 (path) names. */
167 if (*slot)
169 plugin = (struct plugin_name_args *) *slot;
170 if (strcmp (plugin->full_name, plugin_name))
171 error ("Plugin %s was specified with different paths:\n%s\n%s",
172 plugin->base_name, plugin->full_name, plugin_name);
173 return;
176 plugin = XCNEW (struct plugin_name_args);
177 plugin->base_name = base_name;
178 plugin->full_name = plugin_name;
180 *slot = plugin;
184 /* Parse the -fplugin-arg-<name>-<key>[=<value>] option and create a
185 'plugin_argument' object for the parsed key-value pair. ARG is
186 the <name>-<key>[=<value>] part of the option. */
188 void
189 parse_plugin_arg_opt (const char *arg)
191 size_t len = 0, name_len = 0, key_len = 0, value_len = 0;
192 const char *ptr, *name_start = arg, *key_start = NULL, *value_start = NULL;
193 char *name, *key, *value;
194 void **slot;
195 bool name_parsed = false, key_parsed = false;
197 /* Iterate over the ARG string and identify the starting character position
198 of 'name', 'key', and 'value' and their lengths. */
199 for (ptr = arg; *ptr; ++ptr)
201 /* Only the first '-' encountered is considered a separator between
202 'name' and 'key'. All the subsequent '-'s are considered part of
203 'key'. For example, given -fplugin-arg-foo-bar-primary-key=value,
204 the plugin name is 'foo' and the key is 'bar-primary-key'. */
205 if (*ptr == '-' && !name_parsed)
207 name_len = len;
208 len = 0;
209 key_start = ptr + 1;
210 name_parsed = true;
211 continue;
213 else if (*ptr == '=')
215 if (key_parsed)
217 error ("Malformed option -fplugin-arg-%s (multiple '=' signs)",
218 arg);
219 return;
221 key_len = len;
222 len = 0;
223 value_start = ptr + 1;
224 key_parsed = true;
225 continue;
227 else
228 ++len;
231 if (!key_start)
233 error ("Malformed option -fplugin-arg-%s (missing -<key>[=<value>])",
234 arg);
235 return;
238 /* If the option doesn't contain the 'value' part, LEN is the KEY_LEN.
239 Otherwise, it is the VALUE_LEN. */
240 if (!value_start)
241 key_len = len;
242 else
243 value_len = len;
245 name = XNEWVEC (char, name_len + 1);
246 strncpy (name, name_start, name_len);
247 name[name_len] = '\0';
249 /* Check if the named plugin has already been specified earlier in the
250 command-line. */
251 if (plugin_name_args_tab
252 && ((slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT))
253 != NULL))
255 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
257 key = XNEWVEC (char, key_len + 1);
258 strncpy (key, key_start, key_len);
259 key[key_len] = '\0';
260 if (value_start)
262 value = XNEWVEC (char, value_len + 1);
263 strncpy (value, value_start, value_len);
264 value[value_len] = '\0';
266 else
267 value = NULL;
269 /* Create a plugin_argument object for the parsed key-value pair.
270 If there are already arguments for this plugin, we will need to
271 adjust the argument array size by creating a new array and deleting
272 the old one. If the performance ever becomes an issue, we can
273 change the code by pre-allocating a larger array first. */
274 if (plugin->argc > 0)
276 struct plugin_argument *args = XNEWVEC (struct plugin_argument,
277 plugin->argc + 1);
278 memcpy (args, plugin->argv,
279 sizeof (struct plugin_argument) * plugin->argc);
280 XDELETEVEC (plugin->argv);
281 plugin->argv = args;
282 ++plugin->argc;
284 else
286 gcc_assert (plugin->argv == NULL);
287 plugin->argv = XNEWVEC (struct plugin_argument, 1);
288 plugin->argc = 1;
291 plugin->argv[plugin->argc - 1].key = key;
292 plugin->argv[plugin->argc - 1].value = value;
294 else
295 error ("Plugin %s should be specified before -fplugin-arg-%s "
296 "in the command line", name, arg);
298 /* We don't need the plugin's name anymore. Just release it. */
299 XDELETEVEC (name);
302 /* Register additional plugin information. NAME is the name passed to
303 plugin_init. INFO is the information that should be registered. */
305 static void
306 register_plugin_info (const char* name, struct plugin_info *info)
308 void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT);
309 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
310 plugin->version = info->version;
311 plugin->help = info->help;
314 /* Helper function for the event hash table that compares the name of an
315 existing entry (E1) with the given string (S2). */
317 static int
318 htab_event_eq (const void *e1, const void *s2)
320 const char *s1= *(const char * const *) e1;
321 return !strcmp (s1, (const char *) s2);
324 /* Look up the event id for NAME. If the name is not found, return -1
325 if INSERT is NO_INSERT. */
327 get_named_event_id (const char *name, enum insert_option insert)
329 void **slot;
331 if (!event_tab)
333 int i;
335 event_tab = htab_create (150, htab_hash_string, htab_event_eq, NULL);
336 for (i = 0; i < PLUGIN_EVENT_LAST; i++)
338 slot = htab_find_slot (event_tab, plugin_event_name[i], INSERT);
339 gcc_assert (*slot == HTAB_EMPTY_ENTRY);
340 *slot = &plugin_event_name[i];
343 slot = htab_find_slot (event_tab, name, insert);
344 if (slot == NULL)
345 return -1;
346 if (*slot != HTAB_EMPTY_ENTRY)
347 return (const char **) *slot - &plugin_event_name[0];
349 if (event_last >= event_horizon)
351 event_horizon = event_last * 2;
352 if (plugin_event_name == plugin_event_name_init)
354 plugin_event_name = XNEWVEC (const char *, event_horizon);
355 memcpy (plugin_event_name, plugin_event_name_init,
356 sizeof plugin_event_name_init);
357 plugin_callbacks = XNEWVEC (struct callback_info *, event_horizon);
358 memcpy (plugin_callbacks, plugin_callbacks_init,
359 sizeof plugin_callbacks_init);
361 else
363 plugin_event_name
364 = XRESIZEVEC (const char *, plugin_event_name, event_horizon);
365 plugin_callbacks = XRESIZEVEC (struct callback_info *,
366 plugin_callbacks, event_horizon);
368 /* All the pointers in the hash table will need to be updated. */
369 htab_delete (event_tab);
370 event_tab = NULL;
372 else
373 *slot = &plugin_event_name[event_last];
374 plugin_event_name[event_last] = name;
375 return event_last++;
378 /* Called from the plugin's initialization code. Register a single callback.
379 This function can be called multiple times.
381 PLUGIN_NAME - display name for this plugin
382 EVENT - which event the callback is for
383 CALLBACK - the callback to be called at the event
384 USER_DATA - plugin-provided data */
386 void
387 register_callback (const char *plugin_name,
388 int event,
389 plugin_callback_func callback,
390 void *user_data)
392 switch (event)
394 case PLUGIN_PASS_MANAGER_SETUP:
395 gcc_assert (!callback);
396 register_pass ((struct register_pass_info *) user_data);
397 break;
398 case PLUGIN_INFO:
399 gcc_assert (!callback);
400 register_plugin_info (plugin_name, (struct plugin_info *) user_data);
401 break;
402 case PLUGIN_REGISTER_GGC_ROOTS:
403 gcc_assert (!callback);
404 ggc_register_root_tab ((const struct ggc_root_tab*) user_data);
405 break;
406 case PLUGIN_REGISTER_GGC_CACHES:
407 gcc_assert (!callback);
408 ggc_register_cache_tab ((const struct ggc_cache_tab*) user_data);
409 break;
410 case PLUGIN_EVENT_LAST:
411 default:
412 if (event < PLUGIN_FIRST_EXPERIMENTAL || event >= event_last)
414 error ("Unknown callback event registered by plugin %s",
415 plugin_name);
416 return;
418 /* Fall through. */
419 case PLUGIN_FINISH_TYPE:
420 case PLUGIN_START_UNIT:
421 case PLUGIN_FINISH_UNIT:
422 case PLUGIN_CXX_CP_PRE_GENERICIZE:
423 case PLUGIN_GGC_START:
424 case PLUGIN_GGC_MARKING:
425 case PLUGIN_GGC_END:
426 case PLUGIN_ATTRIBUTES:
427 case PLUGIN_PRAGMAS:
428 case PLUGIN_FINISH:
430 struct callback_info *new_callback;
431 if (!callback)
433 error ("Plugin %s registered a null callback function "
434 "for event %s", plugin_name, plugin_event_name[event]);
435 return;
437 new_callback = XNEW (struct callback_info);
438 new_callback->plugin_name = plugin_name;
439 new_callback->func = callback;
440 new_callback->user_data = user_data;
441 new_callback->next = plugin_callbacks[event];
442 plugin_callbacks[event] = new_callback;
444 break;
449 unregister_callback (const char *plugin_name, int event)
451 struct callback_info *callback, **cbp;
453 if (event >= event_last)
454 return PLUGEVT_NO_SUCH_EVENT;
456 for (cbp = &plugin_callbacks[event]; (callback = *cbp); cbp = &callback->next)
457 if (strcmp (callback->plugin_name, plugin_name) == 0)
459 *cbp = callback->next;
460 return PLUGEVT_SUCCESS;
462 return PLUGEVT_NO_CALLBACK;
465 /* Called from inside GCC. Invoke all plug-in callbacks registered with
466 the specified event.
468 EVENT - the event identifier
469 GCC_DATA - event-specific data provided by the compiler */
472 invoke_plugin_callbacks (int event, void *gcc_data)
474 int retval = PLUGEVT_SUCCESS;
476 timevar_push (TV_PLUGIN_RUN);
478 switch (event)
480 case PLUGIN_EVENT_LAST:
481 default:
482 gcc_assert (event >= PLUGIN_FIRST_EXPERIMENTAL);
483 gcc_assert (event < event_last);
484 /* Fall through. */
485 case PLUGIN_FINISH_TYPE:
486 case PLUGIN_START_UNIT:
487 case PLUGIN_FINISH_UNIT:
488 case PLUGIN_CXX_CP_PRE_GENERICIZE:
489 case PLUGIN_ATTRIBUTES:
490 case PLUGIN_PRAGMAS:
491 case PLUGIN_FINISH:
492 case PLUGIN_GGC_START:
493 case PLUGIN_GGC_MARKING:
494 case PLUGIN_GGC_END:
496 /* Iterate over every callback registered with this event and
497 call it. */
498 struct callback_info *callback = plugin_callbacks[event];
500 if (!callback)
501 retval = PLUGEVT_NO_CALLBACK;
502 for ( ; callback; callback = callback->next)
503 (*callback->func) (gcc_data, callback->user_data);
505 break;
507 case PLUGIN_PASS_MANAGER_SETUP:
508 case PLUGIN_REGISTER_GGC_ROOTS:
509 case PLUGIN_REGISTER_GGC_CACHES:
510 gcc_assert (false);
513 timevar_pop (TV_PLUGIN_RUN);
514 return retval;
518 invoke_plugin_va_callbacks (int event, ...)
520 va_list va;
521 int retval;
523 va_start (va, event);
524 retval = invoke_plugin_callbacks (event, &va);
525 va_end (va);
526 return retval;
529 #ifdef ENABLE_PLUGIN
530 /* We need a union to cast dlsym return value to a function pointer
531 as ISO C forbids assignment between function pointer and 'void *'.
532 Use explicit union instead of __extension__(<union_cast>) for
533 portability. */
534 #define PTR_UNION_TYPE(TOTYPE) union { void *_q; TOTYPE _nq; }
535 #define PTR_UNION_AS_VOID_PTR(NAME) (NAME._q)
536 #define PTR_UNION_AS_CAST_PTR(NAME) (NAME._nq)
538 /* Try to initialize PLUGIN. Return true if successful. */
540 static bool
541 try_init_one_plugin (struct plugin_name_args *plugin)
543 void *dl_handle;
544 plugin_init_func plugin_init;
545 const char *err;
546 PTR_UNION_TYPE (plugin_init_func) plugin_init_union;
548 /* We use RTLD_NOW to accelerate binding and detect any mismatch
549 between the API expected by the plugin and the GCC API; we use
550 RTLD_GLOBAL which is useful to plugins which themselves call
551 dlopen. */
552 dl_handle = dlopen (plugin->full_name, RTLD_NOW | RTLD_GLOBAL);
553 if (!dl_handle)
555 error ("Cannot load plugin %s\n%s", plugin->full_name, dlerror ());
556 return false;
559 /* Clear any existing error. */
560 dlerror ();
562 /* Check the plugin license. */
563 if (dlsym (dl_handle, str_license) == NULL)
564 fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
565 "%s", plugin->full_name, dlerror ());
567 PTR_UNION_AS_VOID_PTR (plugin_init_union) =
568 dlsym (dl_handle, str_plugin_init_func_name);
569 plugin_init = PTR_UNION_AS_CAST_PTR (plugin_init_union);
571 if ((err = dlerror ()) != NULL)
573 error ("Cannot find %s in plugin %s\n%s", str_plugin_init_func_name,
574 plugin->full_name, err);
575 return false;
578 /* Call the plugin-provided initialization routine with the arguments. */
579 if ((*plugin_init) (plugin, &gcc_version))
581 error ("Fail to initialize plugin %s", plugin->full_name);
582 return false;
585 return true;
589 /* Routine to dlopen and initialize one plugin. This function is passed to
590 (and called by) the hash table traverse routine. Return 1 for the
591 htab_traverse to continue scan, 0 to stop.
593 SLOT - slot of the hash table element
594 INFO - auxiliary pointer handed to hash table traverse routine
595 (unused in this function) */
597 static int
598 init_one_plugin (void **slot, void * ARG_UNUSED (info))
600 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
601 bool ok = try_init_one_plugin (plugin);
602 if (!ok)
604 htab_remove_elt (plugin_name_args_tab, plugin->base_name);
605 XDELETE (plugin);
607 return 1;
610 #endif /* ENABLE_PLUGIN */
612 /* Main plugin initialization function. Called from compile_file() in
613 toplev.c. */
615 void
616 initialize_plugins (void)
618 /* Test ICI initialization code. */
619 plugin_init (NULL, NULL);
621 /* If no plugin was specified in the command-line, simply return. */
622 if (!plugin_name_args_tab)
623 return;
625 timevar_push (TV_PLUGIN_INIT);
627 #ifdef ENABLE_PLUGIN
628 /* Traverse and initialize each plugin specified in the command-line. */
629 htab_traverse_noresize (plugin_name_args_tab, init_one_plugin, NULL);
630 #endif
632 timevar_pop (TV_PLUGIN_INIT);
635 /* Release memory used by one plugin. */
637 static int
638 finalize_one_plugin (void **slot, void * ARG_UNUSED (info))
640 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
641 XDELETE (plugin);
642 return 1;
645 /* Free memory allocated by the plugin system. */
647 void
648 finalize_plugins (void)
650 if (!plugin_name_args_tab)
651 return;
653 /* We can now delete the plugin_name_args object as it will no longer
654 be used. Note that base_name and argv fields (both of which were also
655 dynamically allocated) are not freed as they could still be used by
656 the plugin code. */
658 htab_traverse_noresize (plugin_name_args_tab, finalize_one_plugin, NULL);
660 /* PLUGIN_NAME_ARGS_TAB is no longer needed, just delete it. */
661 htab_delete (plugin_name_args_tab);
662 plugin_name_args_tab = NULL;
665 /* Used to pass options to htab_traverse callbacks. */
667 struct print_options
669 FILE *file;
670 const char *indent;
673 /* Print the version of one plugin. */
675 static int
676 print_version_one_plugin (void **slot, void *data)
678 struct print_options *opt = (struct print_options *) data;
679 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
680 const char *version = plugin->version ? plugin->version : "Unknown version.";
682 fprintf (opt->file, " %s%s: %s\n", opt->indent, plugin->base_name, version);
683 return 1;
686 /* Print the version of each plugin. */
688 void
689 print_plugins_versions (FILE *file, const char *indent)
691 struct print_options opt;
692 opt.file = file;
693 opt.indent = indent;
694 if (!plugin_name_args_tab || htab_elements (plugin_name_args_tab) == 0)
695 return;
697 fprintf (file, "%sVersions of loaded plugins:\n", indent);
698 htab_traverse_noresize (plugin_name_args_tab, print_version_one_plugin, &opt);
701 /* Print help for one plugin. SLOT is the hash table slot. DATA is the
702 argument to htab_traverse_noresize. */
704 static int
705 print_help_one_plugin (void **slot, void *data)
707 struct print_options *opt = (struct print_options *) data;
708 struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
709 const char *help = plugin->help ? plugin->help : "No help available .";
711 char *dup = xstrdup (help);
712 char *p, *nl;
713 fprintf (opt->file, " %s%s:\n", opt->indent, plugin->base_name);
715 for (p = nl = dup; nl; p = nl)
717 nl = strchr (nl, '\n');
718 if (nl)
720 *nl = '\0';
721 nl++;
723 fprintf (opt->file, " %s %s\n", opt->indent, p);
726 free (dup);
727 return 1;
730 /* Print help for each plugin. The output goes to FILE and every line starts
731 with INDENT. */
733 void
734 print_plugins_help (FILE *file, const char *indent)
736 struct print_options opt;
737 opt.file = file;
738 opt.indent = indent;
739 if (!plugin_name_args_tab || htab_elements (plugin_name_args_tab) == 0)
740 return;
742 fprintf (file, "%sHelp for the loaded plugins:\n", indent);
743 htab_traverse_noresize (plugin_name_args_tab, print_help_one_plugin, &opt);
747 /* Return true if plugins have been loaded. */
749 bool
750 plugins_active_p (void)
752 int event;
754 for (event = PLUGIN_PASS_MANAGER_SETUP; event < event_last; event++)
755 if (plugin_callbacks[event])
756 return true;
758 return false;
762 /* Dump to FILE the names and associated events for all the active
763 plugins. */
765 void
766 dump_active_plugins (FILE *file)
768 int event;
770 if (!plugins_active_p ())
771 return;
773 fprintf (stderr, "Event\t\t\tPlugins\n");
774 for (event = PLUGIN_PASS_MANAGER_SETUP; event < event_last; event++)
775 if (plugin_callbacks[event])
777 struct callback_info *ci;
779 fprintf (file, "%s\t", plugin_event_name[event]);
781 for (ci = plugin_callbacks[event]; ci; ci = ci->next)
782 fprintf (file, "%s ", ci->plugin_name);
784 fprintf (file, "\n");
789 /* Dump active plugins to stderr. */
791 void
792 debug_active_plugins (void)
794 dump_active_plugins (stderr);
797 /* The default version check. Compares every field in VERSION. */
799 bool
800 plugin_default_version_check (struct plugin_gcc_version *gcc_version,
801 struct plugin_gcc_version *plugin_version)
803 if (!gcc_version || !plugin_version)
804 return false;
806 if (strcmp (gcc_version->basever, plugin_version->basever))
807 return false;
808 if (strcmp (gcc_version->datestamp, plugin_version->datestamp))
809 return false;
810 if (strcmp (gcc_version->devphase, plugin_version->devphase))
811 return false;
812 if (strcmp (gcc_version->revision, plugin_version->revision))
813 return false;
814 if (strcmp (gcc_version->configuration_arguments,
815 plugin_version->configuration_arguments))
816 return false;
817 return true;