1 /* Support for GCC plugin mechanism.
2 Copyright (C) 2009-2014 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 "hash-table.h"
27 #include "diagnostic-core.h"
29 #include "tree-pass.h"
35 #include "plugin-version.h"
38 #define GCC_PLUGIN_STRINGIFY0(X) #X
39 #define GCC_PLUGIN_STRINGIFY1(X) GCC_PLUGIN_STRINGIFY0 (X)
41 /* Event names as strings. Keep in sync with enum plugin_event. */
42 static const char *plugin_event_name_init
[] =
44 # define DEFEVENT(NAME) GCC_PLUGIN_STRINGIFY1 (NAME),
45 # include "plugin.def"
49 /* A printf format large enough for the largest event above. */
50 #define FMT_FOR_PLUGIN_EVENT "%-32s"
52 const char **plugin_event_name
= plugin_event_name_init
;
54 /* Event hashtable helpers. */
56 struct event_hasher
: typed_noop_remove
<const char *>
58 typedef const char *value_type
;
59 typedef const char *compare_type
;
60 static inline hashval_t
hash (const value_type
*);
61 static inline bool equal (const value_type
*, const compare_type
*);
64 /* Helper function for the event hash table that hashes the entry V. */
67 event_hasher::hash (const value_type
*v
)
69 return htab_hash_string (*v
);
72 /* Helper function for the event hash table that compares the name of an
73 existing entry (S1) with the given string (S2). */
76 event_hasher::equal (const value_type
*s1
, const compare_type
*s2
)
78 return !strcmp (*s1
, *s2
);
81 /* A hash table to map event names to the position of the names in the
82 plugin_event_name table. */
83 static hash_table
<event_hasher
> *event_tab
;
85 /* Keep track of the limit of allocated events and space ready for
87 static int event_last
= PLUGIN_EVENT_FIRST_DYNAMIC
;
88 static int event_horizon
= PLUGIN_EVENT_FIRST_DYNAMIC
;
90 /* Hash table for the plugin_name_args objects created during command-line
92 static htab_t plugin_name_args_tab
= NULL
;
94 /* List node for keeping track of plugin-registered callback. */
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_FIRST_DYNAMIC
];
105 static struct callback_info
**plugin_callbacks
= plugin_callbacks_init
;
107 /* For invoke_plugin_callbacks(), see plugin.h. */
108 bool flag_plugin_added
= false;
111 /* Each plugin should define an initialization function with exactly
113 static const char *str_plugin_init_func_name
= "plugin_init";
115 /* Each plugin should define this symbol to assert that it is
116 distributed under a GPL-compatible license. */
117 static const char *str_license
= "plugin_is_GPL_compatible";
120 /* Helper function for the hash table that compares the base_name of the
121 existing entry (S1) with the given string (S2). */
124 htab_str_eq (const void *s1
, const void *s2
)
126 const struct plugin_name_args
*plugin
= (const struct plugin_name_args
*) s1
;
127 return !strcmp (plugin
->base_name
, (const char *) s2
);
131 /* Given a plugin's full-path name FULL_NAME, e.g. /pass/to/NAME.so,
135 get_plugin_base_name (const char *full_name
)
137 /* First get the base name part of the full-path name, i.e. NAME.so. */
138 char *base_name
= xstrdup (lbasename (full_name
));
140 /* Then get rid of '.so' part of the name. */
141 strip_off_ending (base_name
, strlen (base_name
));
147 /* Create a plugin_name_args object for the given plugin and insert it
148 to the hash table. This function is called when
149 -fplugin=/path/to/NAME.so or -fplugin=NAME option is processed. */
152 add_new_plugin (const char* plugin_name
)
154 struct plugin_name_args
*plugin
;
160 flag_plugin_added
= true;
162 /* Replace short names by their full path when relevant. */
163 name_is_short
= !IS_ABSOLUTE_PATH (plugin_name
);
164 for (pc
= plugin_name
; name_is_short
&& *pc
; pc
++)
165 if (*pc
== '.' || IS_DIR_SEPARATOR (*pc
))
166 name_is_short
= false;
170 base_name
= CONST_CAST (char*, plugin_name
);
171 /* FIXME: the ".so" suffix is currently builtin, since plugins
172 only work on ELF host systems like e.g. Linux or Solaris.
173 When plugins shall be available on non ELF systems such as
174 Windows or MacOS, this code has to be greatly improved. */
175 plugin_name
= concat (default_plugin_dir_name (), "/",
176 plugin_name
, ".so", NULL
);
177 if (access (plugin_name
, R_OK
))
179 ("inaccessible plugin file %s expanded from short plugin name %s: %m",
180 plugin_name
, base_name
);
183 base_name
= get_plugin_base_name (plugin_name
);
185 /* If this is the first -fplugin= option we encounter, create
186 'plugin_name_args_tab' hash table. */
187 if (!plugin_name_args_tab
)
188 plugin_name_args_tab
= htab_create (10, htab_hash_string
, htab_str_eq
,
191 slot
= htab_find_slot (plugin_name_args_tab
, base_name
, INSERT
);
193 /* If the same plugin (name) has been specified earlier, either emit an
194 error or a warning message depending on if they have identical full
198 plugin
= (struct plugin_name_args
*) *slot
;
199 if (strcmp (plugin
->full_name
, plugin_name
))
200 error ("plugin %s was specified with different paths:\n%s\n%s",
201 plugin
->base_name
, plugin
->full_name
, plugin_name
);
205 plugin
= XCNEW (struct plugin_name_args
);
206 plugin
->base_name
= base_name
;
207 plugin
->full_name
= plugin_name
;
213 /* Parse the -fplugin-arg-<name>-<key>[=<value>] option and create a
214 'plugin_argument' object for the parsed key-value pair. ARG is
215 the <name>-<key>[=<value>] part of the option. */
218 parse_plugin_arg_opt (const char *arg
)
220 size_t len
= 0, name_len
= 0, key_len
= 0, value_len
= 0;
221 const char *ptr
, *name_start
= arg
, *key_start
= NULL
, *value_start
= NULL
;
222 char *name
, *key
, *value
;
224 bool name_parsed
= false, key_parsed
= false;
226 /* Iterate over the ARG string and identify the starting character position
227 of 'name', 'key', and 'value' and their lengths. */
228 for (ptr
= arg
; *ptr
; ++ptr
)
230 /* Only the first '-' encountered is considered a separator between
231 'name' and 'key'. All the subsequent '-'s are considered part of
232 'key'. For example, given -fplugin-arg-foo-bar-primary-key=value,
233 the plugin name is 'foo' and the key is 'bar-primary-key'. */
234 if (*ptr
== '-' && !name_parsed
)
242 else if (*ptr
== '=')
248 value_start
= ptr
+ 1;
259 error ("malformed option -fplugin-arg-%s (missing -<key>[=<value>])",
264 /* If the option doesn't contain the 'value' part, LEN is the KEY_LEN.
265 Otherwise, it is the VALUE_LEN. */
271 name
= XNEWVEC (char, name_len
+ 1);
272 strncpy (name
, name_start
, name_len
);
273 name
[name_len
] = '\0';
275 /* Check if the named plugin has already been specified earlier in the
277 if (plugin_name_args_tab
278 && ((slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
))
281 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
283 key
= XNEWVEC (char, key_len
+ 1);
284 strncpy (key
, key_start
, key_len
);
288 value
= XNEWVEC (char, value_len
+ 1);
289 strncpy (value
, value_start
, value_len
);
290 value
[value_len
] = '\0';
295 /* Create a plugin_argument object for the parsed key-value pair.
296 If there are already arguments for this plugin, we will need to
297 adjust the argument array size by creating a new array and deleting
298 the old one. If the performance ever becomes an issue, we can
299 change the code by pre-allocating a larger array first. */
300 if (plugin
->argc
> 0)
302 struct plugin_argument
*args
= XNEWVEC (struct plugin_argument
,
304 memcpy (args
, plugin
->argv
,
305 sizeof (struct plugin_argument
) * plugin
->argc
);
306 XDELETEVEC (plugin
->argv
);
312 gcc_assert (plugin
->argv
== NULL
);
313 plugin
->argv
= XNEWVEC (struct plugin_argument
, 1);
317 plugin
->argv
[plugin
->argc
- 1].key
= key
;
318 plugin
->argv
[plugin
->argc
- 1].value
= value
;
321 error ("plugin %s should be specified before -fplugin-arg-%s "
322 "in the command line", name
, arg
);
324 /* We don't need the plugin's name anymore. Just release it. */
328 /* Register additional plugin information. NAME is the name passed to
329 plugin_init. INFO is the information that should be registered. */
332 register_plugin_info (const char* name
, struct plugin_info
*info
)
334 void **slot
= htab_find_slot (plugin_name_args_tab
, name
, NO_INSERT
);
335 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
336 plugin
->version
= info
->version
;
337 plugin
->help
= info
->help
;
340 /* Look up the event id for NAME. If the name is not found, return -1
341 if INSERT is NO_INSERT. */
344 get_named_event_id (const char *name
, enum insert_option insert
)
352 event_tab
= new hash_table
<event_hasher
> (150);
353 for (i
= 0; i
< event_last
; i
++)
355 slot
= event_tab
->find_slot (&plugin_event_name
[i
], INSERT
);
356 gcc_assert (*slot
== HTAB_EMPTY_ENTRY
);
357 *slot
= &plugin_event_name
[i
];
360 slot
= event_tab
->find_slot (&name
, insert
);
363 if (*slot
!= HTAB_EMPTY_ENTRY
)
364 return *slot
- &plugin_event_name
[0];
366 if (event_last
>= event_horizon
)
368 event_horizon
= event_last
* 2;
369 if (plugin_event_name
== plugin_event_name_init
)
371 plugin_event_name
= XNEWVEC (const char *, event_horizon
);
372 memcpy (plugin_event_name
, plugin_event_name_init
,
373 sizeof plugin_event_name_init
);
374 plugin_callbacks
= XNEWVEC (struct callback_info
*, event_horizon
);
375 memcpy (plugin_callbacks
, plugin_callbacks_init
,
376 sizeof plugin_callbacks_init
);
381 = XRESIZEVEC (const char *, plugin_event_name
, event_horizon
);
382 plugin_callbacks
= XRESIZEVEC (struct callback_info
*,
383 plugin_callbacks
, event_horizon
);
385 /* All the pointers in the hash table will need to be updated. */
390 *slot
= &plugin_event_name
[event_last
];
391 plugin_event_name
[event_last
] = name
;
395 /* Called from the plugin's initialization code. Register a single callback.
396 This function can be called multiple times.
398 PLUGIN_NAME - display name for this plugin
399 EVENT - which event the callback is for
400 CALLBACK - the callback to be called at the event
401 USER_DATA - plugin-provided data */
404 register_callback (const char *plugin_name
,
406 plugin_callback_func callback
,
411 case PLUGIN_PASS_MANAGER_SETUP
:
412 gcc_assert (!callback
);
413 register_pass ((struct register_pass_info
*) user_data
);
416 gcc_assert (!callback
);
417 register_plugin_info (plugin_name
, (struct plugin_info
*) user_data
);
419 case PLUGIN_REGISTER_GGC_ROOTS
:
420 gcc_assert (!callback
);
421 ggc_register_root_tab ((const struct ggc_root_tab
*) user_data
);
423 case PLUGIN_EVENT_FIRST_DYNAMIC
:
425 if (event
< PLUGIN_EVENT_FIRST_DYNAMIC
|| event
>= event_last
)
427 error ("unknown callback event registered by plugin %s",
432 case PLUGIN_FINISH_TYPE
:
433 case PLUGIN_FINISH_DECL
:
434 case PLUGIN_START_UNIT
:
435 case PLUGIN_FINISH_UNIT
:
436 case PLUGIN_PRE_GENERICIZE
:
437 case PLUGIN_GGC_START
:
438 case PLUGIN_GGC_MARKING
:
440 case PLUGIN_ATTRIBUTES
:
443 case PLUGIN_ALL_PASSES_START
:
444 case PLUGIN_ALL_PASSES_END
:
445 case PLUGIN_ALL_IPA_PASSES_START
:
446 case PLUGIN_ALL_IPA_PASSES_END
:
447 case PLUGIN_OVERRIDE_GATE
:
448 case PLUGIN_PASS_EXECUTION
:
449 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
450 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
451 case PLUGIN_NEW_PASS
:
452 case PLUGIN_INCLUDE_FILE
:
454 struct callback_info
*new_callback
;
457 error ("plugin %s registered a null callback function "
458 "for event %s", plugin_name
, plugin_event_name
[event
]);
461 new_callback
= XNEW (struct callback_info
);
462 new_callback
->plugin_name
= plugin_name
;
463 new_callback
->func
= callback
;
464 new_callback
->user_data
= user_data
;
465 new_callback
->next
= plugin_callbacks
[event
];
466 plugin_callbacks
[event
] = new_callback
;
472 /* Remove a callback for EVENT which has been registered with for a plugin
473 PLUGIN_NAME. Return PLUGEVT_SUCCESS if a matching callback was
474 found & removed, PLUGEVT_NO_CALLBACK if the event does not have a matching
475 callback, and PLUGEVT_NO_SUCH_EVENT if EVENT is invalid. */
477 unregister_callback (const char *plugin_name
, int event
)
479 struct callback_info
*callback
, **cbp
;
481 if (event
>= event_last
)
482 return PLUGEVT_NO_SUCH_EVENT
;
484 for (cbp
= &plugin_callbacks
[event
]; (callback
= *cbp
); cbp
= &callback
->next
)
485 if (strcmp (callback
->plugin_name
, plugin_name
) == 0)
487 *cbp
= callback
->next
;
488 return PLUGEVT_SUCCESS
;
490 return PLUGEVT_NO_CALLBACK
;
493 /* Invoke all plugin callbacks registered with the specified event,
494 called from invoke_plugin_callbacks(). */
497 invoke_plugin_callbacks_full (int event
, void *gcc_data
)
499 int retval
= PLUGEVT_SUCCESS
;
501 timevar_push (TV_PLUGIN_RUN
);
505 case PLUGIN_EVENT_FIRST_DYNAMIC
:
507 gcc_assert (event
>= PLUGIN_EVENT_FIRST_DYNAMIC
);
508 gcc_assert (event
< event_last
);
510 case PLUGIN_FINISH_TYPE
:
511 case PLUGIN_FINISH_DECL
:
512 case PLUGIN_START_UNIT
:
513 case PLUGIN_FINISH_UNIT
:
514 case PLUGIN_PRE_GENERICIZE
:
515 case PLUGIN_ATTRIBUTES
:
518 case PLUGIN_GGC_START
:
519 case PLUGIN_GGC_MARKING
:
521 case PLUGIN_ALL_PASSES_START
:
522 case PLUGIN_ALL_PASSES_END
:
523 case PLUGIN_ALL_IPA_PASSES_START
:
524 case PLUGIN_ALL_IPA_PASSES_END
:
525 case PLUGIN_OVERRIDE_GATE
:
526 case PLUGIN_PASS_EXECUTION
:
527 case PLUGIN_EARLY_GIMPLE_PASSES_START
:
528 case PLUGIN_EARLY_GIMPLE_PASSES_END
:
529 case PLUGIN_NEW_PASS
:
530 case PLUGIN_INCLUDE_FILE
:
532 /* Iterate over every callback registered with this event and
534 struct callback_info
*callback
= plugin_callbacks
[event
];
537 retval
= PLUGEVT_NO_CALLBACK
;
538 for ( ; callback
; callback
= callback
->next
)
539 (*callback
->func
) (gcc_data
, callback
->user_data
);
543 case PLUGIN_PASS_MANAGER_SETUP
:
544 case PLUGIN_REGISTER_GGC_ROOTS
:
548 timevar_pop (TV_PLUGIN_RUN
);
553 /* We need a union to cast dlsym return value to a function pointer
554 as ISO C forbids assignment between function pointer and 'void *'.
555 Use explicit union instead of __extension__(<union_cast>) for
557 #define PTR_UNION_TYPE(TOTYPE) union { void *_q; TOTYPE _nq; }
558 #define PTR_UNION_AS_VOID_PTR(NAME) (NAME._q)
559 #define PTR_UNION_AS_CAST_PTR(NAME) (NAME._nq)
561 /* Try to initialize PLUGIN. Return true if successful. */
564 try_init_one_plugin (struct plugin_name_args
*plugin
)
567 plugin_init_func plugin_init
;
569 PTR_UNION_TYPE (plugin_init_func
) plugin_init_union
;
571 /* We use RTLD_NOW to accelerate binding and detect any mismatch
572 between the API expected by the plugin and the GCC API; we use
573 RTLD_GLOBAL which is useful to plugins which themselves call
575 dl_handle
= dlopen (plugin
->full_name
, RTLD_NOW
| RTLD_GLOBAL
);
578 error ("cannot load plugin %s\n%s", plugin
->full_name
, dlerror ());
582 /* Clear any existing error. */
585 /* Check the plugin license. */
586 if (dlsym (dl_handle
, str_license
) == NULL
)
587 fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
588 "%s", plugin
->full_name
, dlerror ());
590 PTR_UNION_AS_VOID_PTR (plugin_init_union
) =
591 dlsym (dl_handle
, str_plugin_init_func_name
);
592 plugin_init
= PTR_UNION_AS_CAST_PTR (plugin_init_union
);
594 if ((err
= dlerror ()) != NULL
)
596 error ("cannot find %s in plugin %s\n%s", str_plugin_init_func_name
,
597 plugin
->full_name
, err
);
601 /* Call the plugin-provided initialization routine with the arguments. */
602 if ((*plugin_init
) (plugin
, &gcc_version
))
604 error ("fail to initialize plugin %s", plugin
->full_name
);
612 /* Routine to dlopen and initialize one plugin. This function is passed to
613 (and called by) the hash table traverse routine. Return 1 for the
614 htab_traverse to continue scan, 0 to stop.
616 SLOT - slot of the hash table element
617 INFO - auxiliary pointer handed to hash table traverse routine
618 (unused in this function) */
621 init_one_plugin (void **slot
, void * ARG_UNUSED (info
))
623 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
624 bool ok
= try_init_one_plugin (plugin
);
627 htab_remove_elt (plugin_name_args_tab
, plugin
->base_name
);
633 #endif /* ENABLE_PLUGIN */
635 /* Main plugin initialization function. Called from compile_file() in
639 initialize_plugins (void)
641 /* If no plugin was specified in the command-line, simply return. */
642 if (!plugin_name_args_tab
)
645 timevar_push (TV_PLUGIN_INIT
);
648 /* Traverse and initialize each plugin specified in the command-line. */
649 htab_traverse_noresize (plugin_name_args_tab
, init_one_plugin
, NULL
);
652 timevar_pop (TV_PLUGIN_INIT
);
655 /* Release memory used by one plugin. */
658 finalize_one_plugin (void **slot
, void * ARG_UNUSED (info
))
660 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
665 /* Free memory allocated by the plugin system. */
668 finalize_plugins (void)
670 if (!plugin_name_args_tab
)
673 /* We can now delete the plugin_name_args object as it will no longer
674 be used. Note that base_name and argv fields (both of which were also
675 dynamically allocated) are not freed as they could still be used by
678 htab_traverse_noresize (plugin_name_args_tab
, finalize_one_plugin
, NULL
);
680 /* PLUGIN_NAME_ARGS_TAB is no longer needed, just delete it. */
681 htab_delete (plugin_name_args_tab
);
682 plugin_name_args_tab
= NULL
;
685 /* Used to pass options to htab_traverse callbacks. */
693 /* Print the version of one plugin. */
696 print_version_one_plugin (void **slot
, void *data
)
698 struct print_options
*opt
= (struct print_options
*) data
;
699 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
700 const char *version
= plugin
->version
? plugin
->version
: "Unknown version.";
702 fprintf (opt
->file
, " %s%s: %s\n", opt
->indent
, plugin
->base_name
, version
);
706 /* Print the version of each plugin. */
709 print_plugins_versions (FILE *file
, const char *indent
)
711 struct print_options opt
;
714 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
717 fprintf (file
, "%sVersions of loaded plugins:\n", indent
);
718 htab_traverse_noresize (plugin_name_args_tab
, print_version_one_plugin
, &opt
);
721 /* Print help for one plugin. SLOT is the hash table slot. DATA is the
722 argument to htab_traverse_noresize. */
725 print_help_one_plugin (void **slot
, void *data
)
727 struct print_options
*opt
= (struct print_options
*) data
;
728 struct plugin_name_args
*plugin
= (struct plugin_name_args
*) *slot
;
729 const char *help
= plugin
->help
? plugin
->help
: "No help available .";
731 char *dup
= xstrdup (help
);
733 fprintf (opt
->file
, " %s%s:\n", opt
->indent
, plugin
->base_name
);
735 for (p
= nl
= dup
; nl
; p
= nl
)
737 nl
= strchr (nl
, '\n');
743 fprintf (opt
->file
, " %s %s\n", opt
->indent
, p
);
750 /* Print help for each plugin. The output goes to FILE and every line starts
754 print_plugins_help (FILE *file
, const char *indent
)
756 struct print_options opt
;
759 if (!plugin_name_args_tab
|| htab_elements (plugin_name_args_tab
) == 0)
762 fprintf (file
, "%sHelp for the loaded plugins:\n", indent
);
763 htab_traverse_noresize (plugin_name_args_tab
, print_help_one_plugin
, &opt
);
767 /* Return true if plugins have been loaded. */
770 plugins_active_p (void)
774 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
775 if (plugin_callbacks
[event
])
782 /* Dump to FILE the names and associated events for all the active
786 dump_active_plugins (FILE *file
)
790 if (!plugins_active_p ())
793 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" | %s\n", _("Event"), _("Plugins"));
794 for (event
= PLUGIN_PASS_MANAGER_SETUP
; event
< event_last
; event
++)
795 if (plugin_callbacks
[event
])
797 struct callback_info
*ci
;
799 fprintf (file
, FMT_FOR_PLUGIN_EVENT
" |", plugin_event_name
[event
]);
801 for (ci
= plugin_callbacks
[event
]; ci
; ci
= ci
->next
)
802 fprintf (file
, " %s", ci
->plugin_name
);
809 /* Dump active plugins to stderr. */
812 debug_active_plugins (void)
814 dump_active_plugins (stderr
);
817 /* Give a warning if plugins are present, before an ICE message asking
818 to submit a bug report. */
821 warn_if_plugins (void)
823 if (plugins_active_p ())
825 fnotice (stderr
, "*** WARNING *** there are active plugins, do not report"
826 " this as a bug unless you can reproduce it without enabling"
828 dump_active_plugins (stderr
);
833 /* Likewise, as a callback from the diagnostics code. */
836 plugins_internal_error_function (diagnostic_context
*context ATTRIBUTE_UNUSED
,
837 const char *msgid ATTRIBUTE_UNUSED
,
838 va_list *ap ATTRIBUTE_UNUSED
)
843 /* The default version check. Compares every field in VERSION. */
846 plugin_default_version_check (struct plugin_gcc_version
*gcc_version
,
847 struct plugin_gcc_version
*plugin_version
)
849 if (!gcc_version
|| !plugin_version
)
852 if (strcmp (gcc_version
->basever
, plugin_version
->basever
))
854 if (strcmp (gcc_version
->datestamp
, plugin_version
->datestamp
))
856 if (strcmp (gcc_version
->devphase
, plugin_version
->devphase
))
858 if (strcmp (gcc_version
->revision
, plugin_version
->revision
))
860 if (strcmp (gcc_version
->configuration_arguments
,
861 plugin_version
->configuration_arguments
))
867 /* Return the current value of event_last, so that plugins which provide
868 additional functionality for events for the benefit of high-level plugins
869 know how many valid entries plugin_event_name holds. */
872 get_event_last (void)
878 /* Retrieve the default plugin directory. The gcc driver should have passed
879 it as -iplugindir <dir> to the cc1 program, and it is queriable through the
880 -print-file-name=plugin option to gcc. */
882 default_plugin_dir_name (void)
884 if (!plugindir_string
)
885 fatal_error ("-iplugindir <dir> option not passed from the gcc driver");
886 return plugindir_string
;