which halt the compilation at each function, showing a graphviz-rendered diagram of that function (in the "gimple" representation, or the gimple representation after transforming to Static Single Assigment form). An interested developer can invoke these scripts by replacing "gcc" with "gcc-with-python PATH_TO_SCRIPT":

+

which halt the compilation at each function, showing a graphviz-rendered diagram of that function (in the "gimple" representation, or the gimple representation after transforming to Static Single Assigment form). An interested developer can invoke these scripts by replacing "gcc" with "gcc-with-python2 PATH_TO_SCRIPT":

−

<code>gcc-with-python show-gimple.py main.c</code>

+

<code>gcc-with-python2 show-gimple.py main.c</code>

TODO: ensure that the scripts are actually packaged

TODO: ensure that the scripts are actually packaged

Line 96:

Line 96:

Developers will be able to invoke Python scripts whilst running GCC by using a script that invokes gcc with the plugin:

Developers will be able to invoke Python scripts whilst running GCC by using a script that invokes gcc with the plugin:

GCC Python Plugins

Summary

I have created a GCC plugin that embeds Python within GCC. Interested developers should be able to use this to easily extend GCC by writing Python scripts, such as adding new warnings for a library that they work on, without needing to use C.

Benefit to Fedora

Fedora is already a very attractive platform for software development. By making it very easy to extend GCC, the plugin makes Fedora even more compelling to developers. The plugin code was written by a Fedora developer, and is a "Fedora Hosted" project.

Scope

This involves:

writing the plugin

packaging it

documenting it

keeping it in sync with gcc

How To Test

The plugin already has a testsuite, which "make" runs.

TODO: make it run it within the %check

The plugin ships with some sample scripts:

show-gimple.py

show-ssa.py

which halt the compilation at each function, showing a graphviz-rendered diagram of that function (in the "gimple" representation, or the gimple representation after transforming to Static Single Assigment form). An interested developer can invoke these scripts by replacing "gcc" with "gcc-with-python2 PATH_TO_SCRIPT":

gcc-with-python2 show-gimple.py main.c

TODO: ensure that the scripts are actually packaged

User Experience

Non-technical end-users of Fedora should see no difference.

Developers will be able to invoke Python scripts whilst running GCC by using a script that invokes gcc with the plugin:

gcc-with-python2 PATH_TO_SCRIPT.py rest of regular gcc args

for a Python 2 script and:

gcc-with-python3 PATH_TO_SCRIPT.py rest of regular gcc args

Alternatively, this is equivalent:

gcc -fplugin=python2 -fplugin-arg-python2-script=PATH_TO_SCRIPT.py

for a Python 2 script and:

gcc -fplugin=python3 -fplugin-arg-python3-script=PATH_TO_SCRIPT.py

for a Python 3 script.

Dependencies

This will require working closely with the gcc maintainer. I anticipate needing to rebuild the plugin each time that gcc is rebuilt.

Documentation

Release Notes

GCC plugins that embed Python are now available, enabling developers to more easily hook into GCC's inner workings (e.g. to add new compiler warnings). These were written by Fedora contributor David Malcolm.