1 /* Support for GCC plugin mechanism.
2 Copyright (C) 2009-2015 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"
32 #include "tree-pass.h"
37 #include "plugin-version.h"
40 #define GCC_PLUGIN_STRINGIFY0(X) #X
41 #define GCC_PLUGIN_STRINGIFY1(X) GCC_PLUGIN_STRINGIFY0 (X)
43 /* Event names as strings. Keep in sync with enum plugin_event. */
44 static const char *plugin_event_name_init
[] =
46 # define DEFEVENT(NAME) GCC_PLUGIN_STRINGIFY1 (NAME),
47 # include "plugin.def"
51 /* A printf format large enough for the largest event above. */
52 #define FMT_FOR_PLUGIN_EVENT "%-32s"
54 const char **plugin_event_name
= plugin_event_name_init
;
56 /* Event hashtable helpers. */
58 struct event_hasher
: typed_noop_remove
<const char *>
60 typedef const char **value_type
;
61 typedef const char **compare_type
;
62 static inline hashval_t
hash (const char **);
63 static inline bool equal (const char **, const char **);
66 /* Helper function for the event hash table that hashes the entry V. */
69 event_hasher::hash (const char **v
)
71 return htab_hash_string (*v
);
74 /* Helper function for the event hash table that compares the name of an
75 existing entry (S1) with the given string (S2). */
78 event_hasher::equal (const char **s1
, const char **s2
)
80 return !strcmp (*s1
, *s2
);
83 /* A hash table to map event names to the position of the names in the
84 plugin_event_name table. */
85 static hash_table
<event_hasher
> *event_tab
;
87 /* Keep track of the limit of allocated events and space ready for
89 static int event_last
= PLUGIN_EVENT_FIRST_DYNAMIC
;
90 static int event_horizon
= PLUGIN_EVENT_FIRST_DYNAMIC
;
92 /* Hash table for the plugin_name_args objects created during command-line
94 static htab_t plugin_name_args_tab
= NULL
;
96 /* List node for keeping track of plugin-registered callback. */
99 const char *plugin_name
; /* Name of plugin that registers the callback. */
100 plugin_callback_func func
; /* Callback to be called. */
101 void *user_data
; /* plugin-specified data. */
102 struct callback_info
*next
;
105 /* An array of lists of 'callback_info' objects indexed by the event id. */
106 static struct callback_info
*plugin_callbacks_init
[PLUGIN_EVENT_FIRST_DYNAMIC
];
107 static struct callback_info
**plugin_callbacks
= plugin_callbacks_init
;
109 /* For invoke_plugin_callbacks(), see plugin.h. */
110 bool flag_plugin_added
= false;
113 /* Each plugin should define an initialization function with exactly
115 static const char *str_plugin_init_func_name
= "plugin_init";
117 /* Each plugin should define this symbol to assert that it is
118 distributed under a GPL-compatible license. */
119 static const char *str_license
= "plugin_is_GPL_compatible";
122 /* Helper function for the hash table that compares the base_name of the
123 existing entry (S1) with the given string (S2). */
126 htab_str_eq (const void *s1
, const void *s2
)
128 const struct plugin_name_args
*plugin
= (const struct plugin_name_args
*) s1
;
129 return !strcmp (plugin
->base_name
, (const char *) s2
);
133 /* Given a plugin's full-path name FULL_NAME, e.g. /pass/to/NAME.so,
137 get_plugin_base_name (const char *full_name
)
139 /* First get the base name part of the full-path name, i.e. NAME.so. */
140 char *base_name
= xstrdup (lbasename (full_name
));
142 /* Then get rid of '.so' part of the name. */
143 strip_off_ending (base_name
, strlen (base_name
));
149 /* Create a plugin_name_args object for the given plugin and insert it
150 to the hash table. This function is called when
151 -fplugin=/path/to/NAME.so or -fplugin=NAME option is processed. */
154 add_new_plugin (const char* plugin_name
)
156 struct plugin_name_args
*plugin
;
162 flag_plugin_added
= true;
164 /* Replace short names by their full path when relevant. */
165 name_is_short
= !IS_ABSOLUTE_PATH (plugin_name
);
166 for (pc
= plugin_name
; name_is_short
&& *pc
; pc
++)
167 if (*pc
== '.' || IS_DIR_SEPARATOR (*pc
))
168 name_is_short
= false;
172 base_name
= CONST_CAST (char*, plugin_name
);
173 /* FIXME: the ".so" suffix is currently builtin, since plugins
174 only work on ELF host systems like e.g. Linux or Solaris.
175 When plugins shall be available on non ELF systems such as
176 Windows or MacOS, this code has to be greatly improved. */
177 plugin_name
= concat (default_plugin_dir_name (), "/",
178 plugin_name
, ".so", NULL
);
179 if (access (plugin_name
, R_OK
))
182 "inaccessible plugin file %s expanded from short plugin name %s: %m",
183 plugin_name
, base_name
);
186 base_name
= get_plugin_base_name (plugin_name
);
188 /* If this is the first -fplugin= option we encounter, create
189 'plugin_name_args_tab' hash table. */
190 if (!plugin_name_args_tab
)
191 plugin_name_args_tab
= htab_create (10, htab_hash_string
, htab_str_eq
,
194 slot
= htab_find_slot (plugin_name_args_tab
, base_name
, INSERT
);
196 /* If the same plugin (name) has been specified earlier, either emit an
197 error or a warning message depending on if they have identical full
201 plugin
= (struct plugin_name_args
*) *slot
;
202 if (strcmp (plugin
->full_name
, plugin_name
))
203 error ("plugin %s was specified with different paths:\n%s\n%s",
204 plugin
->base_name
, plugin
->full_name
, plugin_name
);
208 plugin
= XCNEW (struct plugin_name_args
);
209 plugin
->base_name
= base_name
;
210 plugin
->full_name
= plugin_name
;
216 /* Parse the -fplugin-arg-<name>-<key>[=<value>] option and create a
217 'plugin_argument' object for the parsed key-value pair. ARG is
218 the <name>-<key>[=<value>] part of the option. */
221 parse_plugin_arg_opt (const char *arg
)
223 size_t len
= 0, name_len
= 0, key_len
= 0, value_len
= 0;
224 const char *ptr
, *name_start
= arg
, *key_start
= NULL
, *value_start
= NULL
;
225 char *name
, *key
, *value
;
227 bool name_parsed
= false, key_parsed
= false;
229 /* Iterate over the ARG string and identify the starting character position
230 of 'name', 'key', and 'value' and their lengths. */
231 for (ptr
= arg
; *ptr
; ++ptr
)
233 /* Only the first '-' encountered is considered a separator between
234 'name' and 'key'. All the subsequent '-'s are considered part of
235 'key'. For example, given -fplugin-arg-foo-bar-primary-key=value,
236 the plugin name is 'foo' and the key is 'bar-primary-key'. */
237 if (*ptr
== '-' && !name_parsed
)
245 else if (*ptr
== '=')
251 value_start
= ptr
+ 1;
262 error ("malformed option -fplugin-arg-%s (missing -<key>[=<value>])",
267 /* If the option doesn't contain the 'value' part, LEN is the KEY_LEN.
268 Otherwise, it is the VALUE_LEN. */
274 name
= XNEWVEC (char, name_len
+ 1);
275 strncpy (name
, name_start
, name_len
);
276 name
[name_len
] = '\0';
278 /* Check if the named plugin has already been specified earlier in the
280 if (plugin_name_args_tab
281 && ((slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
))
284 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
286 key
= XNEWVEC (char, key_len
+ 1);
287 strncpy (key
, key_start
, key_len
);
291 value
= XNEWVEC (char, value_len
+ 1);
292 strncpy (value
, value_start
, value_len
);
293 value
[value_len
] = '\0';
298 /* Create a plugin_argument object for the parsed key-value pair.
299 If there are already arguments for this plugin, we will need to
300 adjust the argument array size by creating a new array and deleting
301 the old one. If the performance ever becomes an issue, we can
302 change the code by pre-allocating a larger array first. */
303 if (plugin
->argc
> 0)
305 struct plugin_argument
*args
= XNEWVEC (struct plugin_argument
,
307 memcpy (args
, plugin
->argv
,
308 sizeof (struct plugin_argument
) * plugin
->argc
);
309 XDELETEVEC (plugin
->argv
);
315 gcc_assert (plugin
->argv
== NULL
);
316 plugin
->argv
= XNEWVEC (struct plugin_argument
, 1);
320 plugin
->argv
[plugin
->argc
- 1].key
= key
;
321 plugin
->argv
[plugin
->argc
- 1].value
= value
;
324 error ("plugin %s should be specified before -fplugin-arg-%s "
325 "in the command line", name
, arg
);
327 /* We don't need the plugin's name anymore. Just release it. */
331 /* Register additional plugin information. NAME is the name passed to
332 plugin_init. INFO is the information that should be registered. */
335 register_plugin_info (const char* name
, struct plugin_info
*info
)
337 void **slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
);
338 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
339 plugin
->version
= info
->version
;
340 plugin
->help
= info
->help
;
343 /* Look up the event id for NAME. If the name is not found, return -1
344 if INSERT is NO_INSERT. */
347 get_named_event_id (const char *name
, enum insert_option insert
)
355 event_tab
= new hash_table
<event_hasher
> (150);
356 for (i
= 0; i
< event_last
; i
++)
358 slot
= event_tab
->find_slot (&plugin_event_name
[i
], INSERT
);
359 gcc_assert (*slot
== HTAB_EMPTY_ENTRY
);
360 *slot
= &plugin_event_name
[i
];
363 slot
= event_tab
->find_slot (&name
, insert
);
366 if (*slot
!= HTAB_EMPTY_ENTRY
)
367 return *slot
- &plugin_event_name
[0];
369 if (event_last
>= event_horizon
)
371 event_horizon
= event_last
* 2;
372 if (plugin_event_name
== plugin_event_name_init
)
374 plugin_event_name
= XNEWVEC (const char *, event_horizon
);
375 memcpy (plugin_event_name
, plugin_event_name_init
,
376 sizeof plugin_event_name_init
);
377 plugin_callbacks
= XNEWVEC (struct callback_info
*, event_horizon
);
378 memcpy (plugin_callbacks
, plugin_callbacks_init
,
379 sizeof plugin_callbacks_init
);
384 = XRESIZEVEC (const char *, plugin_event_name
, event_horizon
);
385 plugin_callbacks
= XRESIZEVEC (struct callback_info
*,
386 plugin_callbacks
, event_horizon
);
388 /* All the pointers in the hash table will need to be updated. */
393 *slot
= &plugin_event_name
[event_last
];
394 plugin_event_name
[event_last
] = name
;
398 /* Called from the plugin's initialization code. Register a single callback.
399 This function can be called multiple times.
401 PLUGIN_NAME - display name for this plugin
402 EVENT - which event the callback is for
403 CALLBACK - the callback to be called at the event
404 USER_DATA - plugin-provided data */
407 register_callback (const char *plugin_name
,
409 plugin_callback_func callback
,
414 case PLUGIN_PASS_MANAGER_SETUP
:
415 gcc_assert (!callback
);
416 register_pass ((struct register_pass_info
*) user_data
);
419 gcc_assert (!callback
);
420 register_plugin_info (plugin_name
, (struct plugin_info
*) user_data
);
422 case PLUGIN_REGISTER_GGC_ROOTS
:
423 gcc_assert (!callback
);
424 ggc_register_root_tab ((const struct ggc_root_tab
*) user_data
);
426 case PLUGIN_EVENT_FIRST_DYNAMIC
:
428 if (event
< PLUGIN_EVENT_FIRST_DYNAMIC
|| event
>= event_last
)
430 error ("unknown callback event registered by plugin %s",
435 case PLUGIN_START_PARSE_FUNCTION
:
436 case PLUGIN_FINISH_PARSE_FUNCTION
:
437 case PLUGIN_FINISH_TYPE
:
438 case PLUGIN_FINISH_DECL
:
439 case PLUGIN_START_UNIT
:
440 case PLUGIN_FINISH_UNIT
:
441 case PLUGIN_PRE_GENERICIZE
:
442 case PLUGIN_GGC_START
:
443 case PLUGIN_GGC_MARKING
:
445 case PLUGIN_ATTRIBUTES
:
448 case PLUGIN_ALL_PASSES_START
:
449 case PLUGIN_ALL_PASSES_END
:
450 case PLUGIN_ALL_IPA_PASSES_START
:
451 case PLUGIN_ALL_IPA_PASSES_END
:
452 case PLUGIN_OVERRIDE_GATE
:
453 case PLUGIN_PASS_EXECUTION
:
454 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
455 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
456 case PLUGIN_NEW_PASS
:
457 case PLUGIN_INCLUDE_FILE
:
459 struct callback_info
*new_callback
;
462 error ("plugin %s registered a null callback function "
463 "for event %s", plugin_name
, plugin_event_name
[event
]);
466 new_callback
= XNEW (struct callback_info
);
467 new_callback
->plugin_name
= plugin_name
;
468 new_callback
->func
= callback
;
469 new_callback
->user_data
= user_data
;
470 new_callback
->next
= plugin_callbacks
[event
];
471 plugin_callbacks
[event
] = new_callback
;
477 /* Remove a callback for EVENT which has been registered with for a plugin
478 PLUGIN_NAME. Return PLUGEVT_SUCCESS if a matching callback was
479 found & removed, PLUGEVT_NO_CALLBACK if the event does not have a matching
480 callback, and PLUGEVT_NO_SUCH_EVENT if EVENT is invalid. */
482 unregister_callback (const char *plugin_name
, int event
)
484 struct callback_info
*callback
, **cbp
;
486 if (event
>= event_last
)
487 return PLUGEVT_NO_SUCH_EVENT
;
489 for (cbp
= &plugin_callbacks
[event
]; (callback
= *cbp
); cbp
= &callback
->next
)
490 if (strcmp (callback
->plugin_name
, plugin_name
) == 0)
492 *cbp
= callback
->next
;
493 return PLUGEVT_SUCCESS
;
495 return PLUGEVT_NO_CALLBACK
;
498 /* Invoke all plugin callbacks registered with the specified event,
499 called from invoke_plugin_callbacks(). */
502 invoke_plugin_callbacks_full (int event
, void *gcc_data
)
504 int retval
= PLUGEVT_SUCCESS
;
506 timevar_push (TV_PLUGIN_RUN
);
510 case PLUGIN_EVENT_FIRST_DYNAMIC
:
512 gcc_assert (event
>= PLUGIN_EVENT_FIRST_DYNAMIC
);
513 gcc_assert (event
< event_last
);
515 case PLUGIN_START_PARSE_FUNCTION
:
516 case PLUGIN_FINISH_PARSE_FUNCTION
:
517 case PLUGIN_FINISH_TYPE
:
518 case PLUGIN_FINISH_DECL
:
519 case PLUGIN_START_UNIT
:
520 case PLUGIN_FINISH_UNIT
:
521 case PLUGIN_PRE_GENERICIZE
:
522 case PLUGIN_ATTRIBUTES
:
525 case PLUGIN_GGC_START
:
526 case PLUGIN_GGC_MARKING
:
528 case PLUGIN_ALL_PASSES_START
:
529 case PLUGIN_ALL_PASSES_END
:
530 case PLUGIN_ALL_IPA_PASSES_START
:
531 case PLUGIN_ALL_IPA_PASSES_END
:
532 case PLUGIN_OVERRIDE_GATE
:
533 case PLUGIN_PASS_EXECUTION
:
534 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
535 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
536 case PLUGIN_NEW_PASS
:
537 case PLUGIN_INCLUDE_FILE
:
539 /* Iterate over every callback registered with this event and
541 struct callback_info
*callback
= plugin_callbacks
[event
];
544 retval
= PLUGEVT_NO_CALLBACK
;
545 for ( ; callback
; callback
= callback
->next
)
546 (*callback
->func
) (gcc_data
, callback
->user_data
);
550 case PLUGIN_PASS_MANAGER_SETUP
:
551 case PLUGIN_REGISTER_GGC_ROOTS
:
555 timevar_pop (TV_PLUGIN_RUN
);
560 /* We need a union to cast dlsym return value to a function pointer
561 as ISO C forbids assignment between function pointer and 'void *'.
562 Use explicit union instead of __extension__(<union_cast>) for
564 #define PTR_UNION_TYPE(TOTYPE) union { void *_q; TOTYPE _nq; }
565 #define PTR_UNION_AS_VOID_PTR(NAME) (NAME._q)
566 #define PTR_UNION_AS_CAST_PTR(NAME) (NAME._nq)
568 /* Try to initialize PLUGIN. Return true if successful. */
571 try_init_one_plugin (struct plugin_name_args
*plugin
)
574 plugin_init_func plugin_init
;
576 PTR_UNION_TYPE (plugin_init_func
) plugin_init_union
;
578 /* We use RTLD_NOW to accelerate binding and detect any mismatch
579 between the API expected by the plugin and the GCC API; we use
580 RTLD_GLOBAL which is useful to plugins which themselves call
582 dl_handle
= dlopen (plugin
->full_name
, RTLD_NOW
| RTLD_GLOBAL
);
585 error ("cannot load plugin %s\n%s", plugin
->full_name
, dlerror ());
589 /* Clear any existing error. */
592 /* Check the plugin license. */
593 if (dlsym (dl_handle
, str_license
) == NULL
)
594 fatal_error (input_location
,
595 "plugin %s is not licensed under a GPL-compatible license\n"
596 "%s", plugin
->full_name
, dlerror ());
598 PTR_UNION_AS_VOID_PTR (plugin_init_union
) =
599 dlsym (dl_handle
, str_plugin_init_func_name
);
600 plugin_init
= PTR_UNION_AS_CAST_PTR (plugin_init_union
);
602 if ((err
= dlerror ()) != NULL
)
604 error ("cannot find %s in plugin %s\n%s", str_plugin_init_func_name
,
605 plugin
->full_name
, err
);
609 /* Call the plugin-provided initialization routine with the arguments. */
610 if ((*plugin_init
) (plugin
, &gcc_version
))
612 error ("fail to initialize plugin %s", plugin
->full_name
);
620 /* Routine to dlopen and initialize one plugin. This function is passed to
621 (and called by) the hash table traverse routine. Return 1 for the
622 htab_traverse to continue scan, 0 to stop.
624 SLOT - slot of the hash table element
625 INFO - auxiliary pointer handed to hash table traverse routine
626 (unused in this function) */
629 init_one_plugin (void **slot
, void * ARG_UNUSED (info
))
631 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
632 bool ok
= try_init_one_plugin (plugin
);
635 htab_remove_elt (plugin_name_args_tab
, plugin
->base_name
);
641 #endif /* ENABLE_PLUGIN */
643 /* Main plugin initialization function. Called from compile_file() in
647 initialize_plugins (void)
649 /* If no plugin was specified in the command-line, simply return. */
650 if (!plugin_name_args_tab
)
653 timevar_push (TV_PLUGIN_INIT
);
656 /* Traverse and initialize each plugin specified in the command-line. */
657 htab_traverse_noresize (plugin_name_args_tab
, init_one_plugin
, NULL
);
660 timevar_pop (TV_PLUGIN_INIT
);
663 /* Release memory used by one plugin. */
666 finalize_one_plugin (void **slot
, void * ARG_UNUSED (info
))
668 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
673 /* Free memory allocated by the plugin system. */
676 finalize_plugins (void)
678 if (!plugin_name_args_tab
)
681 /* We can now delete the plugin_name_args object as it will no longer
682 be used. Note that base_name and argv fields (both of which were also
683 dynamically allocated) are not freed as they could still be used by
686 htab_traverse_noresize (plugin_name_args_tab
, finalize_one_plugin
, NULL
);
688 /* PLUGIN_NAME_ARGS_TAB is no longer needed, just delete it. */
689 htab_delete (plugin_name_args_tab
);
690 plugin_name_args_tab
= NULL
;
693 /* Used to pass options to htab_traverse callbacks. */
701 /* Print the version of one plugin. */
704 print_version_one_plugin (void **slot
, void *data
)
706 struct print_options
*opt
= (struct print_options
*) data
;
707 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
708 const char *version
= plugin
->version
? plugin
->version
: "Unknown version.";
710 fprintf (opt
->file
, " %s%s: %s\n", opt
->indent
, plugin
->base_name
, version
);
714 /* Print the version of each plugin. */
717 print_plugins_versions (FILE *file
, const char *indent
)
719 struct print_options opt
;
722 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
725 fprintf (file
, "%sVersions of loaded plugins:\n", indent
);
726 htab_traverse_noresize (plugin_name_args_tab
, print_version_one_plugin
, &opt
);
729 /* Print help for one plugin. SLOT is the hash table slot. DATA is the
730 argument to htab_traverse_noresize. */
733 print_help_one_plugin (void **slot
, void *data
)
735 struct print_options
*opt
= (struct print_options
*) data
;
736 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
737 const char *help
= plugin
->help
? plugin
->help
: "No help available .";
739 char *dup
= xstrdup (help
);
741 fprintf (opt
->file
, " %s%s:\n", opt
->indent
, plugin
->base_name
);
743 for (p
= nl
= dup
; nl
; p
= nl
)
745 nl
= strchr (nl
, '\n');
751 fprintf (opt
->file
, " %s %s\n", opt
->indent
, p
);
758 /* Print help for each plugin. The output goes to FILE and every line starts
762 print_plugins_help (FILE *file
, const char *indent
)
764 struct print_options opt
;
767 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
770 fprintf (file
, "%sHelp for the loaded plugins:\n", indent
);
771 htab_traverse_noresize (plugin_name_args_tab
, print_help_one_plugin
, &opt
);
775 /* Return true if plugins have been loaded. */
778 plugins_active_p (void)
782 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
783 if (plugin_callbacks
[event
])
790 /* Dump to FILE the names and associated events for all the active
794 dump_active_plugins (FILE *file
)
798 if (!plugins_active_p ())
801 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" | %s\n", _("Event"), _("Plugins"));
802 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
803 if (plugin_callbacks
[event
])
805 struct callback_info
*ci
;
807 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" |", plugin_event_name
[event
]);
809 for (ci
= plugin_callbacks
[event
]; ci
; ci
= ci
->next
)
810 fprintf (file
, " %s", ci
->plugin_name
);
817 /* Dump active plugins to stderr. */
820 debug_active_plugins (void)
822 dump_active_plugins (stderr
);
825 /* Give a warning if plugins are present, before an ICE message asking
826 to submit a bug report. */
829 warn_if_plugins (void)
831 if (plugins_active_p ())
833 fnotice (stderr
, "*** WARNING *** there are active plugins, do not report"
834 " this as a bug unless you can reproduce it without enabling"
836 dump_active_plugins (stderr
);
841 /* Likewise, as a callback from the diagnostics code. */
844 plugins_internal_error_function (diagnostic_context
*context ATTRIBUTE_UNUSED
,
845 const char *msgid ATTRIBUTE_UNUSED
,
846 va_list *ap ATTRIBUTE_UNUSED
)
851 /* The default version check. Compares every field in VERSION. */
854 plugin_default_version_check (struct plugin_gcc_version
*gcc_version
,
855 struct plugin_gcc_version
*plugin_version
)
857 if (!gcc_version
|| !plugin_version
)
860 if (strcmp (gcc_version
->basever
, plugin_version
->basever
))
862 if (strcmp (gcc_version
->datestamp
, plugin_version
->datestamp
))
864 if (strcmp (gcc_version
->devphase
, plugin_version
->devphase
))
866 if (strcmp (gcc_version
->revision
, plugin_version
->revision
))
868 if (strcmp (gcc_version
->configuration_arguments
,
869 plugin_version
->configuration_arguments
))
875 /* Return the current value of event_last, so that plugins which provide
876 additional functionality for events for the benefit of high-level plugins
877 know how many valid entries plugin_event_name holds. */
880 get_event_last (void)
886 /* Retrieve the default plugin directory. The gcc driver should have passed
887 it as -iplugindir <dir> to the cc1 program, and it is queriable through the
888 -print-file-name=plugin option to gcc. */
890 default_plugin_dir_name (void)
892 if (!plugindir_string
)
893 fatal_error (input_location
,
894 "-iplugindir <dir> option not passed from the gcc driver");
895 return plugindir_string
;