Plugins are supported on platforms that support -ldl
-rdynamic as well as Windows/MinGW. They are loaded by the compiler
using dlopen
or equivalent and invoked at pre-determined
locations in the compilation process.
Plugins are loaded with
-fplugin=/path/to/name.ext -fplugin-arg-name-key1[=value1]
Where name is the plugin name and ext is the platform-specific
dynamic library extension. It should be dll
on Windows/MinGW,
dylib
on Darwin/Mac OS X, and so
on all other platforms.
The plugin arguments are parsed by GCC and passed to respective
plugins as key-value pairs. Multiple plugins can be invoked by
specifying multiple -fplugin arguments.
A plugin can be simply given by its short name (no dots or slashes). When simply passing -fplugin=name, the plugin is loaded from the plugin directory, so -fplugin=name is the same as -fplugin=`gcc -print-file-name=plugin`/name.ext, using backquote shell syntax to query the plugin directory.